Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3ca39f

Browse files
committed
Merge branch 'main' into exportstats
2 parents 1af9f64 + 4c204fc commit e3ca39f

File tree

106 files changed

+2956
-851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2956
-851
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ jobs:
186186

187187
- name: Install Protoc
188188
run: |
189-
# protoc must be in lockstep with our dogfood Dockerfile
190-
# or the version in the comments will differ.
189+
# protoc must be in lockstep with our dogfood Dockerfile or the
190+
# version in the comments will differ. This is also defined in
191+
# security.yaml
191192
set -x
192193
cd dogfood
193194
DOCKER_BUILDKIT=1 docker build . --target proto -t protoc

.github/workflows/contrib.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@ jobs:
2727
steps:
2828
- uses: hmarr/auto-approve-action@v3
2929
if: github.actor == 'dependabot[bot]'
30-
auto-approve-docs:
31-
runs-on: ubuntu-latest
32-
if: github.event_name == 'pull_request_target'
33-
permissions:
34-
pull-requests: write
35-
steps:
36-
- uses: actions/checkout@v3
37-
- name: Get changed files in the docs folder
38-
id: changed-files
39-
uses: tj-actions/changed-files@v35
40-
with:
41-
files: docs/*
42-
- uses: hmarr/auto-approve-action@v3
43-
if: github.actor == 'bpmct' && steps.changed-files.outputs.only_changed == 'true'
4430

4531
cla:
4632
runs-on: ubuntu-latest

.github/workflows/security.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ jobs:
9999
100100
- name: Install yq
101101
run: go run github.com/mikefarah/yq/[email protected]
102+
- name: Install protoc-gen-go
103+
run: go install google.golang.org/protobuf/cmd/[email protected]
104+
- name: Install protoc-gen-go-drpc
105+
run: go install storj.io/drpc/cmd/[email protected]
106+
- name: Install Protoc
107+
run: |
108+
# protoc must be in lockstep with our dogfood Dockerfile or the
109+
# version in the comments will differ. This is also defined in
110+
# ci.yaml.
111+
set -x
112+
cd dogfood
113+
DOCKER_BUILDKIT=1 docker build . --target proto -t protoc
114+
protoc_path=/usr/local/bin/protoc
115+
docker run --rm --entrypoint cat protoc /tmp/bin/protoc > $protoc_path
116+
chmod +x $protoc_path
117+
protoc --version
102118
103119
- name: Build Coder linux amd64 Docker image
104120
id: build

cli/cliui/parameter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func RichParameter(cmd *cobra.Command, templateVersionParameter codersdk.Templat
8585
}
8686
} else {
8787
text := "Enter a value"
88-
if templateVersionParameter.DefaultValue != "" {
88+
if !templateVersionParameter.Required {
8989
text += fmt.Sprintf(" (default: %q)", templateVersionParameter.DefaultValue)
9090
}
9191
text += ":"
@@ -111,7 +111,7 @@ func RichParameter(cmd *cobra.Command, templateVersionParameter codersdk.Templat
111111
}
112112

113113
func validateRichPrompt(value string, p codersdk.TemplateVersionParameter) error {
114-
return codersdk.ValidateWorkspaceBuildParameter(p, codersdk.WorkspaceBuildParameter{
114+
return codersdk.ValidateWorkspaceBuildParameter(p, &codersdk.WorkspaceBuildParameter{
115115
Name: p.Name,
116116
Value: value,
117117
}, nil)

cli/deployment/config.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,11 @@ func newConfig() *codersdk.DeploymentConfig {
499499
Default: flag.Lookup("test.v") == nil && !buildinfo.IsDev(),
500500
},
501501
MaxTokenLifetime: &codersdk.DeploymentConfigField[time.Duration]{
502-
Name: "Max Token Lifetime",
503-
Usage: "The maximum lifetime duration users can specify when creating an API token.",
504-
Flag: "max-token-lifetime",
505-
Default: 24 * 30 * time.Hour,
502+
Name: "Max Token Lifetime",
503+
Usage: "The maximum lifetime duration users can specify when creating an API token.",
504+
Flag: "max-token-lifetime",
505+
// max time.Duration is 290 years
506+
Default: 290 * 365 * 24 * time.Hour,
506507
},
507508
Swagger: &codersdk.SwaggerConfig{
508509
Enable: &codersdk.DeploymentConfigField[bool]{

cli/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/spf13/cobra"
99

1010
"github.com/coder/coder/cli/cliui"
11-
"github.com/coder/coder/coderd/autobuild/schedule"
11+
"github.com/coder/coder/coderd/schedule"
1212
"github.com/coder/coder/coderd/util/ptr"
1313
"github.com/coder/coder/codersdk"
1414
)

cli/schedule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"golang.org/x/xerrors"
1111

1212
"github.com/coder/coder/cli/cliui"
13-
"github.com/coder/coder/coderd/autobuild/schedule"
13+
"github.com/coder/coder/coderd/schedule"
1414
"github.com/coder/coder/coderd/util/ptr"
1515
"github.com/coder/coder/coderd/util/tz"
1616
"github.com/coder/coder/codersdk"

cli/schedule_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,16 @@ func TestScheduleOverride(t *testing.T) {
308308
user = coderdtest.CreateFirstUser(t, client)
309309
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
310310
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
311-
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
312-
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID, func(cwr *codersdk.CreateWorkspaceRequest) {
311+
template = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
312+
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID, func(cwr *codersdk.CreateWorkspaceRequest) {
313313
cwr.TTLMillis = nil
314314
})
315315
cmdArgs = []string{"schedule", "override-stop", workspace.Name, "1h"}
316316
stdoutBuf = &bytes.Buffer{}
317317
)
318+
require.Zero(t, template.DefaultTTLMillis)
319+
require.Zero(t, template.MaxTTLMillis)
320+
318321
// Unset the workspace TTL
319322
err = client.UpdateWorkspaceTTL(ctx, workspace.ID, codersdk.UpdateWorkspaceTTLRequest{TTLMillis: nil})
320323
require.NoError(t, err)

cli/templateedit.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"fmt"
5+
"net/http"
56
"time"
67

78
"github.com/spf13/cobra"
@@ -18,6 +19,7 @@ func templateEdit() *cobra.Command {
1819
description string
1920
icon string
2021
defaultTTL time.Duration
22+
maxTTL time.Duration
2123
allowUserCancelWorkspaceJobs bool
2224
)
2325

@@ -30,6 +32,21 @@ func templateEdit() *cobra.Command {
3032
if err != nil {
3133
return xerrors.Errorf("create client: %w", err)
3234
}
35+
36+
if maxTTL != 0 {
37+
entitlements, err := client.Entitlements(cmd.Context())
38+
var sdkErr *codersdk.Error
39+
if xerrors.As(err, &sdkErr) && sdkErr.StatusCode() == http.StatusNotFound {
40+
return xerrors.Errorf("your deployment appears to be an AGPL deployment, so you cannot set --max-ttl")
41+
} else if err != nil {
42+
return xerrors.Errorf("get entitlements: %w", err)
43+
}
44+
45+
if !entitlements.Features[codersdk.FeatureAdvancedTemplateScheduling].Enabled {
46+
return xerrors.Errorf("your license is not entitled to use advanced template scheduling, so you cannot set --max-ttl")
47+
}
48+
}
49+
3350
organization, err := CurrentOrganization(cmd, client)
3451
if err != nil {
3552
return xerrors.Errorf("get current organization: %w", err)
@@ -46,6 +63,7 @@ func templateEdit() *cobra.Command {
4663
Description: description,
4764
Icon: icon,
4865
DefaultTTLMillis: defaultTTL.Milliseconds(),
66+
MaxTTLMillis: maxTTL.Milliseconds(),
4967
AllowUserCancelWorkspaceJobs: allowUserCancelWorkspaceJobs,
5068
}
5169

@@ -58,11 +76,12 @@ func templateEdit() *cobra.Command {
5876
},
5977
}
6078

61-
cmd.Flags().StringVarP(&name, "name", "", "", "Edit the template name")
62-
cmd.Flags().StringVarP(&displayName, "display-name", "", "", "Edit the template display name")
63-
cmd.Flags().StringVarP(&description, "description", "", "", "Edit the template description")
64-
cmd.Flags().StringVarP(&icon, "icon", "", "", "Edit the template icon path")
65-
cmd.Flags().DurationVarP(&defaultTTL, "default-ttl", "", 0, "Edit the template default time before shutdown - workspaces created from this template to this value.")
79+
cmd.Flags().StringVarP(&name, "name", "", "", "Edit the template name.")
80+
cmd.Flags().StringVarP(&displayName, "display-name", "", "", "Edit the template display name.")
81+
cmd.Flags().StringVarP(&description, "description", "", "", "Edit the template description.")
82+
cmd.Flags().StringVarP(&icon, "icon", "", "", "Edit the template icon path.")
83+
cmd.Flags().DurationVarP(&defaultTTL, "default-ttl", "", 0, "Edit the template default time before shutdown - workspaces created from this template default to this value.")
84+
cmd.Flags().DurationVarP(&maxTTL, "max-ttl", "", 0, "Edit the template maximum time before shutdown - workspaces created from this template must shutdown within the given duration after starting. This is an enterprise-only feature.")
6685
cmd.Flags().BoolVarP(&allowUserCancelWorkspaceJobs, "allow-user-cancel-workspace-jobs", "", true, "Allow users to cancel in-progress workspace jobs.")
6786
cliui.AllowSkipPrompt(cmd)
6887

0 commit comments

Comments
 (0)