Skip to content

feat: archive template versions to hide them from the ui #10086

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

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fc715fd
prune template versions
Emyrk Oct 5, 2023
611dac1
Implement fakes and mocks
Emyrk Oct 5, 2023
1de0a5d
Exclude template active versions
Emyrk Oct 5, 2023
3e5f91d
Delete versions are unusable
Emyrk Oct 5, 2023
9200779
Merge remote-tracking branch 'origin/main' into stevenmasley/soft_del…
Emyrk Oct 5, 2023
6e6fbc3
migration bump
Emyrk Oct 5, 2023
2e2c092
Spaces to tabs
Emyrk Oct 5, 2023
7f3d805
add template version prune command
Emyrk Oct 9, 2023
02aa085
Rename to archive
Emyrk Oct 9, 2023
9a416c3
Rename to "archive"
Emyrk Oct 9, 2023
c82ff9a
Merge remote-tracking branch 'origin/main' into stevenmasley/soft_del…
Emyrk Oct 9, 2023
c06d63a
Bump migration file
Emyrk Oct 9, 2023
460b0d2
Make update golden files
Emyrk Oct 9, 2023
d9bfea5
Fix swagger id
Emyrk Oct 9, 2023
655c906
Fix swagger accept json
Emyrk Oct 9, 2023
d4e54b2
Make gen
Emyrk Oct 9, 2023
938f256
Add unarchive
Emyrk Oct 9, 2023
7498c73
Add unarchive api
Emyrk Oct 9, 2023
685512a
Add cli command to unarchive a version
Emyrk Oct 9, 2023
f446ae5
Linting
Emyrk Oct 9, 2023
a9ff9d6
Update golden files
Emyrk Oct 9, 2023
b83a15e
Move cmd commands, allow archiuve deleted
Emyrk Oct 9, 2023
0ecbb79
update golden files
Emyrk Oct 9, 2023
bb3571b
Fix cli errors
Emyrk Oct 9, 2023
533e913
Move cmd
Emyrk Oct 9, 2023
02555b1
Implement fake
Emyrk Oct 9, 2023
1606b99
Linting and gen
Emyrk Oct 9, 2023
3818a57
fixup! Linting and gen
Emyrk Oct 9, 2023
48e44b6
fix: properly trim spaces so multi-line shebang executes (#10146)
kylecarbs Oct 9, 2023
3c97681
chore: reorganize storybook (#10144)
aslilac Oct 9, 2023
f01a4b3
chore: bump the golang-x group with 6 updates (#10128)
dependabot[bot] Oct 9, 2023
e9b4d15
chore: bump google.golang.org/api from 0.143.0 to 0.145.0 (#10130)
dependabot[bot] Oct 9, 2023
4236fc8
ci: bump the github-actions group with 2 updates (#10131)
dependabot[bot] Oct 9, 2023
8c86767
chore: add icons for popular programming languages (#10141)
aslilac Oct 9, 2023
02bcd20
chore: run `go mod tidy`
coadler Oct 9, 2023
91a2025
feat: add `external-auth` cli (#10052)
kylecarbs Oct 9, 2023
54509e5
feat: allow storing extra oauth token properties in the database (#10…
kylecarbs Oct 9, 2023
3fe8966
bump migration number:
Emyrk Oct 10, 2023
44bbbfe
Swagger annotations
Emyrk Oct 10, 2023
f0294c3
Merge remote-tracking branch 'origin/main' into stevenmasley/soft_del…
Emyrk Oct 10, 2023
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
Prev Previous commit
Next Next commit
Linting and gen
  • Loading branch information
Emyrk committed Oct 9, 2023
commit 1606b999b27baa48010c3dd96094c9bcfffdb45f
2 changes: 2 additions & 0 deletions cli/templateversionarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import (
func (r *RootCmd) unarchiveTemplateVersion() *clibase.Cmd {
return r.setArchiveTemplateVersion(false)
}

func (r *RootCmd) archiveTemplateVersion() *clibase.Cmd {
return r.setArchiveTemplateVersion(true)
}

//nolint:revive
func (r *RootCmd) setArchiveTemplateVersion(archive bool) *clibase.Cmd {
presentVerb := "archive"
pastVerb := "archived"
Expand Down
24 changes: 11 additions & 13 deletions cli/testdata/coder_templates_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ USAGE:
$ coder templates push my-template

SUBCOMMANDS:
archive-template Archive unused failed template versions from a given
template(s)
archive-version Archive or unarchive a template version(s).
create Create a template from the current directory or as
specified by flag
delete Delete templates
edit Edit the metadata of a template by name.
init Get started with a templated template.
list List all the templates available for the organization
pull Download the latest version of a template to a path.
push Push a new template version from the current directory
or as specified by flag
versions Manage different versions of the specified template
archive Archive unused failed template versions from a given template(s)
create Create a template from the current directory or as specified by
flag
delete Delete templates
edit Edit the metadata of a template by name.
init Get started with a templated template.
list List all the templates available for the organization
pull Download the latest version of a template to a path.
push Push a new template version from the current directory or as
specified by flag
versions Manage different versions of the specified template

———
Run `coder --help` for a list of global options.
2 changes: 1 addition & 1 deletion cli/testdata/coder_templates_archive_--help.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
coder v0.0.0-devel

USAGE:
coder templates archive [flags] [name...]
coder templates archive [flags] [template-name...]

Archive unused failed template versions from a given template(s)

Expand Down
4 changes: 3 additions & 1 deletion cli/testdata/coder_templates_versions_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ USAGE:
$ coder templates versions list my-template

SUBCOMMANDS:
list List all the versions of the specified template
archive Archive a template version(s).
list List all the versions of the specified template
unarchive Unarchive a template version(s).

———
Run `coder --help` for a list of global options.
14 changes: 14 additions & 0 deletions cli/testdata/coder_templates_versions_archive_--help.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
coder v0.0.0-devel

USAGE:
coder templates versions archive [flags] <template-name>
[template-version-names...]

Archive a template version(s).

OPTIONS:
-y, --yes bool
Bypass prompts.

———
Run `coder --help` for a list of global options.
7 changes: 5 additions & 2 deletions cli/testdata/coder_templates_versions_list_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ USAGE:
List all the versions of the specified template

OPTIONS:
-c, --column string-array (default: name,created at,created by,status,active)
-c, --column string-array (default: name,created at,created by,status,active,archived)
Columns to display in table output. Available columns: name, created
at, created by, status, active.
at, created by, status, active, archived.

--include-archived bool
Include archived versions in the result list.

-o, --output string (default: table)
Output format. Available formats: table, json.
Expand Down
14 changes: 14 additions & 0 deletions cli/testdata/coder_templates_versions_unarchive_--help.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
coder v0.0.0-devel

USAGE:
coder templates versions unarchive [flags] <template-name>
[template-version-names...]

Unarchive a template version(s).

OPTIONS:
-y, --yes bool
Bypass prompts.

———
Run `coder --help` for a list of global options.
70 changes: 70 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -5339,7 +5339,7 @@ func (*FakeQuerier) TryAcquireLock(_ context.Context, _ int64) (bool, error) {
return false, xerrors.New("TryAcquireLock must only be called within a transaction")
}

func (q *FakeQuerier) UnarchiveTemplateVersion(ctx context.Context, arg database.UnarchiveTemplateVersionParams) error {
func (q *FakeQuerier) UnarchiveTemplateVersion(_ context.Context, arg database.UnarchiveTemplateVersionParams) error {
err := validateDatabaseType(arg)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,8 @@ func (api *API) postArchiveTemplateVersions(rw http.ResponseWriter, r *http.Requ
UpdatedAt: dbtime.Now(),
TemplateID: template.ID,
JobStatus: status,
// Archive all versions that match
TemplateVersionID: uuid.Nil,
})

if httpapi.Is404Error(err) {
Expand Down Expand Up @@ -1100,6 +1102,7 @@ func (api *API) postUnarchiveTemplateVersion() func(rw http.ResponseWriter, r *h
return api.setArchiveTemplateVersion(false)
}

//nolint:revive
func (api *API) setArchiveTemplateVersion(archive bool) func(rw http.ResponseWriter, r *http.Request) {
return func(rw http.ResponseWriter, r *http.Request) {
var (
Expand Down
1 change: 1 addition & 0 deletions codersdk/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func (c *Client) ArchiveTemplateVersions(ctx context.Context, template uuid.UUID
return resp, json.NewDecoder(res.Body).Decode(&resp)
}

//nolint:revive
func (c *Client) SetArchiveTemplateVersion(ctx context.Context, templateVersion uuid.UUID, archive bool) error {
u := fmt.Sprintf("/api/v2/templateversions/%s", templateVersion.String())
if archive {
Expand Down
62 changes: 62 additions & 0 deletions docs/api/templates.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/cli/templates_archive.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading