Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0cc46c8
fix: make template push a superset of template create
f0ssel Dec 20, 2023
93da7d0
add back work dir
f0ssel Dec 20, 2023
3c409f6
add groupacl
f0ssel Dec 20, 2023
4b763d7
Add back workdir
f0ssel Dec 20, 2023
d178cc7
combine edit flags
f0ssel Dec 20, 2023
5474942
fix edit
f0ssel Dec 20, 2023
2b9bcf6
unify edit and push
f0ssel Dec 20, 2023
44f264b
make gen
f0ssel Dec 20, 2023
d58cf18
fix test
f0ssel Dec 21, 2023
9b32922
make gen
f0ssel Dec 21, 2023
c6ef6f4
update golden
f0ssel Dec 21, 2023
e1e1653
fix tests:
f0ssel Dec 21, 2023
0cdefbc
fix merge
f0ssel Dec 21, 2023
d2a7866
add test
f0ssel Dec 22, 2023
63d57fd
remove test
f0ssel Dec 22, 2023
ca65869
add unset test
f0ssel Dec 22, 2023
9866235
Add deprecation warning
f0ssel Dec 22, 2023
35c7adf
fix
f0ssel Dec 22, 2023
4abf179
rename functions
f0ssel Jan 2, 2024
a3fdb76
test removing flags
f0ssel Jan 3, 2024
7599090
revert
f0ssel Jan 3, 2024
e958e1a
cleanup
f0ssel Jan 3, 2024
c8cae6c
add back flag
f0ssel Jan 3, 2024
1b03e89
remove create command
f0ssel Jan 4, 2024
8918cda
make gen
f0ssel Jan 4, 2024
7d2a7ac
fix gen
f0ssel Jan 4, 2024
5b2792d
add private flag to template edit
f0ssel Jan 4, 2024
b85a73c
fix test
f0ssel Jan 4, 2024
7655bc9
fix golden
f0ssel Jan 4, 2024
2f2911a
update mentions of templates create command
f0ssel Jan 4, 2024
5334e8e
update golden
f0ssel Jan 4, 2024
79c0c02
add removal comment
f0ssel Jan 4, 2024
2dfb98e
Add back create
f0ssel Jan 4, 2024
cb0aec4
fix formatting
f0ssel Jan 4, 2024
d1f13d1
add disableeveryonegroupaccess test
f0ssel Jan 4, 2024
5792279
update test
f0ssel Jan 5, 2024
2e54259
fix test lint
f0ssel Jan 5, 2024
de78f4b
pr comments
f0ssel Jan 5, 2024
0c859bc
fix text formatting
f0ssel Jan 5, 2024
b65ab81
Add deprecation to help text
f0ssel Jan 5, 2024
77c9edf
fix template push wording
f0ssel Jan 5, 2024
13794fd
golden
f0ssel Jan 5, 2024
8355850
fix gen again
f0ssel Jan 5, 2024
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
fix merge
  • Loading branch information
f0ssel committed Jan 5, 2024
commit 0cdefbc6c1f9b1a0bb3b14f86c7c50b3f73ab366
49 changes: 0 additions & 49 deletions cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,46 +47,7 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
r.InitClient(client),
),
Handler: func(inv *clibase.Invocation) error {
<<<<<<< HEAD
<<<<<<< HEAD
isTemplateSchedulingOptionsSet := failureTTL != 0 || dormancyThreshold != 0 || dormancyAutoDeletion != 0 || maxTTL != 0

if isTemplateSchedulingOptionsSet || requireActiveVersion {
if failureTTL != 0 || dormancyThreshold != 0 || dormancyAutoDeletion != 0 {
// This call can be removed when workspace_actions is no longer experimental
experiments, exErr := client.Experiments(inv.Context())
if exErr != nil {
return xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentWorkspaceActions) {
return xerrors.Errorf("--failure-ttl, --dormancy-threshold, and --dormancy-auto-deletion are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
}
}

entitlements, err := client.Entitlements(inv.Context())
if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() == http.StatusNotFound {
return xerrors.Errorf("your deployment appears to be an AGPL deployment, so you cannot set enterprise-only flags")
} else if err != nil {
return xerrors.Errorf("get entitlements: %w", err)
}

if isTemplateSchedulingOptionsSet {
if !entitlements.Features[codersdk.FeatureAdvancedTemplateScheduling].Enabled {
return xerrors.Errorf("your license is not entitled to use advanced template scheduling, so you cannot set --failure-ttl, --inactivity-ttl, or --max-ttl")
}
}

if requireActiveVersion {
if !entitlements.Features[codersdk.FeatureAccessControl].Enabled {
return xerrors.Errorf("your license is not entitled to use enterprise access control, so you cannot set --require-active-version")
}
}
=======
err := handleEntitlements(inv.Context(), handleEntitlementsArgs{
=======
err := createEntitlementsCheck(inv.Context(), handleEntitlementsArgs{
>>>>>>> 3c377e5d3 (combine edit flags)
client: client,
requireActiveVersion: requireActiveVersion,
defaultTTL: defaultTTL,
Expand All @@ -97,7 +58,6 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
})
if err != nil {
return err
>>>>>>> 7b0afe8e9 (fix: make template push a superset of template create)
}

organization, err := CurrentOrganization(inv, client)
Expand Down Expand Up @@ -420,15 +380,6 @@ func createEntitlementsCheck(ctx context.Context, args handleEntitlementsArgs) e
if !entitlements.Features[codersdk.FeatureAccessControl].Enabled {
return xerrors.Errorf("your license is not entitled to use enterprise access control, so you cannot set --require-active-version")
}

experiments, exErr := args.client.Experiments(ctx)
if exErr != nil {
return xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentTemplateUpdatePolicies) {
return xerrors.Errorf("--require-active-version is an experimental feature, contact an administrator to enable the 'template_update_policies' experiment on your Coder server")
}
}
}

Expand Down
55 changes: 0 additions & 55 deletions cli/templateedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,52 +47,6 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
),
Short: "Edit the metadata of a template by name.",
Handler: func(inv *clibase.Invocation) error {
<<<<<<< HEAD
// This clause can be removed when workspace_actions is no longer experimental
if failureTTL != 0 || dormancyThreshold != 0 || dormancyAutoDeletion != 0 {
experiments, exErr := client.Experiments(inv.Context())
if exErr != nil {
return xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentWorkspaceActions) {
return xerrors.Errorf("--failure-ttl, --dormancy-threshold, and --dormancy-auto-deletion are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
}
}

unsetAutostopRequirementDaysOfWeek := len(autostopRequirementDaysOfWeek) == 1 && autostopRequirementDaysOfWeek[0] == "none"
requiresScheduling := (len(autostopRequirementDaysOfWeek) > 0 && !unsetAutostopRequirementDaysOfWeek) ||
autostopRequirementWeeks > 0 ||
!allowUserAutostart ||
!allowUserAutostop ||
maxTTL != 0 ||
failureTTL != 0 ||
dormancyThreshold != 0 ||
dormancyAutoDeletion != 0 ||
len(autostartRequirementDaysOfWeek) > 0

requiresEntitlement := requiresScheduling || requireActiveVersion
if requiresEntitlement {
entitlements, err := client.Entitlements(inv.Context())
if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() == http.StatusNotFound {
return xerrors.Errorf("your deployment appears to be an AGPL deployment, so you cannot set enterprise-only flags")
} else if err != nil {
return xerrors.Errorf("get entitlements: %w", err)
}

if requiresScheduling && !entitlements.Features[codersdk.FeatureAdvancedTemplateScheduling].Enabled {
return xerrors.Errorf("your license is not entitled to use advanced template scheduling, so you cannot set --max-ttl, --failure-ttl, --inactivityTTL, --allow-user-autostart=false or --allow-user-autostop=false")
}

if requireActiveVersion {
if !entitlements.Features[codersdk.FeatureAccessControl].Enabled {
return xerrors.Errorf("your license is not entitled to use enterprise access control, so you cannot set --require-active-version")
}
}
}

=======
>>>>>>> 3c377e5d3 (combine edit flags)
organization, err := CurrentOrganization(inv, client)
if err != nil {
return xerrors.Errorf("get current organization: %w", err)
Expand Down Expand Up @@ -341,15 +295,6 @@ func editTemplateEntitlementsCheck(ctx context.Context, args editTemplateEntitle
if !entitlements.Features[codersdk.FeatureAccessControl].Enabled {
return false, xerrors.Errorf("your license is not entitled to use enterprise access control, so you cannot set --require-active-version")
}

experiments, exErr := args.client.Experiments(ctx)
if exErr != nil {
return false, xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentTemplateUpdatePolicies) {
return false, xerrors.Errorf("--require-active-version is an experimental feature, contact an administrator to enable the 'template_update_policies' experiment on your Coder server")
}
}
}

Expand Down