Skip to content

Commit 7599090

Browse files
committed
revert
1 parent a3fdb76 commit 7599090

File tree

11 files changed

+11
-255
lines changed

11 files changed

+11
-255
lines changed

cli/templatepush.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,6 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
277277

278278
_, _ = fmt.Fprintf(inv.Stdout, "Updated version at %s!\n", pretty.Sprint(cliui.DefaultStyles.DateTimeStamp, time.Now().Format(time.Stamp)))
279279

280-
// refresh template data for edit api call
281-
template, err = client.TemplateByName(inv.Context(), organization.ID, name)
282-
if err != nil {
283-
return err
284-
}
285-
286-
if err != nil {
287-
return err
288-
}
289-
_, _ = fmt.Fprintf(inv.Stdout, "Updated template metadata at %s!\n", pretty.Sprint(cliui.DefaultStyles.DateTimeStamp, time.Now().Format(time.Stamp)))
290-
291280
return nil
292281
},
293282
}

cli/templatepush_test.go

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import (
66
"os"
77
"path/filepath"
88
"runtime"
9-
"strconv"
109
"strings"
1110
"testing"
12-
"time"
1311

1412
"github.com/google/uuid"
1513
"github.com/stretchr/testify/assert"
@@ -710,153 +708,6 @@ func TestTemplatePush(t *testing.T) {
710708
require.NotEqual(t, uuid.Nil, template.ActiveVersionID)
711709
})
712710
})
713-
714-
t.Run("EditMetadata", func(t *testing.T) {
715-
t.Parallel()
716-
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
717-
owner := coderdtest.CreateFirstUser(t, client)
718-
templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin())
719-
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
720-
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
721-
722-
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
723-
724-
// Test the cli command.
725-
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
726-
Parse: echo.ParseComplete,
727-
ProvisionApply: echo.ApplyComplete,
728-
})
729-
730-
name := "new-template-name"
731-
displayName := "New Display Name 789"
732-
desc := "lorem ipsum dolor sit amet et cetera"
733-
icon := "/icon/new-icon.png"
734-
defaultTTL := 12 * time.Hour
735-
allowUserCancelWorkspaceJobs := false
736-
737-
inv, root := clitest.New(t,
738-
"templates",
739-
"push",
740-
template.Name,
741-
"--directory", source,
742-
"--test.provisioner", string(database.ProvisionerTypeEcho),
743-
"--name", name,
744-
"--display-name", displayName,
745-
"--description", desc,
746-
"--icon", icon,
747-
"--default-ttl", defaultTTL.String(),
748-
"--allow-user-cancel-workspace-jobs="+strconv.FormatBool(allowUserCancelWorkspaceJobs),
749-
)
750-
clitest.SetupConfig(t, templateAdmin, root)
751-
pty := ptytest.New(t).Attach(inv)
752-
753-
execDone := make(chan error)
754-
go func() {
755-
execDone <- inv.Run()
756-
}()
757-
758-
matches := []struct {
759-
match string
760-
write string
761-
}{
762-
{match: "Upload", write: "yes"},
763-
}
764-
for _, m := range matches {
765-
pty.ExpectMatch(m.match)
766-
pty.WriteLine(m.write)
767-
}
768-
769-
require.NoError(t, <-execDone)
770-
771-
// Assert that the template version changed.
772-
templateVersions, err := client.TemplateVersionsByTemplate(context.Background(), codersdk.TemplateVersionsByTemplateRequest{
773-
TemplateID: template.ID,
774-
})
775-
require.NoError(t, err)
776-
assert.Len(t, templateVersions, 2)
777-
assert.NotEqual(t, template.ActiveVersionID, templateVersions[1].ID)
778-
require.Equal(t, name, templateVersions[1].Name)
779-
780-
// Assert that the template metadata changed.
781-
updated, err := client.Template(context.Background(), template.ID)
782-
require.NoError(t, err)
783-
assert.Equal(t, template.Name, updated.Name)
784-
assert.Equal(t, displayName, updated.DisplayName)
785-
assert.Equal(t, desc, updated.Description)
786-
assert.Equal(t, icon, updated.Icon)
787-
assert.Equal(t, defaultTTL.Milliseconds(), updated.DefaultTTLMillis)
788-
assert.Equal(t, allowUserCancelWorkspaceJobs, updated.AllowUserCancelWorkspaceJobs)
789-
})
790-
791-
t.Run("EditMetadataKeepUnsetUnchanged", func(t *testing.T) {
792-
t.Parallel()
793-
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
794-
owner := coderdtest.CreateFirstUser(t, client)
795-
templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin())
796-
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
797-
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
798-
799-
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
800-
801-
// Test the cli command.
802-
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
803-
Parse: echo.ParseComplete,
804-
ProvisionApply: echo.ApplyComplete,
805-
})
806-
807-
desc := "lorem ipsum dolor sit amet et cetera"
808-
809-
inv, root := clitest.New(t,
810-
"templates",
811-
"push",
812-
template.Name,
813-
"--directory", source,
814-
"--test.provisioner", string(database.ProvisionerTypeEcho),
815-
"--description", desc,
816-
)
817-
clitest.SetupConfig(t, templateAdmin, root)
818-
pty := ptytest.New(t).Attach(inv)
819-
820-
execDone := make(chan error)
821-
go func() {
822-
execDone <- inv.Run()
823-
}()
824-
825-
matches := []struct {
826-
match string
827-
write string
828-
}{
829-
{match: "Upload", write: "yes"},
830-
}
831-
for _, m := range matches {
832-
pty.ExpectMatch(m.match)
833-
pty.WriteLine(m.write)
834-
}
835-
836-
require.NoError(t, <-execDone)
837-
838-
// Assert that the template version changed.
839-
templateVersions, err := client.TemplateVersionsByTemplate(context.Background(), codersdk.TemplateVersionsByTemplateRequest{
840-
TemplateID: template.ID,
841-
})
842-
require.NoError(t, err)
843-
assert.Len(t, templateVersions, 2)
844-
assert.NotEqual(t, template.ActiveVersionID, templateVersions[1].ID)
845-
846-
// Assert that the template metadata changed.
847-
updated, err := client.Template(context.Background(), template.ID)
848-
require.NoError(t, err)
849-
assert.Equal(t, template.Name, updated.Name)
850-
assert.Equal(t, template.DisplayName, updated.DisplayName)
851-
assert.Equal(t, desc, updated.Description)
852-
assert.Equal(t, template.Icon, updated.Icon)
853-
assert.Equal(t, template.DefaultTTLMillis, updated.DefaultTTLMillis)
854-
assert.Equal(t, template.FailureTTLMillis, updated.FailureTTLMillis)
855-
assert.Equal(t, template.TimeTilDormantAutoDeleteMillis, updated.TimeTilDormantAutoDeleteMillis)
856-
assert.Equal(t, template.AutostartRequirement.DaysOfWeek, updated.AutostartRequirement.DaysOfWeek)
857-
assert.Equal(t, template.AutostopRequirement.DaysOfWeek, updated.AutostopRequirement.DaysOfWeek)
858-
assert.Equal(t, template.RequireActiveVersion, updated.RequireActiveVersion)
859-
})
860711
}
861712

862713
func createEchoResponsesWithTemplateVariables(templateVariables []*proto.TemplateVariable) *echo.Responses {

cli/testdata/coder_templates_push_--help.golden

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,23 @@ USAGE:
66
Push a new template version from the current directory or as specified by flag
77

88
OPTIONS:
9-
--deprecated string
10-
Sets the template as deprecated. Must be a message explaining why the
11-
template is deprecated.
12-
139
--activate bool (default: true)
1410
Whether the new template will be marked active.
1511

16-
--allow-user-autostart bool (default: true)
17-
Allow users to configure autostart for workspaces on this template.
18-
This can only be disabled in enterprise.
19-
20-
--allow-user-autostop bool (default: true)
21-
Allow users to customize the autostop TTL for workspaces on this
22-
template. This can only be disabled in enterprise.
23-
24-
--allow-user-cancel-workspace-jobs bool (default: true)
25-
Allow users to cancel in-progress workspace jobs.
26-
2712
--always-prompt bool
2813
Always prompt all parameters. Does not pull parameter values from
2914
active template version.
3015

31-
--autostart-requirement-weekdays string-array
32-
Edit the template autostart requirement weekdays - workspaces created
33-
from this template can only autostart on the given weekdays. To unset
34-
this value for the template (and allow autostart on all days), pass
35-
'all'.
36-
37-
--default-ttl duration (default: 24h)
38-
Specify a default TTL for workspaces created from this template. It is
39-
the default time before shutdown - workspaces created from this
40-
template default to this value. Maps to "Default autostop" in the UI.
41-
42-
--description string
43-
Edit the template description.
16+
--create bool (default: false)
17+
Create the template if it does not exist.
4418

4519
-d, --directory string (default: .)
4620
Specify the directory to create from, use '-' to read tar from stdin.
4721

48-
--display-name string
49-
Edit the template display name.
50-
51-
--dormancy-auto-deletion duration (default: 0h)
52-
Specify a duration workspaces may be in the dormant state prior to
53-
being deleted. This licensed feature's default is 0h (off). Maps to
54-
"Dormancy Auto-Deletion" in the UI.
55-
56-
--dormancy-threshold duration (default: 0h)
57-
Specify a duration workspaces may be inactive prior to being moved to
58-
the dormant state. This licensed feature's default is 0h (off). Maps
59-
to "Dormancy threshold" in the UI.
60-
61-
--failure-ttl duration (default: 0h)
62-
Specify a failure TTL for workspaces created from this template. It is
63-
the amount of time after a failed "start" build before coder
64-
automatically schedules a "stop" build to cleanup.This licensed
65-
feature's default is 0h (off). Maps to "Failure cleanup"in the UI.
66-
67-
--icon string
68-
Edit the template icon path.
69-
7022
--ignore-lockfile bool (default: false)
7123
Ignore warnings about not having a .terraform.lock.hcl file present in
7224
the template.
7325

74-
--max-ttl duration
75-
Edit the template maximum time before shutdown - workspaces created
76-
from this template must shutdown within the given duration after
77-
starting. This is an enterprise-only feature.
78-
7926
-m, --message string
8027
Specify a message describing the changes in this version of the
8128
template. Messages longer than 72 characters will be displayed as
@@ -85,19 +32,9 @@ OPTIONS:
8532
Specify a name for the new template version. It will be automatically
8633
generated if not provided.
8734

88-
--private bool
89-
Disable the default behavior of granting template access to the
90-
'everyone' group. The template permissions must be updated to allow
91-
non-admin users to use this template.
92-
9335
--provisioner-tag string-array
9436
Specify a set of tags to target provisioner daemons.
9537

96-
--require-active-version bool (default: false)
97-
Requires workspace builds to use the active template version. This
98-
setting does not apply to template admins. This is an enterprise-only
99-
feature.
100-
10138
--var string-array
10239
Alias of --variable.
10340

coderd/database/queries.sql.go

Lines changed: 8 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/templates.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ SET
115115
name = $4,
116116
icon = $5,
117117
display_name = $6,
118-
allow_user_cancel_workspace_jobs = $7,
119-
group_acl = $8
118+
allow_user_cancel_workspace_jobs = $7
120119
WHERE
121120
id = $1
122121
;

coderd/templates.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,6 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
667667
name = template.Name
668668
}
669669

670-
groupACL := template.GroupACL
671-
if req.DisableEveryoneGroupAccess {
672-
groupACL = database.TemplateACL{}
673-
}
674-
675670
var err error
676671
err = tx.UpdateTemplateMetaByID(ctx, database.UpdateTemplateMetaByIDParams{
677672
ID: template.ID,
@@ -681,7 +676,6 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
681676
Description: req.Description,
682677
Icon: req.Icon,
683678
AllowUserCancelWorkspaceJobs: req.AllowUserCancelWorkspaceJobs,
684-
GroupACL: groupACL,
685679
})
686680
if err != nil {
687681
return xerrors.Errorf("update template metadata: %w", err)

codersdk/templates.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,6 @@ type UpdateTemplateMeta struct {
241241
// If passed an empty string, will remove the deprecated message, making
242242
// the template usable for new workspaces again.
243243
DeprecationMessage *string `json:"deprecation_message"`
244-
// DisableEveryoneGroupAccess allows optionally disabling the default
245-
// behavior of granting the 'everyone' group access to use the template.
246-
// If this is set to true, the template will not be available to all users,
247-
// and must be explicitly granted to users or groups in the permissions settings
248-
// of the template.
249-
DisableEveryoneGroupAccess bool `json:"disable_everyone_group_access"`
250244
}
251245

252246
type TemplateExample struct {

site/src/pages/TemplateSettingsPage/TemplateGeneralSettingsPage/TemplateSettingsForm.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
7777
update_workspace_dormant_at: false,
7878
require_active_version: template.require_active_version,
7979
deprecation_message: template.deprecation_message,
80-
disable_everyone_group_access: false,
8180
},
8281
validationSchema,
8382
onSubmit,

site/src/pages/TemplateSettingsPage/TemplateGeneralSettingsPage/TemplateSettingsPage.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const validFormValues: FormValues = {
4747
update_workspace_last_used_at: false,
4848
update_workspace_dormant_at: false,
4949
require_active_version: false,
50-
disable_everyone_group_access: false,
5150
};
5251

5352
const renderTemplateSettingsPage = async () => {

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateScheduleForm.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
118118
update_workspace_last_used_at: false,
119119
update_workspace_dormant_at: false,
120120
require_active_version: false,
121-
disable_everyone_group_access: false,
122121
},
123122
validationSchema,
124123
onSubmit: () => {
@@ -239,7 +238,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
239238
update_workspace_last_used_at: form.values.update_workspace_last_used_at,
240239
update_workspace_dormant_at: form.values.update_workspace_dormant_at,
241240
require_active_version: false,
242-
disable_everyone_group_access: false,
243241
});
244242
};
245243

0 commit comments

Comments
 (0)