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

Skip to content

Commit 9feedc6

Browse files
committed
Merge branch 'main' into docs-reorganize
2 parents 6985d21 + f6c89a2 commit 9feedc6

File tree

149 files changed

+2810
-2309
lines changed

Some content is hidden

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

149 files changed

+2810
-2309
lines changed

.github/workflows/cron-weekly.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Markdown Links Check
1+
name: Weekly Cron
22
# runs every monday at 9 am
33
on:
44
schedule:
@@ -19,12 +19,13 @@ jobs:
1919
with:
2020
use-quiet-mode: "yes"
2121
use-verbose-mode: "yes"
22-
config-file: ".github/workflows/markdown.links.config.json"
22+
config-file: ".github/workflows/mlc_config.json"
2323
folder-path: "docs/"
2424

2525
- name: Send Slack notification
26+
if: failure()
2627
run: |
2728
curl -X POST -H 'Content-type: application/json' -d '{"msg":"Broken links found in the documentation. Please check the logs at ${{ env.LOGS_URL }}"}' ${{ secrets.DOCS_LINK_SLACK_WEBHOOK }}
2829
echo "Sent Slack notification"
2930
env:
30-
LOGS_URL: ${{ https://github.com/coder/coder/actions/runs/${{ github.run_id }}
31+
LOGS_URL: https://github.com/coder/coder/actions/runs/${{ github.run_id }}

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ gen: \
423423
provisionersdk/proto/provisioner.pb.go \
424424
provisionerd/proto/provisionerd.pb.go \
425425
site/src/api/typesGenerated.ts \
426+
coderd/rbac/object_gen.go \
426427
docs/admin/prometheus.md \
427428
docs/cli.md \
428429
docs/admin/audit-logs.md \
@@ -443,6 +444,7 @@ gen/mark-fresh:
443444
provisionersdk/proto/provisioner.pb.go \
444445
provisionerd/proto/provisionerd.pb.go \
445446
site/src/api/typesGenerated.ts \
447+
coderd/rbac/object_gen.go \
446448
docs/admin/prometheus.md \
447449
docs/cli.md \
448450
docs/admin/audit-logs.md \
@@ -495,6 +497,9 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./coders
495497
cd site
496498
yarn run format:types
497499

500+
coderd/rbac/object_gen.go: scripts/rbacgen/main.go coderd/rbac/object.go
501+
go run scripts/rbacgen/main.go ./coderd/rbac > coderd/rbac/object_gen.go
502+
498503
docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
499504
go run scripts/metricsdocgen/main.go
500505
cd site
@@ -505,12 +510,12 @@ docs/cli.md: scripts/clidocgen/main.go $(GO_SRC_FILES) docs/manifest.json
505510
cd site
506511
yarn run format:write:only ../docs/cli.md ../docs/cli/*.md ../docs/manifest.json
507512

508-
docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go
513+
docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go
509514
go run scripts/auditdocgen/main.go
510515
cd site
511516
yarn run format:write:only ../docs/admin/audit-logs.md
512517

513-
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) .swaggo docs/manifest.json
518+
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) .swaggo docs/manifest.json coderd/rbac/object_gen.go
514519
./scripts/apidocgen/generate.sh
515520
yarn run --cwd=site format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
516521

cli/scaletest.go

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func (r *RootCmd) scaletestCleanup() *clibase.Cmd {
471471
}
472472

473473
cliui.Errorf(inv.Stderr, "Found %d scaletest users\n", len(users))
474-
if len(workspaces) != 0 {
474+
if len(users) != 0 {
475475
cliui.Infof(inv.Stdout, "Deleting scaletest users..."+"\n")
476476
harness := harness.NewTestHarness(cleanupStrategy.toStrategy(), harness.ConcurrentExecutionStrategy{})
477477

@@ -535,6 +535,8 @@ func (r *RootCmd) scaletestCreateWorkspaces() *clibase.Cmd {
535535
connectInterval time.Duration
536536
connectTimeout time.Duration
537537

538+
useHostUser bool
539+
538540
tracingFlags = &scaletestTracingFlags{}
539541
strategy = &scaletestStrategyFlags{}
540542
cleanupStrategy = &scaletestStrategyFlags{cleanup: true}
@@ -693,35 +695,37 @@ func (r *RootCmd) scaletestCreateWorkspaces() *clibase.Cmd {
693695
const name = "workspacebuild"
694696
id := strconv.Itoa(i)
695697

696-
username, email, err := newScaleTestUser(id)
697-
if err != nil {
698-
return xerrors.Errorf("create scaletest username and email: %w", err)
699-
}
700-
workspaceName, err := newScaleTestWorkspace(id)
701-
if err != nil {
702-
return xerrors.Errorf("create scaletest workspace name: %w", err)
703-
}
704-
705698
config := createworkspaces.Config{
706699
User: createworkspaces.UserConfig{
707700
// TODO: configurable org
708701
OrganizationID: me.OrganizationIDs[0],
709-
Username: username,
710-
Email: email,
711702
},
712703
Workspace: workspacebuild.Config{
713704
OrganizationID: me.OrganizationIDs[0],
714705
// UserID is set by the test automatically.
715706
Request: codersdk.CreateWorkspaceRequest{
716707
TemplateID: tpl.ID,
717-
Name: workspaceName,
718708
ParameterValues: params,
719709
},
720710
NoWaitForAgents: noWaitForAgents,
721711
},
722712
NoCleanup: noCleanup,
723713
}
724714

715+
if useHostUser {
716+
config.User.SessionToken = client.SessionToken()
717+
} else {
718+
config.User.Username, config.User.Email, err = newScaleTestUser(id)
719+
if err != nil {
720+
return xerrors.Errorf("create scaletest username and email: %w", err)
721+
}
722+
}
723+
724+
config.Workspace.Request.Name, err = newScaleTestWorkspace(id)
725+
if err != nil {
726+
return xerrors.Errorf("create scaletest workspace name: %w", err)
727+
}
728+
725729
if runCommand != "" {
726730
config.ReconnectingPTY = &reconnectingpty.Config{
727731
// AgentID is set by the test automatically.
@@ -927,6 +931,13 @@ func (r *RootCmd) scaletestCreateWorkspaces() *clibase.Cmd {
927931
Description: "Timeout for each request to the --connect-url.",
928932
Value: clibase.DurationOf(&connectTimeout),
929933
},
934+
{
935+
Flag: "use-host-login",
936+
Env: "CODER_SCALETEST_USE_HOST_LOGIN",
937+
Default: "false",
938+
Description: "Use the use logged in on the host machine, instead of creating users.",
939+
Value: clibase.BoolOf(&useHostUser),
940+
},
930941
}
931942

932943
tracingFlags.attach(&cmd.Options)
@@ -1009,9 +1020,6 @@ func isScaleTestUser(user codersdk.User) bool {
10091020
}
10101021

10111022
func isScaleTestWorkspace(workspace codersdk.Workspace) bool {
1012-
if !strings.HasPrefix(workspace.OwnerName, "scaletest-") {
1013-
return false
1014-
}
1015-
1016-
return strings.HasPrefix(workspace.Name, "scaletest-")
1023+
return strings.HasPrefix(workspace.OwnerName, "scaletest-") ||
1024+
strings.HasPrefix(workspace.Name, "scaletest-")
10171025
}

cli/server.go

Lines changed: 74 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func ReadGitAuthProvidersFromEnv(environ []string) ([]codersdk.GitAuthConfig, er
145145
case "REGEX":
146146
provider.Regex = v.Value
147147
case "NO_REFRESH":
148-
b, err := strconv.ParseBool(key)
148+
b, err := strconv.ParseBool(v.Value)
149149
if err != nil {
150150
return nil, xerrors.Errorf("parse bool: %s", v.Value)
151151
}
@@ -165,62 +165,24 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
165165
opts = cfg.Options()
166166
)
167167
serverCmd := &clibase.Cmd{
168-
Use: "server",
169-
Short: "Start a Coder server",
170-
Options: opts,
171-
Middleware: clibase.RequireNArgs(0),
168+
Use: "server",
169+
Short: "Start a Coder server",
170+
Options: opts,
171+
Middleware: clibase.Chain(
172+
writeConfigMW(cfg),
173+
printDeprecatedOptions(),
174+
clibase.RequireNArgs(0),
175+
),
172176
Handler: func(inv *clibase.Invocation) error {
173177
// Main command context for managing cancellation of running
174178
// services.
175179
ctx, cancel := context.WithCancel(inv.Context())
176180
defer cancel()
177181

178-
if cfg.WriteConfig {
179-
n, err := opts.MarshalYAML()
180-
if err != nil {
181-
return xerrors.Errorf("generate yaml: %w", err)
182-
}
183-
enc := yaml.NewEncoder(inv.Stdout)
184-
enc.SetIndent(2)
185-
err = enc.Encode(n)
186-
if err != nil {
187-
return xerrors.Errorf("encode yaml: %w", err)
188-
}
189-
err = enc.Close()
190-
if err != nil {
191-
return xerrors.Errorf("close yaml encoder: %w", err)
192-
}
193-
return nil
194-
}
195-
196182
if cfg.Config != "" {
197183
cliui.Warnf(inv.Stderr, "YAML support is experimental and offers no compatibility guarantees.")
198184
}
199185

200-
// Print deprecation warnings.
201-
for _, opt := range opts {
202-
if opt.UseInstead == nil {
203-
continue
204-
}
205-
206-
if opt.Value.String() == opt.Default {
207-
continue
208-
}
209-
210-
warnStr := opt.Name + " is deprecated, please use "
211-
for i, use := range opt.UseInstead {
212-
warnStr += use.Name + " "
213-
if i != len(opt.UseInstead)-1 {
214-
warnStr += "and "
215-
}
216-
}
217-
warnStr += "instead.\n"
218-
219-
cliui.Warn(inv.Stderr,
220-
warnStr,
221-
)
222-
}
223-
224186
go dumpHandler(ctx)
225187

226188
// Validate bind addresses.
@@ -1222,6 +1184,71 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
12221184
return serverCmd
12231185
}
12241186

1187+
// printDeprecatedOptions loops through all command options, and prints
1188+
// a warning for usage of deprecated options.
1189+
func printDeprecatedOptions() clibase.MiddlewareFunc {
1190+
return func(next clibase.HandlerFunc) clibase.HandlerFunc {
1191+
return func(inv *clibase.Invocation) error {
1192+
opts := inv.Command.Options
1193+
// Print deprecation warnings.
1194+
for _, opt := range opts {
1195+
if opt.UseInstead == nil {
1196+
continue
1197+
}
1198+
1199+
if opt.Value.String() == opt.Default {
1200+
continue
1201+
}
1202+
1203+
warnStr := opt.Name + " is deprecated, please use "
1204+
for i, use := range opt.UseInstead {
1205+
warnStr += use.Name + " "
1206+
if i != len(opt.UseInstead)-1 {
1207+
warnStr += "and "
1208+
}
1209+
}
1210+
warnStr += "instead.\n"
1211+
1212+
cliui.Warn(inv.Stderr,
1213+
warnStr,
1214+
)
1215+
}
1216+
1217+
return next(inv)
1218+
}
1219+
}
1220+
}
1221+
1222+
// writeConfigMW will prevent the main command from running if the write-config
1223+
// flag is set. Instead, it will marshal the command options to YAML and write
1224+
// them to stdout.
1225+
func writeConfigMW(cfg *codersdk.DeploymentValues) clibase.MiddlewareFunc {
1226+
return func(next clibase.HandlerFunc) clibase.HandlerFunc {
1227+
return func(inv *clibase.Invocation) error {
1228+
if !cfg.WriteConfig {
1229+
return next(inv)
1230+
}
1231+
1232+
opts := inv.Command.Options
1233+
n, err := opts.MarshalYAML()
1234+
if err != nil {
1235+
return xerrors.Errorf("generate yaml: %w", err)
1236+
}
1237+
enc := yaml.NewEncoder(inv.Stdout)
1238+
enc.SetIndent(2)
1239+
err = enc.Encode(n)
1240+
if err != nil {
1241+
return xerrors.Errorf("encode yaml: %w", err)
1242+
}
1243+
err = enc.Close()
1244+
if err != nil {
1245+
return xerrors.Errorf("close yaml encoder: %w", err)
1246+
}
1247+
return nil
1248+
}
1249+
}
1250+
}
1251+
12251252
// isLocalURL returns true if the hostname of the provided URL appears to
12261253
// resolve to a loopback address.
12271254
func isLocalURL(ctx context.Context, u *url.URL) (bool, error) {

cli/server_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func TestReadGitAuthProvidersFromEnv(t *testing.T) {
8484
"CODER_GITAUTH_1_TOKEN_URL=google.com",
8585
"CODER_GITAUTH_1_VALIDATE_URL=bing.com",
8686
"CODER_GITAUTH_1_SCOPES=repo:read repo:write",
87+
"CODER_GITAUTH_1_NO_REFRESH=true",
8788
})
8889
require.NoError(t, err)
8990
require.Len(t, providers, 2)
@@ -99,6 +100,7 @@ func TestReadGitAuthProvidersFromEnv(t *testing.T) {
99100
assert.Equal(t, "google.com", providers[1].TokenURL)
100101
assert.Equal(t, "bing.com", providers[1].ValidateURL)
101102
assert.Equal(t, []string{"repo:read", "repo:write"}, providers[1].Scopes)
103+
assert.Equal(t, true, providers[1].NoRefresh)
102104
})
103105
}
104106

cli/testdata/coder_scaletest_create-workspaces_--help.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,8 @@ It is recommended that all rate limits are disabled on the server before running
116116
if the server is configured with the exact same tracing configuration
117117
as the client.
118118

119+
--use-host-login bool, $CODER_SCALETEST_USE_HOST_LOGIN (default: false)
120+
Use the use logged in on the host machine, instead of creating users.
121+
119122
---
120123
Run `coder --help` for a list of global options.

cli/testdata/coder_server_--help.golden

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Start a Coder server
1616
$CACHE_DIRECTORY is set, it will be used for compatibility with
1717
systemd.
1818

19+
--disable-owner-workspace-access bool, $CODER_DISABLE_OWNER_WORKSPACE_ACCESS
20+
Remove the permission for the 'owner' role to have workspace execution
21+
on all workspaces. This prevents the 'owner' from ssh, apps, and
22+
terminal access based on the 'owner' role. They still have their user
23+
permissions to access their own workspaces.
24+
1925
--disable-path-apps bool, $CODER_DISABLE_PATH_APPS
2026
Disable workspace apps that are not served from subdomains. Path-based
2127
apps can make requests to the Coder API and pose a security risk when

cli/testdata/server-config.yaml.golden

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ agentFallbackTroubleshootingURL: https://coder.com/docs/coder-oss/latest/templat
315315
# --wildcard-access-url is configured.
316316
# (default: <unset>, type: bool)
317317
disablePathApps: false
318+
# Remove the permission for the 'owner' role to have workspace execution on all
319+
# workspaces. This prevents the 'owner' from ssh, apps, and terminal access based
320+
# on the 'owner' role. They still have their user permissions to access their own
321+
# workspaces.
322+
# (default: <unset>, type: bool)
323+
disableOwnerWorkspaceAccess: false
318324
# These options change the behavior of how clients interact with the Coder.
319325
# Clients include the coder cli, vs code extension, and the web UI.
320326
client:

0 commit comments

Comments
 (0)