Skip to content

Commit c010530

Browse files
author
Katie Horne
committed
Merge branch 'bpmct/docs' of https://github.com/coder/coder into bpmct/docs
2 parents a803f8a + e37e4a4 commit c010530

File tree

248 files changed

+3679
-1236
lines changed

Some content is hidden

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

248 files changed

+3679
-1236
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
site @coder/frontend
1+
site/ @coder/frontend
22
site/src/xServices @presleyp

.github/workflows/coder.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
- name: Install Protoc
9595
uses: arduino/setup-protoc@v1
9696
with:
97-
version: "3.19.4"
97+
version: "3.20.0"
9898
- uses: actions/setup-go@v3
9999
with:
100100
go-version: "~1.18"
@@ -172,7 +172,7 @@ jobs:
172172
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
173173

174174
- name: Install goreleaser
175-
uses: jaxxstorm/action-install-gh-release@v1.4.0
175+
uses: jaxxstorm/action-install-gh-release@v1.5.0
176176
env:
177177
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
178178
with:
@@ -241,7 +241,7 @@ jobs:
241241
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
242242

243243
- name: Install goreleaser
244-
uses: jaxxstorm/action-install-gh-release@v1.4.0
244+
uses: jaxxstorm/action-install-gh-release@v1.5.0
245245
env:
246246
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
247247
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ site/out/
3535
*.tfplan
3636
*.lock.hcl
3737
.terraform/
38+
39+
.vscode/*.log

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"nolint",
3636
"nosec",
3737
"ntqry",
38+
"OIDC",
3839
"oneof",
3940
"parameterscopeid",
4041
"pqtype",
@@ -46,15 +47,18 @@
4647
"ptytest",
4748
"retrier",
4849
"sdkproto",
50+
"Signup",
4951
"stretchr",
5052
"TCGETS",
5153
"tcpip",
5254
"TCSETS",
5355
"tfexec",
56+
"tfjson",
5457
"tfstate",
5558
"trimprefix",
5659
"unconvert",
5760
"Untar",
61+
"VMID",
5862
"webrtc",
5963
"xerrors",
6064
"yamux"

Makefile

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
1515
.PHONY: coderd/database/dump.sql
1616

1717
# Generates Go code for querying the database.
18-
coderd/database/generate: fmt/sql coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
18+
coderd/database/generate: coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
1919
coderd/database/generate.sh
2020
.PHONY: coderd/database/generate
2121

2222
apitypings/generate: site/src/api/types.ts
23-
go run scripts/apitypings/main.go > site/src/api/types-generated.ts
23+
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
2424
cd site && yarn run format:types
2525
.PHONY: apitypings/generate
2626

@@ -34,31 +34,18 @@ else
3434
endif
3535
.PHONY: fmt/prettier
3636

37-
fmt/sql: $(wildcard coderd/database/queries/*.sql)
38-
# TODO: this is slightly slow
39-
for fi in coderd/database/queries/*.sql; do \
40-
npx sql-formatter \
41-
--language postgresql \
42-
--lines-between-queries 2 \
43-
--tab-indent \
44-
$$fi \
45-
--output $$fi; \
46-
done
47-
48-
sed -i 's/@ /@/g' ./coderd/database/queries/*.sql
49-
5037
fmt/terraform: $(wildcard *.tf)
5138
terraform fmt -recursive
5239

53-
fmt: fmt/prettier fmt/sql fmt/terraform
40+
fmt: fmt/prettier fmt/terraform
5441
.PHONY: fmt
5542

5643
gen: coderd/database/generate peerbroker/proto provisionersdk/proto provisionerd/proto apitypings/generate
5744
.PHONY: gen
5845

5946
install: bin
6047
@echo "--- Copying from bin to $(INSTALL_DIR)"
61-
cp -r ./dist/coder_$(GOOS)_$(GOARCH)/* $(INSTALL_DIR)
48+
cp -r ./dist/coder-$(GOOS)_$(GOOS)_$(GOARCH)*/* $(INSTALL_DIR)
6249
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
6350
.PHONY: install
6451

@@ -93,7 +80,7 @@ provisionersdk/proto: provisionersdk/proto/provisioner.proto
9380
./provisionersdk/proto/provisioner.proto
9481
.PHONY: provisionersdk/proto
9582

96-
release:
83+
release: site/out
9784
goreleaser release --snapshot --rm-dist --skip-sign
9885
.PHONY: release
9986

agent/agent_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ func TestAgent(t *testing.T) {
7676
session.Stdin = ptty.Input()
7777
err = session.Start(command)
7878
require.NoError(t, err)
79+
caret := "$"
80+
if runtime.GOOS == "windows" {
81+
caret = ">"
82+
}
83+
ptty.ExpectMatch(caret)
7984
ptty.WriteLine("echo test")
8085
ptty.ExpectMatch("test")
8186
ptty.WriteLine("exit")

agent/usershell/usershell_darwin.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package usershell
33
import "os"
44

55
// Get returns the $SHELL environment variable.
6-
// TODO: This should use "dscl" to fetch the proper value. See:
7-
// https://stackoverflow.com/questions/16375519/how-to-get-the-default-shell
86
func Get(username string) (string, error) {
97
return os.Getenv("SHELL"), nil
108
}

cli/agent.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,19 @@ func workspaceAgent() *cobra.Command {
7676
return client.AuthWorkspaceAWSInstanceIdentity(ctx)
7777
}
7878
case "azure-instance-identity":
79-
return xerrors.Errorf("not implemented")
79+
// This is *only* done for testing to mock client authentication.
80+
// This will never be set in a production scenario.
81+
var azureClient *http.Client
82+
azureClientRaw := cmd.Context().Value("azure-client")
83+
if azureClientRaw != nil {
84+
azureClient, _ = azureClientRaw.(*http.Client)
85+
if azureClient != nil {
86+
client.HTTPClient = azureClient
87+
}
88+
}
89+
exchangeToken = func(ctx context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error) {
90+
return client.AuthWorkspaceAzureInstanceIdentity(ctx)
91+
}
8092
}
8193

8294
if exchangeToken != nil {
@@ -108,6 +120,10 @@ func workspaceAgent() *cobra.Command {
108120
if err != nil {
109121
return xerrors.Errorf("writing agent session token to config: %w", err)
110122
}
123+
err = cfg.URL().Write(client.URL.String())
124+
if err != nil {
125+
return xerrors.Errorf("writing agent url to config: %w", err)
126+
}
111127

112128
closer := agent.New(client.ListenWorkspaceAgent, logger)
113129
<-cmd.Context().Done()

cli/agent_test.go

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,66 @@ import (
1515

1616
func TestWorkspaceAgent(t *testing.T) {
1717
t.Parallel()
18+
t.Run("Azure", func(t *testing.T) {
19+
t.Parallel()
20+
instanceID := "instanceidentifier"
21+
certificates, metadataClient := coderdtest.NewAzureInstanceIdentity(t, instanceID)
22+
client := coderdtest.New(t, &coderdtest.Options{
23+
AzureCertificates: certificates,
24+
})
25+
user := coderdtest.CreateFirstUser(t, client)
26+
coderdtest.NewProvisionerDaemon(t, client)
27+
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
28+
Parse: echo.ParseComplete,
29+
Provision: []*proto.Provision_Response{{
30+
Type: &proto.Provision_Response_Complete{
31+
Complete: &proto.Provision_Complete{
32+
Resources: []*proto.Resource{{
33+
Name: "somename",
34+
Type: "someinstance",
35+
Agents: []*proto.Agent{{
36+
Auth: &proto.Agent_InstanceId{
37+
InstanceId: instanceID,
38+
},
39+
}},
40+
}},
41+
},
42+
},
43+
}},
44+
})
45+
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
46+
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
47+
workspace := coderdtest.CreateWorkspace(t, client, codersdk.Me, template.ID)
48+
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
49+
50+
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--url", client.URL.String())
51+
ctx, cancelFunc := context.WithCancel(context.Background())
52+
defer cancelFunc()
53+
go func() {
54+
// A linting error occurs for weakly typing the context value here,
55+
// but it seems reasonable for a one-off test.
56+
// nolint
57+
ctx = context.WithValue(ctx, "azure-client", metadataClient)
58+
err := cmd.ExecuteContext(ctx)
59+
require.NoError(t, err)
60+
}()
61+
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
62+
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
63+
require.NoError(t, err)
64+
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
65+
require.NoError(t, err)
66+
defer dialer.Close()
67+
_, err = dialer.Ping()
68+
require.NoError(t, err)
69+
cancelFunc()
70+
})
71+
1872
t.Run("AWS", func(t *testing.T) {
1973
t.Parallel()
2074
instanceID := "instanceidentifier"
2175
certificates, metadataClient := coderdtest.NewAWSInstanceIdentity(t, instanceID)
2276
client := coderdtest.New(t, &coderdtest.Options{
23-
AWSInstanceIdentity: certificates,
77+
AWSCertificates: certificates,
2478
})
2579
user := coderdtest.CreateFirstUser(t, client)
2680
coderdtest.NewProvisionerDaemon(t, client)
@@ -74,7 +128,7 @@ func TestWorkspaceAgent(t *testing.T) {
74128
instanceID := "instanceidentifier"
75129
validator, metadata := coderdtest.NewGoogleInstanceIdentity(t, instanceID, false)
76130
client := coderdtest.New(t, &coderdtest.Options{
77-
GoogleInstanceIdentity: validator,
131+
GoogleTokenValidator: validator,
78132
})
79133
user := coderdtest.CreateFirstUser(t, client)
80134
coderdtest.NewProvisionerDaemon(t, client)

cli/cliflag/cliflag.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"fmt"
1515
"os"
1616
"strconv"
17+
"strings"
1718

1819
"github.com/spf13/pflag"
1920
)
@@ -27,6 +28,14 @@ func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string
2728
flagset.StringVarP(p, name, shorthand, v, fmtUsage(usage, env))
2829
}
2930

31+
func StringArrayVarP(flagset *pflag.FlagSet, ptr *[]string, name string, shorthand string, env string, def []string, usage string) {
32+
val, ok := os.LookupEnv(env)
33+
if ok {
34+
def = strings.Split(val, ",")
35+
}
36+
flagset.StringArrayVarP(ptr, name, shorthand, def, usage)
37+
}
38+
3039
// Uint8VarP sets a uint8 flag on the given flag set.
3140
func Uint8VarP(flagset *pflag.FlagSet, ptr *uint8, name string, shorthand string, env string, def uint8, usage string) {
3241
val, ok := os.LookupEnv(env)

0 commit comments

Comments
 (0)