Skip to content

Commit

Permalink
Delegate defaulting series of local charms to deploy
Browse files Browse the repository at this point in the history
This does not really belong in bundle client-side code, but should live
in the controller/deployment side of things
  • Loading branch information
jack-w-shaw committed Aug 11, 2023
1 parent f3c2ea8 commit 1521e4c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
24 changes: 0 additions & 24 deletions core/bundle/changes/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3668,30 +3668,6 @@ func (s *changesSuite) TestLocalCharmWithExplicitBase(c *gc.C) {
s.assertLocalBundleChangesWithDevices(c, charmDir, bundleContent, "ubuntu@16.04/stable")
}

func (s *changesSuite) TestLocalCharmWithSeriesFromCharm(c *gc.C) {
charmDir := filepath.Join(c.MkDir(), "multiseries")
err := os.Mkdir(charmDir, 0700)
c.Assert(err, jc.ErrorIsNil)
bundleContent := fmt.Sprintf(`
applications:
django:
charm: %s
`, charmDir)
charmMeta := `
name: multi-series
summary: That's a dummy charm with multi-series.
description: A dummy charm.
series:
- jammy
- focal
- bionic
`[1:]
err = os.WriteFile(filepath.Join(charmDir, "metadata.yaml"), []byte(charmMeta), 0644)
c.Assert(err, jc.ErrorIsNil)
s.assertLocalBundleChanges(c, charmDir, bundleContent, "ubuntu@22.04/stable")
s.assertLocalBundleChangesWithDevices(c, charmDir, bundleContent, "ubuntu@22.04/stable")
}

func (s *changesSuite) TestLocalCharmWithBaseFromBundle(c *gc.C) {
charmDir := c.MkDir()
bundleContent := fmt.Sprintf(`
Expand Down
16 changes: 1 addition & 15 deletions core/bundle/changes/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/juju/naturalsort"

corebase "github.com/juju/juju/core/base"
corecharm "github.com/juju/juju/core/charm"
)

type resolver struct {
Expand Down Expand Up @@ -1288,20 +1287,7 @@ func getSeries(application *charm.ApplicationSpec, defaultSeries string) (string

// Handle local charm paths.
if charm.IsValidLocalCharmOrBundlePath(application.Charm) {
_, charmURL, err := corecharm.NewCharmAtPath(application.Charm, defaultSeries)
if corecharm.IsMissingSeriesError(err) {
// local charm path is valid but the charm doesn't declare a default series.
return defaultSeries, nil
} else if corecharm.IsUnsupportedSeriesError(err) {
// The bundle's default series is not supported by the charm, but we'll
// use it anyway. This is no different to the case above where application.Series
// is used without checking for potential charm incompatibility.
return defaultSeries, nil
} else if err != nil {
return "", errors.Trace(err)
}
// Return the default series from the local charm.
return charmURL.Series, nil
return defaultSeries, nil
}

// The following is safe because the bundle data is assumed to be already
Expand Down

0 comments on commit 1521e4c

Please sign in to comment.