Skip to content

Commit

Permalink
Merge pull request #116 from tlm/credential-upgrade
Browse files Browse the repository at this point in the history
Adds case to support kubernetes series.
  • Loading branch information
tlm authored Oct 21, 2022
2 parents 8f350f6 + 8add49f commit e1ecc72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions charmorigin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,20 @@ type charmOrigin struct {
Platform_ string `yaml:"platform"`
}

const (
defaultKubernetesPlatform = "unknown/kubernetes/kubernetes"
kubernetesSeries = "kubernetes"
)

func platformFromSeries(s string) (string, error) {
if s == "" {
return "", errors.New("cannot convert empty series to a platform")
}

if s == kubernetesSeries {
return defaultKubernetesPlatform, nil
}

os, err := series.GetOSFromSeries(s)
if err != nil {
return "", fmt.Errorf("extracting os from series %q: %w", s, err)
Expand Down
4 changes: 4 additions & 0 deletions charmorigin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func (s *CharmOriginSerializationSuite) TestPlatformFromSeries(c *gc.C) {
expectedVal: "unknown/windows/win2008r2",
series: "win2008r2",
},
{
expectedVal: "unknown/kubernetes/kubernetes",
series: "kubernetes",
},
}

for _, test := range tests {
Expand Down

0 comments on commit e1ecc72

Please sign in to comment.