Skip to content

Commit 2cbe025

Browse files
committed
cr
1 parent d3e3df2 commit 2cbe025

File tree

5 files changed

+11
-87
lines changed

5 files changed

+11
-87
lines changed

apptrust/commands/flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ var flagsMap = map[string]components.Flag{
9090
ExcludeReposFlag: components.NewStringFlag(ExcludeReposFlag, "Semicolon-separated list of repositories to exclude.", func(f *components.StringFlag) { f.Mandatory = false }),
9191
IncludeReposFlag: components.NewStringFlag(IncludeReposFlag, "Semicolon-separated list of repositories to include.", func(f *components.StringFlag) { f.Mandatory = false }),
9292
PropsFlag: components.NewStringFlag(PropsFlag, "Semicolon-separated list of properties in the form of 'key1=value1;key2=value2;...' to be added to each artifact.", func(f *components.StringFlag) { f.Mandatory = false }),
93-
TagFlag: components.NewStringFlag(TagFlag, "A tag to associate with the version. Must contain only alphanumeric characters, hyphens (-), underscores (_), and dots (.). Examples: 'release-1.2.3', 'v1.0.0', 'production_build'.", func(f *components.StringFlag) { f.Mandatory = false }),
93+
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 }),
9494
BuildsFlag: components.NewStringFlag(BuildsFlag, "List of builds in format 'name1:number1[:timestamp1];name2:number2[:timestamp2]'", func(f *components.StringFlag) { f.Mandatory = false }),
9595
ReleaseBundlesFlag: components.NewStringFlag(ReleaseBundlesFlag, "List of release bundles in format 'name1:version1;name2:version2'", func(f *components.StringFlag) { f.Mandatory = false }),
9696
SourceVersionFlag: components.NewStringFlag(SourceVersionFlag, "Source versions in format 'app1:version1;app2:version2'", func(f *components.StringFlag) { f.Mandatory = false }),
9797
PackagesFlag: components.NewStringFlag(PackagesFlag, "List of packages in format 'name1;name2'", func(f *components.StringFlag) { f.Mandatory = false }),
98-
PropertiesFlag: components.NewStringFlag(PropertiesFlag, "Set or update a property: 'key=val1[,val2,...]'", func(f *components.StringFlag) { f.Mandatory = false }),
98+
PropertiesFlag: components.NewStringFlag(PropertiesFlag, "Sets or updates custom properties for the application version in format 'key1=value1[,value2,...];key2=value3[,value4,...]'", func(f *components.StringFlag) { f.Mandatory = false }),
9999
DeletePropertyFlag: components.NewStringFlag(DeletePropertyFlag, "Remove a property key and all its values", func(f *components.StringFlag) { f.Mandatory = false }),
100100
}
101101

apptrust/commands/utils/utils.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ func ParseNameVersionPairs(input string) ([][2]string, error) {
137137
return result, nil
138138
}
139139

140-
// ParsePropertiesFlag parses a properties string into a map of keys to value slices.
140+
// ParseListPropertiesFlag parses a properties string into a map of keys to value slices.
141141
// Format: "key1=value1[,value2,...];key2=value3[,value4,...]"
142142
// Examples:
143143
// - "status=rc" -> {"status": ["rc"]}
144144
// - "status=rc,validated" -> {"status": ["rc", "validated"]}
145145
// - "status=rc;deployed_to=staging" -> {"status": ["rc"], "deployed_to": ["staging"]}
146146
// - "old_flag=" -> {"old_flag": []} (clears values)
147-
func ParsePropertiesFlag(propertiesStr string) (map[string][]string, error) {
147+
func ParseListPropertiesFlag(propertiesStr string) (map[string][]string, error) {
148148
if propertiesStr == "" {
149149
return nil, nil
150150
}
@@ -171,6 +171,9 @@ func ParsePropertiesFlag(propertiesStr string) (map[string][]string, error) {
171171
for i, v := range values {
172172
values[i] = strings.TrimSpace(v)
173173
}
174+
} else {
175+
// Return empty slice instead of nil for empty values
176+
values = []string{}
174177
}
175178
// Always set the key, even with empty values (to clear values)
176179
result[key] = values

apptrust/commands/utils/utils_test.go

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -197,82 +197,3 @@ func TestParseNameVersionPairs(t *testing.T) {
197197
})
198198
}
199199
}
200-
201-
func TestParsePropertiesFlag(t *testing.T) {
202-
tests := []struct {
203-
name string
204-
input string
205-
expected map[string][]string
206-
expectErr bool
207-
}{
208-
{
209-
name: "empty string",
210-
input: "",
211-
expected: nil,
212-
},
213-
{
214-
name: "single property with single value",
215-
input: "status=rc",
216-
expected: map[string][]string{
217-
"status": {"rc"},
218-
},
219-
},
220-
{
221-
name: "single property with multiple values",
222-
input: "status=rc,validated",
223-
expected: map[string][]string{
224-
"status": {"rc", "validated"},
225-
},
226-
},
227-
{
228-
name: "multiple properties",
229-
input: "status=rc,validated;deployed_to=staging-A,staging-B",
230-
expected: map[string][]string{
231-
"status": {"rc", "validated"},
232-
"deployed_to": {"staging-A", "staging-B"},
233-
},
234-
},
235-
{
236-
name: "empty values (clears values)",
237-
input: "old_feature_flag=",
238-
expected: map[string][]string{
239-
"old_feature_flag": nil,
240-
},
241-
},
242-
{
243-
name: "with spaces",
244-
input: " status = rc , validated ; deployed_to = staging-A , staging-B ",
245-
expected: map[string][]string{
246-
"status": {"rc", "validated"},
247-
"deployed_to": {"staging-A", "staging-B"},
248-
},
249-
},
250-
{
251-
name: "invalid format - missing =",
252-
input: "invalid-format",
253-
expectErr: true,
254-
},
255-
{
256-
name: "empty key",
257-
input: "=value",
258-
expectErr: true,
259-
},
260-
{
261-
name: "empty key with spaces",
262-
input: " =value",
263-
expectErr: true,
264-
},
265-
}
266-
267-
for _, tt := range tests {
268-
t.Run(tt.name, func(t *testing.T) {
269-
result, err := ParsePropertiesFlag(tt.input)
270-
if tt.expectErr {
271-
assert.Error(t, err)
272-
} else {
273-
assert.NoError(t, err)
274-
assert.Equal(t, tt.expected, result)
275-
}
276-
})
277-
}
278-
}

apptrust/commands/version/update_app_version_cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (uv *updateAppVersionCommand) buildRequestPayload(ctx *components.Context)
9696

9797
// Handle properties - use spec format: key=value1[,value2,...]
9898
if ctx.IsFlagSet(commands.PropertiesFlag) {
99-
properties, err := utils.ParsePropertiesFlag(ctx.GetStringFlagValue(commands.PropertiesFlag))
99+
properties, err := utils.ParseListPropertiesFlag(ctx.GetStringFlagValue(commands.PropertiesFlag))
100100
if err != nil {
101101
return nil, err
102102
}

apptrust/commands/version/update_app_version_cmd_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func TestUpdateAppVersionCommand_FlagsSuite(t *testing.T) {
163163
ApplicationKey: "app-key",
164164
Version: "1.0.0",
165165
Properties: map[string][]string{
166-
"old_feature_flag": nil,
166+
"old_feature_flag": {},
167167
},
168168
},
169169
},
@@ -292,7 +292,7 @@ func TestParseProperties(t *testing.T) {
292292
name: "empty values (clears values)",
293293
input: "old_feature_flag=",
294294
expected: map[string][]string{
295-
"old_feature_flag": nil,
295+
"old_feature_flag": {},
296296
},
297297
},
298298
{
@@ -322,7 +322,7 @@ func TestParseProperties(t *testing.T) {
322322

323323
for _, tt := range tests {
324324
t.Run(tt.name, func(t *testing.T) {
325-
result, err := utils.ParsePropertiesFlag(tt.input)
325+
result, err := utils.ParseListPropertiesFlag(tt.input)
326326
if tt.expectErr {
327327
assert.Error(t, err)
328328
} else {

0 commit comments

Comments
 (0)