Skip to content

Commit 0ff2be9

Browse files
committed
Merge branch 'main' of https://github.com/coder/coder into bq/add-agent-timings
2 parents 124d149 + 097fdaf commit 0ff2be9

File tree

221 files changed

+6196
-4763
lines changed

Some content is hidden

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

221 files changed

+6196
-4763
lines changed

.github/actions/setup-go/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: |
44
inputs:
55
version:
66
description: "The Go version to use."
7-
default: "1.22.6"
7+
default: "1.22.8"
88
runs:
99
using: "composite"
1010
steps:

.github/actions/setup-tf/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ runs:
77
- name: Install Terraform
88
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
99
with:
10-
terraform_version: 1.9.2
10+
terraform_version: 1.9.8
1111
terraform_wrapper: false

.github/workflows/ci.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ jobs:
197197
198198
# Check for any typos
199199
- name: Check for typos
200-
uses: crate-ci/typos@6802cc60d4e7f78b9d5454f6cf3935c042d5e1e3 # v1.26.0
200+
uses: crate-ci/typos@0d9e0c2c1bd7f770f6eb90f87780848ca02fc12c # v1.26.8
201201
with:
202202
config: .github/workflows/typos.toml
203203

@@ -233,8 +233,7 @@ jobs:
233233
gen:
234234
timeout-minutes: 8
235235
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
236-
needs: changes
237-
if: needs.changes.outputs.docs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
236+
if: always()
238237
steps:
239238
- name: Harden Runner
240239
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1

.github/workflows/pr-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ jobs:
425425
--first-user-username coder \
426426
--first-user-email pr${{ env.PR_NUMBER }}@coder.com \
427427
--first-user-password $password \
428-
--first-user-trial \
428+
--first-user-trial=false \
429429
--use-token-as-session \
430430
https://${{ env.PR_HOSTNAME }}
431431

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ jobs:
4747

4848
# Upload the results to GitHub's code scanning dashboard.
4949
- name: "Upload to code-scanning"
50-
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
50+
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
5151
with:
5252
sarif_file: results.sarif

.github/workflows/security.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: "security"
33
permissions:
44
actions: read
55
contents: read
6-
security-events: write
76

87
on:
98
workflow_dispatch:
@@ -23,6 +22,8 @@ concurrency:
2322

2423
jobs:
2524
codeql:
25+
permissions:
26+
security-events: write
2627
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
2728
steps:
2829
- name: Harden Runner
@@ -37,7 +38,7 @@ jobs:
3738
uses: ./.github/actions/setup-go
3839

3940
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
41+
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
4142
with:
4243
languages: go, javascript
4344

@@ -47,7 +48,7 @@ jobs:
4748
rm Makefile
4849
4950
- name: Perform CodeQL Analysis
50-
uses: github/codeql-action/analyze@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
51+
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
5152

5253
- name: Send Slack notification on failure
5354
if: ${{ failure() }}
@@ -61,6 +62,8 @@ jobs:
6162
"${{ secrets.SLACK_SECURITY_FAILURE_WEBHOOK_URL }}"
6263
6364
trivy:
65+
permissions:
66+
security-events: write
6467
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
6568
steps:
6669
- name: Harden Runner
@@ -95,13 +98,20 @@ jobs:
9598
# protoc must be in lockstep with our dogfood Dockerfile or the
9699
# version in the comments will differ. This is also defined in
97100
# ci.yaml.
98-
set -x
101+
set -euxo pipefail
99102
cd dogfood/contents
103+
mkdir -p /usr/local/bin
104+
mkdir -p /usr/local/include
105+
100106
DOCKER_BUILDKIT=1 docker build . --target proto -t protoc
101107
protoc_path=/usr/local/bin/protoc
102108
docker run --rm --entrypoint cat protoc /tmp/bin/protoc > $protoc_path
103109
chmod +x $protoc_path
104110
protoc --version
111+
# Copy the generated files to the include directory.
112+
docker run --rm -v /usr/local/include:/target protoc cp -r /tmp/include/google /target/
113+
ls -la /usr/local/include/google/protobuf/
114+
stat /usr/local/include/google/protobuf/timestamp.proto
105115
106116
- name: Build Coder linux amd64 Docker image
107117
id: build
@@ -132,7 +142,7 @@ jobs:
132142
severity: "CRITICAL,HIGH"
133143

134144
- name: Upload Trivy scan results to GitHub Security tab
135-
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
145+
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
136146
with:
137147
sarif_file: trivy-results.sarif
138148
category: "Trivy"

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
"unauthenticate",
176176
"unconvert",
177177
"untar",
178+
"userauth",
178179
"userspace",
179180
"VMID",
180181
"walkthrough",

cli/login.go

Lines changed: 124 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,59 @@ func (r *RootCmd) login() *serpent.Command {
267267
trial = v == "yes" || v == "y"
268268
}
269269

270+
var trialInfo codersdk.CreateFirstUserTrialInfo
271+
if trial {
272+
if trialInfo.FirstName == "" {
273+
trialInfo.FirstName, err = promptTrialInfo(inv, "firstName")
274+
if err != nil {
275+
return err
276+
}
277+
}
278+
if trialInfo.LastName == "" {
279+
trialInfo.LastName, err = promptTrialInfo(inv, "lastName")
280+
if err != nil {
281+
return err
282+
}
283+
}
284+
if trialInfo.PhoneNumber == "" {
285+
trialInfo.PhoneNumber, err = promptTrialInfo(inv, "phoneNumber")
286+
if err != nil {
287+
return err
288+
}
289+
}
290+
if trialInfo.JobTitle == "" {
291+
trialInfo.JobTitle, err = promptTrialInfo(inv, "jobTitle")
292+
if err != nil {
293+
return err
294+
}
295+
}
296+
if trialInfo.CompanyName == "" {
297+
trialInfo.CompanyName, err = promptTrialInfo(inv, "companyName")
298+
if err != nil {
299+
return err
300+
}
301+
}
302+
if trialInfo.Country == "" {
303+
trialInfo.Country, err = promptCountry(inv)
304+
if err != nil {
305+
return err
306+
}
307+
}
308+
if trialInfo.Developers == "" {
309+
trialInfo.Developers, err = promptDevelopers(inv)
310+
if err != nil {
311+
return err
312+
}
313+
}
314+
}
315+
270316
_, err = client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{
271-
Email: email,
272-
Username: username,
273-
Name: name,
274-
Password: password,
275-
Trial: trial,
317+
Email: email,
318+
Username: username,
319+
Name: name,
320+
Password: password,
321+
Trial: trial,
322+
TrialInfo: trialInfo,
276323
})
277324
if err != nil {
278325
return xerrors.Errorf("create initial user: %w", err)
@@ -449,3 +496,75 @@ func openURL(inv *serpent.Invocation, urlToOpen string) error {
449496

450497
return browser.OpenURL(urlToOpen)
451498
}
499+
500+
func promptTrialInfo(inv *serpent.Invocation, fieldName string) (string, error) {
501+
value, err := cliui.Prompt(inv, cliui.PromptOptions{
502+
Text: fmt.Sprintf("Please enter %s:", pretty.Sprint(cliui.DefaultStyles.Field, fieldName)),
503+
Validate: func(s string) error {
504+
if strings.TrimSpace(s) == "" {
505+
return xerrors.Errorf("%s is required", fieldName)
506+
}
507+
return nil
508+
},
509+
})
510+
if err != nil {
511+
if errors.Is(err, cliui.Canceled) {
512+
return "", nil
513+
}
514+
return "", err
515+
}
516+
return value, nil
517+
}
518+
519+
func promptDevelopers(inv *serpent.Invocation) (string, error) {
520+
options := []string{"1-100", "101-500", "501-1000", "1001-2500", "2500+"}
521+
selection, err := cliui.Select(inv, cliui.SelectOptions{
522+
Options: options,
523+
HideSearch: false,
524+
Message: "Select the number of developers:",
525+
})
526+
if err != nil {
527+
return "", xerrors.Errorf("select developers: %w", err)
528+
}
529+
return selection, nil
530+
}
531+
532+
func promptCountry(inv *serpent.Invocation) (string, error) {
533+
countries := []string{
534+
"Afghanistan", "Åland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda",
535+
"Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados",
536+
"Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia, Plurinational State of", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana",
537+
"Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada",
538+
"Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros",
539+
"Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Côte d'Ivoire", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czech Republic",
540+
"Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia",
541+
"Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon",
542+
"Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam",
543+
"Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong",
544+
"Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic of", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy",
545+
"Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait",
546+
"Kyrgyzstan", "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
547+
"Macao", "Macedonia, the Former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique",
548+
"Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montenegro", "Montserrat",
549+
"Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua",
550+
"Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestine, State of",
551+
"Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar",
552+
"Réunion", "Romania", "Russian Federation", "Rwanda", "Saint Barthélemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon",
553+
"Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore",
554+
"Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka",
555+
"Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of",
556+
"Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands",
557+
"Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu",
558+
"Venezuela, Bolivarian Republic of", "Vietnam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe",
559+
}
560+
561+
selection, err := cliui.Select(inv, cliui.SelectOptions{
562+
Options: countries,
563+
Message: "Select the country:",
564+
HideSearch: false,
565+
})
566+
if err != nil {
567+
return "", xerrors.Errorf("select country: %w", err)
568+
}
569+
return selection, nil
570+
}

0 commit comments

Comments
 (0)