Skip to content

Commit

Permalink
Handle removing unknown application from a bundle through overlay pro…
Browse files Browse the repository at this point in the history
…cessing.
  • Loading branch information
howbazaar committed Feb 15, 2018
1 parent 1de2826 commit 8dfb299
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/juju/application/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,17 +1172,17 @@ func processSingleBundleOverlay(data *charm.BundleData, bundleOverlayFile string
// actually exist in the bundle data.
for appName, bc := range config.Applications {
app, found := data.Applications[appName]
if !found {
// Add it in.
data.Applications[appName] = bc
continue
}
// If bc is nil, that means to remove it from data.
if bc == nil {
delete(data.Applications, appName)
data.Relations = removeRelations(data.Relations, appName)
continue
}
if !found {
// Add it in.
data.Applications[appName] = bc
continue
}

fieldCheck := configCheck.Applications[appName]

Expand Down
14 changes: 14 additions & 0 deletions cmd/juju/application/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,20 @@ func (s *ProcessBundleOverlaySuite) TestRemoveApplication(c *gc.C) {
c.Assert(s.bundleData.Relations, gc.HasLen, 0)
}

func (s *ProcessBundleOverlaySuite) TestRemoveUnknownApplication(c *gc.C) {
config := `
applications:
unknown:
`
filename := s.writeFile(c, config)
err := processBundleOverlay(s.bundleData, filename)
c.Assert(err, jc.ErrorIsNil)
s.assertApplications(c, "django", "memcached")
c.Assert(s.bundleData.Relations, jc.DeepEquals, [][]string{
{"django", "memcached"},
})
}

func (s *ProcessBundleOverlaySuite) TestIncludes(c *gc.C) {
config := `
applications:
Expand Down

0 comments on commit 8dfb299

Please sign in to comment.