Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit ab2af78

Browse files
aashir21eamansour
andauthored
CLI now returns and filter test on group name (#321)
* CLI now returns and filter test on group name Signed-off-by: Aashir Siddiqui <[email protected]> * Added validation for group name Signed-off-by: Aashir Siddiqui <[email protected]> * Added unit test Signed-off-by: Aashir Siddiqui <[email protected]> * Added a unit test for checking mutually exclusive flags Signed-off-by: Aashir Siddiqui <[email protected]> * Updated integration tests Signed-off-by: Aashir Siddiqui <[email protected]> * review: Formatting fixes, revert unwanted changes Signed-off-by: Eamonn Mansour <[email protected]> * review: Add group validation, stop erroring out when --age is not given with --group Signed-off-by: Eamonn Mansour <[email protected]> * Restore ecosystem script constants and add group name validation test Signed-off-by: Eamonn Mansour <[email protected]> * Add group to more unit tests Signed-off-by: Eamonn Mansour <[email protected]> * Add group to runs submit output, add runs get --group ecosystem tests Signed-off-by: Eamonn Mansour <[email protected]> * Empty commit to kick off build Signed-off-by: Eamonn Mansour <[email protected]> * Create RunsQuery struct to store run query parameters and get pages of runs Signed-off-by: Eamonn Mansour <[email protected]> * Replace Latin-1 validation for group and secret names with alphanumeric + dashes and underscores Signed-off-by: Eamonn Mansour <[email protected]> * Update role name validation to use common name validation function Signed-off-by: Eamonn Mansour <[email protected]> --------- Signed-off-by: Aashir Siddiqui <[email protected]> Signed-off-by: Eamonn Mansour <[email protected]> Co-authored-by: Eamonn Mansour <[email protected]>
1 parent e486b86 commit ab2af78

33 files changed

+757
-481
lines changed

docs/generated/errors-list.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The `galasactl` tool can generate the following errors:
7979
- GAL1076E: Badly formed from or to value '{}' specified in the age parameter. The value could not be converted into an integer value.
8080
- GAL1077E: Invalid value '{}' detected for age parameter. The 'from' value must be greater than the 'to' value.
8181
- GAL1078E: Badly formed '--age' parameter value '{}' specified. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be {}. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference/cli-commands.
82-
- GAL1079E: The --age or the --name parameter must be used to identify which test run(s) you want see. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference/cli-commands.
82+
- GAL1079E: The --age, --name, or --group parameter must be used to identify which test run(s) you want see. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference/cli-commands.
8383
- GAL1080E: Invalid 'from' value '{}' in the '--age' parameter. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be {}. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference/cli-commands.
8484
- GAL1081E: Unable use a negative value '{}' in the '--age' parameter. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be {}. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference/cli-commands.
8585
- GAL1082E: Invalid time unit specified '{}' in the '--age' parameter. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be {}. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference/cli-commands.
@@ -105,6 +105,7 @@ The `galasactl` tool can generate the following errors:
105105
- GAL1102E: name '{}' is invalid. '--name' is a mandatory flag for this command. Use the --help flag for more information, or refer to the documentation at https://galasa.dev/docs/reference/cli-commands.
106106
- GAL1103E: Could not query CPS results. Reason: '{}'
107107
- GAL1104E: Unable to delete the bearer token file '{}'.
108+
- GAL1105E: Invalid group name provided. Group names must only contain characters in the following ranges: 'a'-'z', 'A'-'Z', '0'-'9', '-' (dash), '_' (underscore).
108109
- GAL1106E: Could not get security bearer token from API server. Reason: '{}'. Ensure you have allocated a personal access token and configured your client program by setting your GALASA_TOKEN as an environment variable or by storing it in your galasactl.properties file
109110
- GAL1107E: Could not get security bearer token from file '{}'. Reason: '{}'. Ensure you are authenticated by running 'galasactl auth login' and that your personal access token has not expired or been revoked
110111
- GAL1108E: Invalid bearer token. Ensure you are authenticated by running 'galasactl auth login' and that your personal access token has not expired or been revoked
@@ -167,7 +168,7 @@ The `galasactl` tool can generate the following errors:
167168
- GAL1169E: An attempt to delete a secret named '{}' failed. Unexpected http status code {} received from the server. Error details from the server are not in a valid json format. Cause: '{}'
168169
- GAL1170E: An attempt to delete a secret named '{}' failed. Unexpected http status code {} received from the server. Error details from the server are: '{}'
169170
- GAL1171E: An attempt to delete a secret named '{}' failed. Unexpected http status code {} received from the server. Error details from the server are not in the json format.
170-
- GAL1172E: Invalid secret name provided. The name provided with the --name flag cannot be empty, contain spaces or dots (.), and must only contain characters in the Latin-1 character set.
171+
- GAL1172E: Invalid secret name provided. The name provided with the --name flag cannot be empty and must only contain characters in the following ranges: 'a'-'z', 'A'-'Z', '0'-'9', '-' (dash), '_' (underscore).
171172
- GAL1173E: An attempt to delete a secret named '{}' failed. Sending the delete request to the Galasa service failed. Cause is {}
172173
- GAL1174E: An attempt to get a secret named '{}' failed. Unexpected http status code {} received from the server.
173174
- GAL1175E: An attempt to get a secret named '{}' failed. Unexpected http status code {} received from the server. Error details from the server could not be read. Cause: {}
@@ -204,7 +205,7 @@ The `galasactl` tool can generate the following errors:
204205
- GAL1206E: Failed to get roles. Unexpected http status code {} received from the server. Error details from the server are not in a valid json format. Cause: '{}'
205206
- GAL1207E: Failed to get roles. Unexpected http status code {} received from the server. Error details from the server are: '{}'
206207
- GAL1208E: Failed to get roles. Unexpected http status code {} received from the server. Error details from the server are not in the json format.
207-
- GAL1209E: Invalid role name provided. The name provided with the --name flag cannot be empty, contain spaces or dots (.), and must only contain characters in the Latin-1 character set.
208+
- GAL1209E: Invalid role name provided. The name provided with the --name flag cannot be empty and must only contain characters in the following ranges: 'a'-'z', 'A'-'Z', '0'-'9', '-' (dash), '_' (underscore).
208209
- GAL1210E: Role name {} is not known on the Galasa service.
209210
- GAL1225E: Failed to open file '{}' cause: {}. Check that this file exists, and that you have read permissions.
210211
- GAL1226E: Internal failure. Contents of gzip could be read, but not decoded. New gzip reader failed: file: {} error: {}

docs/generated/galasactl_runs_get.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ galasactl runs get [flags]
1616
--active parameter to retrieve runs that have not finished yet. Cannot be used in conjunction with --name or --result flag.
1717
--age string the age of the test run(s) we want information about. Supported formats are: 'FROM' or 'FROM:TO', where FROM and TO are each ages, made up of an integer and a time-unit qualifier. Supported time-units are 'w' (weeks), 'd' (days), 'h' (hours), 'm' (minutes). If missing, the TO part is defaulted to '0h'. Examples: '--age 1d', '--age 6h:1h' (list test runs which happened from 6 hours ago to 1 hour ago). The TO part must be a smaller time-span than the FROM part.
1818
--format string output format for the data returned. Supported formats are: 'details', 'raw', 'summary'. (default "summary")
19+
--group string the name of the group to return tests under that group. Cannot be used in conjunction with --name
1920
-h, --help Displays the options for the 'runs get' command.
2021
--name string the name of the test run we want information about. Cannot be used in conjunction with --requestor, --result or --active flags
2122
--requestor string the requestor of the test run we want information about. Cannot be used in conjunction with --name flag.

pkg/cmd/runsGet.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type RunsGetCmdValues struct {
2828
requestor string
2929
result string
3030
isActiveRuns bool
31+
group string
3132
}
3233

3334
type RunsGetCommand struct {
@@ -93,6 +94,8 @@ func (cmd *RunsGetCommand) createCobraCommand(
9394
formatters := runs.GetFormatterNamesString(runs.CreateFormatters())
9495
runsGetCobraCmd.PersistentFlags().StringVar(&cmd.values.runName, "name", "", "the name of the test run we want information about."+
9596
" Cannot be used in conjunction with --requestor, --result or --active flags")
97+
runsGetCobraCmd.PersistentFlags().StringVar(&cmd.values.group, "group", "", "the name of the group to return tests under that group."+
98+
" Cannot be used in conjunction with --name")
9699
runsGetCobraCmd.PersistentFlags().StringVar(&cmd.values.age, "age", "", "the age of the test run(s) we want information about. Supported formats are: 'FROM' or 'FROM:TO', where FROM and TO are each ages,"+
97100
" made up of an integer and a time-unit qualifier. Supported time-units are "+units+". If missing, the TO part is defaulted to '0h'. Examples: '--age 1d',"+
98101
" '--age 6h:1h' (list test runs which happened from 6 hours ago to 1 hour ago)."+
@@ -109,6 +112,7 @@ func (cmd *RunsGetCommand) createCobraCommand(
109112
runsGetCobraCmd.MarkFlagsMutuallyExclusive("name", "result")
110113
runsGetCobraCmd.MarkFlagsMutuallyExclusive("name", "active")
111114
runsGetCobraCmd.MarkFlagsMutuallyExclusive("result", "active")
115+
runsGetCobraCmd.MarkFlagsMutuallyExclusive("group", "name")
112116

113117
runsCommand.CobraCommand().AddCommand(runsGetCobraCmd)
114118

@@ -165,6 +169,7 @@ func (cmd *RunsGetCommand) executeRunsGet(
165169
cmd.values.result,
166170
cmd.values.isActiveRuns,
167171
cmd.values.outputFormatString,
172+
cmd.values.group,
168173
timeService,
169174
console,
170175
apiServerUrl,

pkg/cmd/runsGet_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ func TestRunsGetNameFlagReturnsOk(t *testing.T) {
135135
assert.Contains(t, cmd.Values().(*RunsGetCmdValues).runName, "gerald")
136136
}
137137

138+
func TestRunsGetGroupFlagReturnsOk(t *testing.T) {
139+
// Given...
140+
factory := utils.NewMockFactory()
141+
commandCollection, cmd := setupTestCommandCollection(COMMAND_NAME_RUNS_GET, factory, t)
142+
143+
var args []string = []string{"runs", "get", "--group", "someGroup"}
144+
145+
// When...
146+
err := commandCollection.Execute(args)
147+
148+
// Then...
149+
assert.Nil(t, err)
150+
151+
// Check what the user saw was reasonable
152+
checkOutput("", "", factory, t)
153+
154+
assert.Contains(t, cmd.Values().(*RunsGetCmdValues).group, "someGroup")
155+
}
156+
138157
func TestRunsGetageFlagReturnsOk(t *testing.T) {
139158
// Given...
140159
factory := utils.NewMockFactory()
@@ -297,3 +316,20 @@ func TestRunsGetResultActiveMutuallyExclusive(t *testing.T) {
297316
// Check what the user saw is reasonable.
298317
checkOutput("", "Error: if any flags in the group [result active] are set none of the others can be; [active result] were all set", factory, t)
299318
}
319+
320+
func TestRunsGetGroupRunNameMutuallyExclusive(t *testing.T) {
321+
// Given...
322+
factory := utils.NewMockFactory()
323+
324+
var args []string = []string{"runs", "get", "--group", "group-1", "--name", "CV123"}
325+
326+
// When...
327+
err := Execute(factory, args)
328+
329+
// Then...
330+
assert.NotNil(t, err)
331+
assert.Contains(t, err.Error(), "if any flags in the group [group name] are set none of the others can be; [group name] were all set")
332+
333+
// Check what the user saw is reasonable.
334+
checkOutput("", "Error: if any flags in the group [group name] are set none of the others can be; [group name] were all set", factory, t)
335+
}

pkg/errors/errorMessage.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ var (
241241
GALASA_ERROR_INVALID_FROM_OR_TO_PARAMETER = NewMessageType("GAL1076E: Badly formed from or to value '%s' specified in the age parameter. The value could not be converted into an integer value.", 1076, STACK_TRACE_NOT_WANTED)
242242
GALASA_ERROR_FROM_AGE_SMALLER_THAN_TO_AGE = NewMessageType("GAL1077E: Invalid value '%s' detected for age parameter. The 'from' value must be greater than the 'to' value.", 1077, STACK_TRACE_NOT_WANTED)
243243
GALASA_ERROR_INVALID_AGE_PARAMETER = NewMessageType("GAL1078E: Badly formed '--age' parameter value '%s' specified. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be %s. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified."+SEE_COMMAND_REFERENCE, 1078, STACK_TRACE_NOT_WANTED)
244-
GALASA_ERROR_NO_RUNNAME_OR_AGE_SPECIFIED = NewMessageType("GAL1079E: The --age or the --name parameter must be used to identify which test run(s) you want see."+SEE_COMMAND_REFERENCE, 1079, STACK_TRACE_NOT_WANTED)
244+
GALASA_ERROR_NO_TEST_RUN_IDENTIFIER_FLAG_SPECIFIED = NewMessageType("GAL1079E: The --age, --name, or --group parameter must be used to identify which test run(s) you want see."+SEE_COMMAND_REFERENCE, 1079, STACK_TRACE_NOT_WANTED)
245245
GALASA_ERROR_INVALID_FROM_AGE_SPECIFIED = NewMessageType("GAL1080E: Invalid 'from' value '%s' in the '--age' parameter. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be %s. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified."+SEE_COMMAND_REFERENCE, 1080, STACK_TRACE_NOT_WANTED)
246246
GALASA_ERROR_NEGATIVE_AGE_SPECIFIED = NewMessageType("GAL1081E: Unable use a negative value '%s' in the '--age' parameter. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be %s. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified."+SEE_COMMAND_REFERENCE, 1081, STACK_TRACE_NOT_WANTED)
247247
GALASA_ERROR_BAD_TIME_UNIT_AGE_SPECIFIED = NewMessageType("GAL1082E: Invalid time unit specified '%s' in the '--age' parameter. Age of the test runs should be specified in the format '{FROM}{TIME-UNIT}:{TO}{TIME-UNIT}' or '{FROM}{TIME-UNIT}', where 'FROM' is a positive, non-zero integer, 'TO' is a non-negative integer, and 'TIME-UNIT' can be %s. 'FROM' must be greater than 'TO'. 'TO' defaults to 0 if not specified."+SEE_COMMAND_REFERENCE, 1082, STACK_TRACE_NOT_WANTED)
@@ -268,6 +268,7 @@ var (
268268
GALASA_ERROR_MISSING_NAME_FLAG = NewMessageType("GAL1102E: name '%s' is invalid. '--name' is a mandatory flag for this command."+SEE_COMMAND_REFERENCE, 1102, STACK_TRACE_WANTED)
269269
GALASA_ERROR_QUERY_CPS_FAILED = NewMessageType("GAL1103E: Could not query CPS results. Reason: '%s'", 1103, STACK_TRACE_WANTED)
270270
GALASA_ERROR_UNABLE_TO_DELETE_BEARER_TOKEN_FILE = NewMessageType("GAL1104E: Unable to delete the bearer token file '%s'.", 1104, STACK_TRACE_NOT_WANTED)
271+
GALASA_ERROR_INVALID_GROUP_NAME_PROVIDED = NewMessageType("GAL1105E: Invalid group name provided. Group names must only contain characters in the following ranges: 'a'-'z', 'A'-'Z', '0'-'9', '-' (dash), '_' (underscore).", 1105, STACK_TRACE_NOT_WANTED)
271272
GALASA_ERROR_RETRIEVING_BEARER_TOKEN_FROM_API_SERVER = NewMessageType("GAL1106E: Could not get security bearer token from API server. Reason: '%s'. Ensure you have allocated a personal access token and configured your client program by setting your GALASA_TOKEN as an environment variable or by storing it in your galasactl.properties file", 1106, STACK_TRACE_WANTED)
272273
GALASA_ERROR_RETRIEVING_BEARER_TOKEN_FROM_FILE = NewMessageType("GAL1107E: Could not get security bearer token from file '%s'. Reason: '%s'. Ensure you are authenticated by running 'galasactl auth login' and that your personal access token has not expired or been revoked", 1107, STACK_TRACE_NOT_WANTED)
273274
GALASA_ERROR_INVALID_BEARER_TOKEN = NewMessageType("GAL1108E: Invalid bearer token. Ensure you are authenticated by running 'galasactl auth login' and that your personal access token has not expired or been revoked", 1108, STACK_TRACE_NOT_WANTED)
@@ -345,7 +346,7 @@ var (
345346
GALASA_ERROR_DELETE_SECRET_UNPARSEABLE_CONTENT = NewMessageType("GAL1169E: An attempt to delete a secret named '%s' failed. Unexpected http status code %v received from the server. Error details from the server are not in a valid json format. Cause: '%s'", 1169, STACK_TRACE_NOT_WANTED)
346347
GALASA_ERROR_DELETE_SECRET_SERVER_REPORTED_ERROR = NewMessageType("GAL1170E: An attempt to delete a secret named '%s' failed. Unexpected http status code %v received from the server. Error details from the server are: '%s'", 1170, STACK_TRACE_NOT_WANTED)
347348
GALASA_ERROR_DELETE_SECRET_EXPLANATION_NOT_JSON = NewMessageType("GAL1171E: An attempt to delete a secret named '%s' failed. Unexpected http status code %v received from the server. Error details from the server are not in the json format.", 1171, STACK_TRACE_NOT_WANTED)
348-
GALASA_ERROR_INVALID_SECRET_NAME = NewMessageType("GAL1172E: Invalid secret name provided. The name provided with the --name flag cannot be empty, contain spaces or dots (.), and must only contain characters in the Latin-1 character set.", 1172, STACK_TRACE_NOT_WANTED)
349+
GALASA_ERROR_INVALID_SECRET_NAME = NewMessageType("GAL1172E: Invalid secret name provided. The name provided with the --name flag cannot be empty and must only contain characters in the following ranges: 'a'-'z', 'A'-'Z', '0'-'9', '-' (dash), '_' (underscore).", 1172, STACK_TRACE_NOT_WANTED)
349350
GALASA_ERROR_DELETE_SECRET_REQUEST_FAILED = NewMessageType("GAL1173E: An attempt to delete a secret named '%s' failed. Sending the delete request to the Galasa service failed. Cause is %v", 1173, STACK_TRACE_NOT_WANTED)
350351

351352
GALASA_ERROR_GET_SECRET_NO_RESPONSE_CONTENT = NewMessageType("GAL1174E: An attempt to get a secret named '%s' failed. Unexpected http status code %v received from the server.", 1174, STACK_TRACE_NOT_WANTED)
@@ -390,7 +391,7 @@ var (
390391
GALASA_ERROR_GET_ROLES_EXPLANATION_NOT_JSON = NewMessageType("GAL1208E: Failed to get roles. Unexpected http status code %v received from the server. Error details from the server are not in the json format.", 1208, STACK_TRACE_NOT_WANTED)
391392

392393
// When getting a single named role...
393-
GALASA_ERROR_INVALID_ROLE_NAME = NewMessageType("GAL1209E: Invalid role name provided. The name provided with the --name flag cannot be empty, contain spaces or dots (.), and must only contain characters in the Latin-1 character set.", 1209, STACK_TRACE_NOT_WANTED)
394+
GALASA_ERROR_INVALID_ROLE_NAME = NewMessageType("GAL1209E: Invalid role name provided. The name provided with the --name flag cannot be empty and must only contain characters in the following ranges: 'a'-'z', 'A'-'Z', '0'-'9', '-' (dash), '_' (underscore).", 1209, STACK_TRACE_NOT_WANTED)
394395
GALASA_ERROR_ROLE_NAME_NOT_FOUND = NewMessageType("GAL1210E: Role name %v is not known on the Galasa service.", 1210, STACK_TRACE_NOT_WANTED)
395396

396397
// Warnings...

pkg/roles/roles.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,15 @@ import (
99
"strings"
1010

1111
galasaErrors "github.com/galasa-dev/cli/pkg/errors"
12+
"github.com/galasa-dev/cli/pkg/utils"
1213
)
1314

1415
func validateRoleName(nameToValidate string) (string, error) {
1516
var err error
1617
name := strings.TrimSpace(nameToValidate)
1718

18-
if name == "" || !usesValidRoleCharacters(name) {
19+
if name == "" || !utils.IsNameValid(name) {
1920
err = galasaErrors.NewGalasaError(galasaErrors.GALASA_ERROR_INVALID_ROLE_NAME)
2021
}
2122
return name, err
2223
}
23-
24-
// Checks if a given string contains only characters in the Latin-1 character set (codepoints 0-255),
25-
// returning true if so, and false otherwise
26-
func usesValidRoleCharacters(str string) bool {
27-
isValidLatin1 := true
28-
for _, character := range str {
29-
if !((character >= 'a' && character <= 'z') ||
30-
(character >= 'A' && character <= 'Z') ||
31-
(character >= '0' && character <= '9')) {
32-
isValidLatin1 = false
33-
break
34-
}
35-
}
36-
return isValidLatin1
37-
}

pkg/runs/groups.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright contributors to the Galasa project
3+
*
4+
* SPDX-License-Identifier: EPL-2.0
5+
*/
6+
package runs
7+
8+
import (
9+
"strings"
10+
11+
galasaErrors "github.com/galasa-dev/cli/pkg/errors"
12+
"github.com/galasa-dev/cli/pkg/utils"
13+
)
14+
15+
func validateGroupname(groupName string) (string, error) {
16+
var err error
17+
trimmedName := strings.TrimSpace(groupName)
18+
19+
if trimmedName == "" || !utils.IsNameValid(trimmedName) {
20+
err = galasaErrors.NewGalasaError(galasaErrors.GALASA_ERROR_INVALID_GROUP_NAME_PROVIDED)
21+
}
22+
return trimmedName, err
23+
}

0 commit comments

Comments
 (0)