Skip to content

Commit

Permalink
Adds case to support kubernetes series.
Browse files Browse the repository at this point in the history
  • Loading branch information
tlm committed Oct 21, 2022
1 parent 8f350f6 commit 8add49f
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 8add49f

Please sign in to comment.