-
Notifications
You must be signed in to change notification settings - Fork 887
feat: archive template versions to hide them from the ui #10179
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
} | ||
|
||
if !templateVersion.TemplateID.Valid { | ||
// Maybe we should allow this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not allowing arching orphaned versions atm, as it makes them impossible to find. Not sure what we should do with orphaned versions, but we can make this a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what a user could even do with these? I think it makes sense to kick this one down the road.
func(next clibase.HandlerFunc) clibase.HandlerFunc { | ||
return func(i *clibase.Invocation) error { | ||
// This is the only way to dynamically add the "archived" | ||
// column if '--include-archived' is true. | ||
// It does not make sense to show this column if the | ||
// flag is false. | ||
if includeArchived { | ||
for _, opt := range i.Command.Options { | ||
if opt.Flag == "column" { | ||
if opt.ValueSource == clibase.ValueSourceDefault { | ||
v, ok := opt.Value.(*clibase.StringArray) | ||
if ok { | ||
// Add the extra new default column. | ||
*v = append(*v, "Archived") | ||
} | ||
} | ||
break | ||
} | ||
} | ||
} | ||
return next(i) | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 That's cool, didn't know you could do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, it's a little janky imo, but the value is tied to the option 😢.
If we have to do this more often, I can create a helper Middleware to do this more generally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only adds the column if the user is using the default columns
} | ||
|
||
if !templateVersion.TemplateID.Valid { | ||
// Maybe we should allow this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what a user could even do with these? I think it makes sense to kick this one down the road.
cli/templateversionarchive_test.go
Outdated
"github.com/coder/coder/v2/provisioner/echo" | ||
|
||
"github.com/coder/coder/v2/codersdk" | ||
|
||
"github.com/coder/coder/v2/testutil" | ||
|
||
"github.com/coder/coder/v2/coderd/rbac" | ||
|
||
"github.com/coder/coder/v2/cli/clitest" | ||
"github.com/coder/coder/v2/coderd/coderdtest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports
q.mutex.Lock() | ||
defer q.mutex.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always forget this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently same lol
What this does
Allows "archiving" template versions to clean them up from the UX. By default archived are not listed when calling
/versions
for a template. This action is reversible. Archived versions cannot be promoted or used in workspace builds.Template versions that are in use or the current active template version cannot be archived.
Closes #9478
Cli Commands
Archive a template
Archive a template version
Archive/unarchive specific versions.
Future Work