Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JUJU-3315] Force "stable" channel to be "latest/stable" when reading apps. #204

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion internal/juju/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,18 @@ func (c applicationsClient) ReadApplication(input *ReadApplicationInput) (*ReadA
exposed["cidrs"] = cidrs
}

// (juanmanuel-tirado) In certain scenarios depending on how
// charms are uploaded to CharmHub, Juju may register the
// latest/stable channel as stable. We check this case here
// and force it to be latest/stable
normalizedChannel := appInfo.Channel
if normalizedChannel == "stable" {
normalizedChannel = "latest/stable"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect. We shouldn't need to coerce the track in the client. The app is deployed with the channel stable and ReadApplication (applicationAPIClient.ApplicationsInfo really) is correctly bringing the channel as stable. I think the problem is we incorrectly default to latest/stable when a channel is not specified. I believe the correct fix is defaulting to just stable instead of fixating the track as well.

}

response := &ReadApplicationResponse{
Name: charmURL.Name,
Channel: appStatus.CharmChannel,
Channel: normalizedChannel,
Revision: charmURL.Revision,
Series: appInfo.Series,
Units: unitCount,
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ func resourceApplication() *schema.Resource {
},
"placement": {
Description: "Specify the target location for the application's units",
Type: schema.TypeString,
Optional: true,
Computed: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"principal": {
Description: "Whether this is a Principal application",
Expand Down