Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import (

"github.com/coder/coder/v2/cli/clibase"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/util/ptr"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisionerd"
)

func (r *RootCmd) templateCreate() *clibase.Cmd {
Expand Down Expand Up @@ -111,7 +109,7 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
Message: message,
Client: client,
Organization: organization,
Provisioner: database.ProvisionerType(provisioner),
Provisioner: codersdk.ProvisionerType(provisioner),
FileID: resp.ID,
ProvisionerTags: tags,
VariablesFile: variablesFile,
Expand Down Expand Up @@ -224,7 +222,7 @@ type createValidTemplateVersionArgs struct {
Message string
Client *codersdk.Client
Organization codersdk.Organization
Provisioner database.ProvisionerType
Provisioner codersdk.ProvisionerType
FileID uuid.UUID

VariablesFile string
Expand Down Expand Up @@ -258,7 +256,7 @@ func createValidTemplateVersion(inv *clibase.Invocation, args createValidTemplat
Message: args.Message,
StorageMethod: codersdk.ProvisionerStorageMethodFile,
FileID: args.FileID,
Provisioner: codersdk.ProvisionerType(args.Provisioner),
Provisioner: args.Provisioner,
ProvisionerTags: args.ProvisionerTags,
UserVariableValues: variableValues,
}
Expand All @@ -284,7 +282,10 @@ func createValidTemplateVersion(inv *clibase.Invocation, args createValidTemplat
})
if err != nil {
var jobErr *cliui.ProvisionerJobError
if errors.As(err, &jobErr) && !provisionerd.IsMissingParameterErrorCode(string(jobErr.Code)) {
if errors.As(err, &jobErr) && !codersdk.JobIsMissingParameterErrorCode(jobErr.Code) {
return nil, err
}
if err != nil {
return nil, err
}
}
Expand Down
3 changes: 1 addition & 2 deletions cli/templatepush.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/coder/coder/v2/cli/clibase"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisionersdk"
)
Expand Down Expand Up @@ -216,7 +215,7 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
Message: message,
Client: client,
Organization: organization,
Provisioner: database.ProvisionerType(provisioner),
Provisioner: codersdk.ProvisionerType(provisioner),
FileID: resp.ID,
ProvisionerTags: tags,
VariablesFile: variablesFile,
Expand Down
7 changes: 7 additions & 0 deletions codersdk/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"nhooyr.io/websocket"

"github.com/coder/coder/v2/provisionerd/proto"
"github.com/coder/coder/v2/provisionerd/runner"
"github.com/coder/coder/v2/provisionersdk"
)

Expand Down Expand Up @@ -72,6 +73,12 @@ const (
RequiredTemplateVariables JobErrorCode = "REQUIRED_TEMPLATE_VARIABLES"
)

// JobIsMissingParameterErrorCode returns whether the error is a missing parameter error.
// This can indicate to consumers that they should check parameters.
func JobIsMissingParameterErrorCode(code JobErrorCode) bool {
return string(code) == runner.MissingParameterErrorCode
}

// ProvisionerJob describes the job executed by the provisioning daemon.
type ProvisionerJob struct {
ID uuid.UUID `json:"id" format:"uuid"`
Expand Down
6 changes: 0 additions & 6 deletions provisionerd/provisionerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ import (
"github.com/coder/retry"
)

// IsMissingParameterErrorCode returns whether the error is a missing parameter error.
// This can indicate to consumers that they should check parameters.
func IsMissingParameterErrorCode(code string) bool {
return code == runner.MissingParameterErrorCode
}

// Dialer represents the function to create a daemon client connection.
type Dialer func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error)

Expand Down