Skip to content

Commit 91825d7

Browse files
committed
Merge branch 'main' into licenseflow
2 parents 5ebd76b + b6703b1 commit 91825d7

Some content is hidden

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

54 files changed

+1094
-372
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"codersdk",
1818
"cronstrue",
1919
"databasefake",
20+
"dbtype",
2021
"DERP",
2122
"derphttp",
2223
"derpmap",

cli/deployment/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func newConfig() *codersdk.DeploymentConfig {
143143
Name: "Cache Directory",
144144
Usage: "The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd.",
145145
Flag: "cache-dir",
146-
Default: defaultCacheDir(),
146+
Default: DefaultCacheDir(),
147147
},
148148
InMemoryDatabase: &codersdk.DeploymentConfigField[bool]{
149149
Name: "In Memory Database",
@@ -672,7 +672,7 @@ func formatEnv(key string) string {
672672
return "CODER_" + strings.ToUpper(strings.NewReplacer("-", "_", ".", "_").Replace(key))
673673
}
674674

675-
func defaultCacheDir() string {
675+
func DefaultCacheDir() string {
676676
defaultCacheDir, err := os.UserCacheDir()
677677
if err != nil {
678678
defaultCacheDir = os.TempDir()

cli/gitaskpass.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func gitAskpass() *cobra.Command {
2626
RunE: func(cmd *cobra.Command, args []string) error {
2727
ctx := cmd.Context()
2828

29-
ctx, stop := signal.NotifyContext(ctx, interruptSignals...)
29+
ctx, stop := signal.NotifyContext(ctx, InterruptSignals...)
3030
defer stop()
3131

3232
user, host, err := gitauth.ParseAskpass(args[0])

cli/gitssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func gitssh() *cobra.Command {
2929

3030
// Catch interrupt signals to ensure the temporary private
3131
// key file is cleaned up on most cases.
32-
ctx, stop := signal.NotifyContext(ctx, interruptSignals...)
32+
ctx, stop := signal.NotifyContext(ctx, InterruptSignals...)
3333
defer stop()
3434

3535
// Early check so errors are reported immediately.

cli/login_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestLogin(t *testing.T) {
7575
// accurately detect Windows ptys when they are not attached to a process:
7676
// https://github.com/mattn/go-isatty/issues/59
7777
doneChan := make(chan struct{})
78-
root, _ := clitest.New(t, "login", client.URL.String(), "--first-user-username", "testuser", "--first-user-email", "user@coder.com", "--first-user-password", "password")
78+
root, _ := clitest.New(t, "login", client.URL.String(), "--first-user-username", "testuser", "--first-user-email", "user@coder.com", "--first-user-password", "password", "--first-user-trial")
7979
pty := ptytest.New(t)
8080
root.SetIn(pty.Input())
8181
root.SetOut(pty.Output())

cli/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
108108
//
109109
// To get out of a graceful shutdown, the user can send
110110
// SIGQUIT with ctrl+\ or SIGKILL with `kill -9`.
111-
notifyCtx, notifyStop := signal.NotifyContext(ctx, interruptSignals...)
111+
notifyCtx, notifyStop := signal.NotifyContext(ctx, InterruptSignals...)
112112
defer notifyStop()
113113

114114
// Clean up idle connections at the end, e.g.
@@ -946,7 +946,7 @@ func newProvisionerDaemon(
946946
return provisionerd.New(func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
947947
// This debounces calls to listen every second. Read the comment
948948
// in provisionerdserver.go to learn more!
949-
return coderAPI.ListenProvisionerDaemon(ctx, time.Second)
949+
return coderAPI.CreateInMemoryProvisionerDaemon(ctx, time.Second)
950950
}, &provisionerd.Options{
951951
Logger: logger,
952952
PollInterval: 500 * time.Millisecond,

cli/signal_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"syscall"
88
)
99

10-
var interruptSignals = []os.Signal{
10+
var InterruptSignals = []os.Signal{
1111
os.Interrupt,
1212
syscall.SIGTERM,
1313
syscall.SIGHUP,

cli/signal_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import (
66
"os"
77
)
88

9-
var interruptSignals = []os.Signal{os.Interrupt}
9+
var InterruptSignals = []os.Signal{os.Interrupt}

cli/templatecreate.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ import (
2424

2525
func templateCreate() *cobra.Command {
2626
var (
27-
directory string
28-
provisioner string
29-
parameterFile string
30-
defaultTTL time.Duration
27+
directory string
28+
provisioner string
29+
provisionerTags []string
30+
parameterFile string
31+
defaultTTL time.Duration
3132
)
3233
cmd := &cobra.Command{
3334
Use: "create [name]",
@@ -87,12 +88,18 @@ func templateCreate() *cobra.Command {
8788
}
8889
spin.Stop()
8990

91+
tags, err := ParseProvisionerTags(provisionerTags)
92+
if err != nil {
93+
return err
94+
}
95+
9096
job, _, err := createValidTemplateVersion(cmd, createValidTemplateVersionArgs{
91-
Client: client,
92-
Organization: organization,
93-
Provisioner: database.ProvisionerType(provisioner),
94-
FileID: resp.ID,
95-
ParameterFile: parameterFile,
97+
Client: client,
98+
Organization: organization,
99+
Provisioner: database.ProvisionerType(provisioner),
100+
FileID: resp.ID,
101+
ParameterFile: parameterFile,
102+
ProvisionerTags: tags,
96103
})
97104
if err != nil {
98105
return err
@@ -131,6 +138,7 @@ func templateCreate() *cobra.Command {
131138
cmd.Flags().StringVarP(&directory, "directory", "d", currentDirectory, "Specify the directory to create from")
132139
cmd.Flags().StringVarP(&provisioner, "test.provisioner", "", "terraform", "Customize the provisioner backend")
133140
cmd.Flags().StringVarP(&parameterFile, "parameter-file", "", "", "Specify a file path with parameter values.")
141+
cmd.Flags().StringArrayVarP(&provisionerTags, "provisioner-tag", "", []string{}, "Specify a set of tags to target provisioner daemons.")
134142
cmd.Flags().DurationVarP(&defaultTTL, "default-ttl", "", 24*time.Hour, "Specify a default TTL for workspaces created from this template.")
135143
// This is for testing!
136144
err := cmd.Flags().MarkHidden("test.provisioner")
@@ -154,6 +162,7 @@ type createValidTemplateVersionArgs struct {
154162
// before prompting the user. Set to false to always prompt for param
155163
// values.
156164
ReuseParameters bool
165+
ProvisionerTags map[string]string
157166
}
158167

159168
func createValidTemplateVersion(cmd *cobra.Command, args createValidTemplateVersionArgs, parameters ...codersdk.CreateParameterRequest) (*codersdk.TemplateVersion, []codersdk.CreateParameterRequest, error) {
@@ -165,6 +174,7 @@ func createValidTemplateVersion(cmd *cobra.Command, args createValidTemplateVers
165174
FileID: args.FileID,
166175
Provisioner: codersdk.ProvisionerType(args.Provisioner),
167176
ParameterValues: parameters,
177+
ProvisionerTags: args.ProvisionerTags,
168178
}
169179
if args.Template != nil {
170180
req.TemplateID = args.Template.ID
@@ -334,3 +344,15 @@ func prettyDirectoryPath(dir string) string {
334344
}
335345
return pretty
336346
}
347+
348+
func ParseProvisionerTags(rawTags []string) (map[string]string, error) {
349+
tags := map[string]string{}
350+
for _, rawTag := range rawTags {
351+
parts := strings.SplitN(rawTag, "=", 2)
352+
if len(parts) < 2 {
353+
return nil, xerrors.Errorf("invalid tag format for %q. must be key=value", rawTag)
354+
}
355+
tags[parts[0]] = parts[1]
356+
}
357+
return tags, nil
358+
}

cli/templatepush.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import (
1818

1919
func templatePush() *cobra.Command {
2020
var (
21-
directory string
22-
versionName string
23-
provisioner string
24-
parameterFile string
25-
alwaysPrompt bool
21+
directory string
22+
versionName string
23+
provisioner string
24+
parameterFile string
25+
alwaysPrompt bool
26+
provisionerTags []string
2627
)
2728

2829
cmd := &cobra.Command{
@@ -75,6 +76,11 @@ func templatePush() *cobra.Command {
7576
}
7677
spin.Stop()
7778

79+
tags, err := ParseProvisionerTags(provisionerTags)
80+
if err != nil {
81+
return err
82+
}
83+
7884
job, _, err := createValidTemplateVersion(cmd, createValidTemplateVersionArgs{
7985
Name: versionName,
8086
Client: client,
@@ -84,6 +90,7 @@ func templatePush() *cobra.Command {
8490
ParameterFile: parameterFile,
8591
Template: &template,
8692
ReuseParameters: !alwaysPrompt,
93+
ProvisionerTags: tags,
8794
})
8895
if err != nil {
8996
return err

0 commit comments

Comments
 (0)