Skip to content

Commit

Permalink
Merge pull request #14661 from wallyworld/merge-2.9-20220926
Browse files Browse the repository at this point in the history
#14661

Merge 2.9

#14637
#14638
#14641
#14612
#14646
#14647
#14649
#14628
#14654

Conflicts
```
# Conflicts:
# apiserver/facades/client/application/deploy.go
# apiserver/facades/client/charmhub/charmhub_test.go
# apiserver/facades/client/charmhub/convert.go
# apiserver/facades/client/charms/conversions.go
# apiserver/facades/client/machinemanager/machinemanager.go
# apiserver/facades/client/machinemanager/machinemanager_test.go
# apiserver/facades/client/machinemanager/register.go
# apiserver/facades/client/resources/repository.go
# apiserver/facades/schema.json
# cmd/juju/application/deploy_test.go
# cmd/juju/application/deployer/bundlehandler.go
# cmd/juju/machine/add.go
# core/charm/strategies.go
# core/charm/strategies_test.go
# core/series/supportedseries.go
# core/series/supportedseries_test.go
# environs/manual/winrmprovisioner/provisioner_test.go
# rpc/params/applications.go
# rpc/params/params.go
# state/charm.go
# tests/includes/storage.sh
```

## Checklist

- [X] Code style: imports ordered, good names, simple structure, etc
- [X] Comments saying why design decisions were made
- [X] Go unit tests, with comments saying what you're testing
- ~[ ] [Integration tests](https://github.com/juju/juju/tree/develop/tests), with comments saying what you're testing~
- ~[ ] [doc.go](https://discourse.charmhub.io/t/readme-in-packages/451) added or updated in changed packages~

## QA steps

See PRs
  • Loading branch information
jujubot authored Sep 26, 2022
2 parents 60f440a + d387de4 commit 2736835
Show file tree
Hide file tree
Showing 61 changed files with 816 additions and 680 deletions.
4 changes: 2 additions & 2 deletions api/client/charms/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (s *charmsMockSuite) TestAddCharm(c *gc.C) {
Track: nil,
Architecture: arch.DefaultArchitecture,
OS: "ubuntu",
Series: "bionic",
Channel: "18.04",
}
facadeArgs := params.AddCharmWithOrigin{
URL: curl.String(),
Expand Down Expand Up @@ -219,7 +219,7 @@ func (s *charmsMockSuite) TestAddCharmWithAuthorization(c *gc.C) {
Track: nil,
Architecture: arch.DefaultArchitecture,
OS: "ubuntu",
Series: "bionic",
Channel: "18.04",
}
facadeArgs := params.AddCharmWithAuth{
URL: curl.String(),
Expand Down
2 changes: 1 addition & 1 deletion api/client/resources/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func newAddPendingResourcesArgsV2(tag names.ApplicationTag, chID CharmID, csMac
Track: chID.Origin.Track,
Architecture: chID.Origin.Architecture,
OS: chID.Origin.OS,
Series: chID.Origin.Series,
Channel: chID.Origin.Channel,
}
args.CharmStoreMacaroon = csMac
return args, nil
Expand Down
24 changes: 16 additions & 8 deletions api/common/charm/charmorigin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/juju/charm/v9"

corecharm "github.com/juju/juju/core/charm"
"github.com/juju/juju/core/series"
"github.com/juju/juju/rpc/params"
)

Expand Down Expand Up @@ -48,8 +49,8 @@ type Origin struct {
Architecture string
// OS describes the OS intended to be used by the charm.
OS string
// Series describes the series of the OS intended to be used by the charm.
Series string
// Channel describes the channel (version) of the OS intended to be used by the charm.
Channel string

// InstanceKey is a unique string associated with the application. To
// assist with keeping KPI data in charmhub, it must be the same for every
Expand All @@ -59,9 +60,16 @@ type Origin struct {
}

// WithSeries allows to update the series of an origin.
func (o Origin) WithSeries(series string) Origin {
// TODO(juju3) - remove, replace with os/channel
func (o Origin) WithSeries(aseries string) Origin {
other := o
other.Series = series
other.Channel = ""
other.OS = ""
if aseries != "" {
base, _ := series.GetBaseFromSeries(aseries)
other.OS = base.Name
other.Channel = base.Channel
}
return other
}

Expand Down Expand Up @@ -96,7 +104,7 @@ func (o Origin) ParamsCharmOrigin() params.CharmOrigin {
Branch: o.Branch,
Architecture: o.Architecture,
OS: o.OS,
Series: o.Series,
Channel: o.Channel,
InstanceKey: o.InstanceKey,
}
}
Expand Down Expand Up @@ -129,7 +137,7 @@ func (o Origin) CoreCharmOrigin() corecharm.Origin {
Platform: corecharm.Platform{
Architecture: o.Architecture,
OS: o.OS,
Series: o.Series,
Channel: o.Channel,
},
InstanceKey: o.InstanceKey,
}
Expand All @@ -149,7 +157,7 @@ func APICharmOrigin(origin params.CharmOrigin) Origin {
Branch: origin.Branch,
Architecture: origin.Architecture,
OS: origin.OS,
Series: origin.Series,
Channel: origin.Channel,
InstanceKey: origin.InstanceKey,
}
}
Expand Down Expand Up @@ -180,7 +188,7 @@ func CoreCharmOrigin(origin corecharm.Origin) Origin {
Branch: branch,
Architecture: origin.Platform.Architecture,
OS: origin.Platform.OS,
Series: origin.Platform.Series,
Channel: origin.Platform.Channel,
InstanceKey: origin.InstanceKey,
}
}
18 changes: 13 additions & 5 deletions apiserver/facades/client/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func convertCharmOrigin(origin *params.CharmOrigin, curl *charm.URL, charmStoreC
platform = corecharm.Platform{
Architecture: origin.Architecture,
OS: origin.OS,
Series: origin.Series,
Channel: origin.Channel,
}
}

Expand Down Expand Up @@ -1218,12 +1218,15 @@ func (api *APIBase) GetCharmURLOrigin(args params.ApplicationGet) (params.CharmU
result.Error = apiservererrors.ServerError(errors.NotFoundf("charm origin for %q", args.ApplicationName))
return result, nil
}
result.Origin = makeParamsCharmOrigin(chOrigin)
if result.Origin, err = makeParamsCharmOrigin(chOrigin); err != nil {
result.Error = apiservererrors.ServerError(errors.NotFoundf("charm origin for %q", args.ApplicationName))
return result, nil
}
result.Origin.InstanceKey = charmhub.CreateInstanceKey(oneApplication.ApplicationTag(), api.model.ModelTag())
return result, nil
}

func makeParamsCharmOrigin(origin *state.CharmOrigin) params.CharmOrigin {
func makeParamsCharmOrigin(origin *state.CharmOrigin) (params.CharmOrigin, error) {
retOrigin := params.CharmOrigin{
Source: origin.Source,
ID: origin.ID,
Expand All @@ -1244,9 +1247,14 @@ func makeParamsCharmOrigin(origin *state.CharmOrigin) params.CharmOrigin {
if origin.Platform != nil {
retOrigin.Architecture = origin.Platform.Architecture
retOrigin.OS = origin.Platform.OS
retOrigin.Series = origin.Platform.Series
// TODO(juju3) - use channel not series in state
base, err := series.GetBaseFromSeries(origin.Platform.Series)
if err != nil {
return params.CharmOrigin{}, errors.Trace(err)
}
retOrigin.Channel = base.Channel
}
return retOrigin
return retOrigin, nil
}

// CharmRelations implements the server side of Application.CharmRelations.
Expand Down
Loading

0 comments on commit 2736835

Please sign in to comment.