Skip to content

feat: add --version flag to coder templates pull, default to active version #10153

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

Conversation

coadler
Copy link
Contributor

@coadler coadler commented Oct 9, 2023

Fixes #9837

@coadler
Copy link
Contributor Author

coadler commented Oct 9, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@coadler coadler requested a review from deansheather October 9, 2023 22:01
Comment on lines +52 to 73
var latestVersion codersdk.TemplateVersion
{
// Determine the latest template version and compare with the
// active version. If they aren't the same, warn the user.
versions, err := client.TemplateVersionsByTemplate(ctx, codersdk.TemplateVersionsByTemplateRequest{
TemplateID: template.ID,
})
if err != nil {
return xerrors.Errorf("template versions by template: %w", err)
}

if len(versions) == 0 {
return xerrors.Errorf("no template versions for template %q", templateName)
}

// Sort the slice from newest to oldest template.
sort.SliceStable(versions, func(i, j int) bool {
return versions[i].CreatedAt.After(versions[j].CreatedAt)
})

if len(versions) == 0 {
return xerrors.Errorf("no template versions for template %q", templateName)
latestVersion = versions[0]
}
Copy link
Member

Choose a reason for hiding this comment

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

You should move this into the switch when you pick latest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to know the latest version for the warning when the version isn't specified.

@coadler coadler merged commit c11f241 into main Oct 10, 2023
@coadler coadler deleted the colin/featadd--versionflagtocodertemplatespulldefaulttoactiveversion branch October 10, 2023 15:20
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

coder templates pull: should pull the promoted version, not the latest
2 participants