Skip to content

Commit 998e7c7

Browse files
APP-4230 - Add --skip-unassigned flag to version-create command
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 55a0ab5 commit 998e7c7

5 files changed

Lines changed: 26 additions & 0 deletions

File tree

apptrust/commands/flags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const (
5252
OverwriteStrategyFlag = "overwrite-strategy"
5353
TagFlag = "tag"
5454
DraftFlag = "draft"
55+
SkipUnassignedFlag = "skip-unassigned"
5556
SourceTypeBuildsFlag = "source-type-builds"
5657
SourceTypeReleaseBundlesFlag = "source-type-release-bundles"
5758
SourceTypeApplicationVersionsFlag = "source-type-application-versions"
@@ -94,6 +95,7 @@ var flagsMap = map[string]components.Flag{
9495
OverwriteStrategyFlag: components.NewStringFlag(OverwriteStrategyFlag, "Strategy for handling target artifacts with the same path but different checksum. Supported values: "+coreutils.ListToText(model.OverwriteStrategyValues)+".", func(f *components.StringFlag) { f.Mandatory = false }),
9596
TagFlag: components.NewStringFlag(TagFlag, "A tag to associate with the version. Must contain only alphanumeric characters, hyphens (-), underscores (_), and dots (.).", func(f *components.StringFlag) { f.Mandatory = false }),
9697
DraftFlag: components.NewBoolFlag(DraftFlag, "Create the application version as a draft.", components.WithBoolDefaultValueFalse()),
98+
SkipUnassignedFlag: components.NewBoolFlag(SkipUnassignedFlag, "Automatically promote the new version to the first lifecycle stage when all of its source artifacts reside in repositories mapped to that stage. Otherwise the version is left unassigned and a message explaining why is returned.", components.WithBoolDefaultValueFalse()),
9799
SourceTypeBuildsFlag: components.NewStringFlag(SourceTypeBuildsFlag, "List of semicolon-separated (;) builds in the form of 'name=buildName1, id=runID1[, include-deps=true][, repo-key=repo1][, started=2023-01-01T12:34:56.789+0100]; name=buildName2, id=runID2[, include-deps=true][, repo-key=repo2][, started=2023-01-01T12:34:56.789+0100]' to be included in the new version.", func(f *components.StringFlag) { f.Mandatory = false }),
98100
SourceTypeReleaseBundlesFlag: components.NewStringFlag(SourceTypeReleaseBundlesFlag, "List of semicolon-separated (;) release bundles in the form of 'name=releaseBundleName1, version=version1[, project-key=project1][, repo-key=repo1]; name=releaseBundleName2, version=version2[, project-key=project2][, repo-key=repo2]' to be included in the new version.", func(f *components.StringFlag) { f.Mandatory = false }),
99101
SourceTypeApplicationVersionsFlag: components.NewStringFlag(SourceTypeApplicationVersionsFlag, "List of semicolon-separated (;) application versions in the form of 'application-key=app1, version=version1; application-key=app2, version=version2' to be included in the new version.", func(f *components.StringFlag) { f.Mandatory = false }),
@@ -114,6 +116,7 @@ var commandFlags = map[string][]string{
114116
SyncFlag,
115117
TagFlag,
116118
DraftFlag,
119+
SkipUnassignedFlag,
117120
SourceTypeBuildsFlag,
118121
SourceTypeReleaseBundlesFlag,
119122
SourceTypeApplicationVersionsFlag,

apptrust/commands/version/create_app_version_cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func (cv *createAppVersionCommand) buildRequestPayload(ctx *components.Context)
8686
Sources: sources,
8787
Tag: ctx.GetStringFlagValue(commands.TagFlag),
8888
Draft: ctx.GetBoolFlagValue(commands.DraftFlag),
89+
SkipUnassigned: ctx.GetBoolFlagValue(commands.SkipUnassignedFlag),
8990
Filters: filters,
9091
}, nil
9192
}

apptrust/commands/version/create_app_version_cmd_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func TestCreateAppVersionCommand_FlagsSuite(t *testing.T) {
139139
ctx.Arguments = []string{"app-key", "1.0.0"}
140140
ctx.AddStringFlag(commands.TagFlag, "release-tag")
141141
ctx.AddBoolFlag(commands.DraftFlag, true)
142+
ctx.AddBoolFlag(commands.SkipUnassignedFlag, true)
142143
ctx.AddStringFlag(commands.SourceTypeBuildsFlag, "name=build1,id=1.0.0,include-deps=true,repo-key=build-info-repo,started=2024-01-15T10:30:00Z;name=build2,id=2.0.0,include-deps=false")
143144
ctx.AddStringFlag(commands.SourceTypeReleaseBundlesFlag, "name=rb1,version=1.0.0;name=rb2,version=2.0.0")
144145
ctx.AddStringFlag(commands.SourceTypeApplicationVersionsFlag, "application-key=source-app,version=3.2.1")
@@ -150,6 +151,7 @@ func TestCreateAppVersionCommand_FlagsSuite(t *testing.T) {
150151
Version: "1.0.0",
151152
Tag: "release-tag",
152153
Draft: true,
154+
SkipUnassigned: true,
153155
Sources: &model.CreateVersionSources{
154156
Builds: []model.CreateVersionBuild{
155157
{Name: "build1", Number: "1.0.0", IncludeDependencies: true, RepositoryKey: "build-info-repo", Started: "2024-01-15T10:30:00Z"},
@@ -173,6 +175,24 @@ func TestCreateAppVersionCommand_FlagsSuite(t *testing.T) {
173175
},
174176
},
175177
},
178+
{
179+
name: "skip-unassigned flag",
180+
ctxSetup: func(ctx *components.Context) {
181+
ctx.Arguments = []string{"app-key", "1.0.0"}
182+
ctx.AddBoolFlag(commands.SkipUnassignedFlag, true)
183+
ctx.AddStringFlag(commands.SourceTypePackagesFlag, "type=npm,name=pkg1,version=1.0.0,repo-key=repo1")
184+
},
185+
expectsPayload: &model.CreateAppVersionRequest{
186+
ApplicationKey: "app-key",
187+
Version: "1.0.0",
188+
SkipUnassigned: true,
189+
Sources: &model.CreateVersionSources{
190+
Packages: []model.CreateVersionPackage{
191+
{Type: "npm", Name: "pkg1", Version: "1.0.0", Repository: "repo1"},
192+
},
193+
},
194+
},
195+
},
176196
{
177197
name: "spec only",
178198
ctxSetup: func(ctx *components.Context) {

apptrust/common/keys.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var OrderedAppVersionKeys = []string{
88
"status",
99
"current_stage",
1010
"tag",
11+
"message",
1112
}
1213

1314
// OrderedAppKeys defines the display order for application table output

apptrust/model/create_app_version_request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type CreateAppVersionRequest struct {
66
Sources *CreateVersionSources `json:"sources,omitempty"`
77
Tag string `json:"tag,omitempty"`
88
Draft bool `json:"draft,omitempty"`
9+
SkipUnassigned bool `json:"skip_unassigned,omitempty"`
910
Filters *CreateVersionFilters `json:"filters,omitempty"`
1011
}
1112

0 commit comments

Comments
 (0)