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
23 changes: 19 additions & 4 deletions bundle/deploy/lock/deployment_metadata_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/deploy"
"github.com/databricks/cli/bundle/deployplan"
"github.com/databricks/cli/bundle/statemgmt"
Expand Down Expand Up @@ -153,10 +154,11 @@ func acquireLock(ctx context.Context, b *bundle.Bundle, svc *tmpdms.DeploymentMe
Parent: "deployments/" + deploymentID,
VersionID: versionID,
Version: &tmpdms.Version{
DisplayName: b.Config.Bundle.Name,
CliVersion: build.GetInfo().Version,
VersionType: versionType,
TargetName: b.Config.Bundle.Target,
DisplayName: b.Config.Bundle.Name,
DeploymentMode: deploymentMode(b.Config.Bundle.Mode),
CliVersion: build.GetInfo().Version,
VersionType: versionType,
TargetName: b.Config.Bundle.Target,
// Same git provenance the CLI records in metadata.json.
GitInfo: &tmpdms.GitInfo{
OriginURL: b.Config.Bundle.Git.OriginURL,
Expand Down Expand Up @@ -342,3 +344,16 @@ func isAborted(err error) bool {
apiErr, ok := errors.AsType[*apierr.APIError](err)
return ok && apiErr.StatusCode == http.StatusConflict && apiErr.ErrorCode == "ABORTED"
}

// deploymentMode maps a bundle target mode to the DMS deployment mode enum.
// Unset target modes produce an empty value, which is omitted from the request.
func deploymentMode(mode config.Mode) tmpdms.DeploymentMode {
switch mode {
case config.Development:
return tmpdms.DeploymentModeDevelopment
case config.Production:
return tmpdms.DeploymentModeProduction
default:
return ""
}
}
19 changes: 19 additions & 0 deletions bundle/deploy/lock/deployment_metadata_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package lock
import (
"testing"

"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/deployplan"
"github.com/databricks/cli/libs/tmpdms"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -52,3 +53,21 @@ func TestGoalToVersionType(t *testing.T) {
_, ok = goalToVersionType(GoalUnbind)
assert.False(t, ok)
}

func TestDeploymentMode(t *testing.T) {
tests := []struct {
mode config.Mode
expected tmpdms.DeploymentMode
}{
{config.Development, tmpdms.DeploymentModeDevelopment},
{config.Production, tmpdms.DeploymentModeProduction},
{"", ""},
{"unknown", ""},
}

for _, tt := range tests {
t.Run(string(tt.mode), func(t *testing.T) {
assert.Equal(t, tt.expected, deploymentMode(tt.mode))
})
}
}
7 changes: 7 additions & 0 deletions libs/tmpdms/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type (
OperationStatus string
OperationActionType string
DeploymentResourceType string
DeploymentMode string
)

const (
Expand Down Expand Up @@ -47,6 +48,11 @@ const (
VersionTypeDestroy VersionType = "VERSION_TYPE_DESTROY"
)

const (
DeploymentModeDevelopment DeploymentMode = "DEPLOYMENT_MODE_DEVELOPMENT"
DeploymentModeProduction DeploymentMode = "DEPLOYMENT_MODE_PRODUCTION"
)

const (
OperationStatusUnspecified OperationStatus = "OPERATION_STATUS_UNSPECIFIED"
OperationStatusSucceeded OperationStatus = "OPERATION_STATUS_SUCCEEDED"
Expand Down Expand Up @@ -119,6 +125,7 @@ type Version struct {
VersionType VersionType `json:"version_type,omitempty"`
CompletionReason VersionComplete `json:"completion_reason,omitempty"`
CompletedBy string `json:"completed_by,omitempty"`
DeploymentMode DeploymentMode `json:"deployment_mode,omitempty"`
DisplayName string `json:"display_name,omitempty"`
TargetName string `json:"target_name,omitempty"`
GitInfo *GitInfo `json:"git_info,omitempty"`
Expand Down
Loading