Skip to content

Commit

Permalink
bugfix: specifying confusing instance names
Browse files Browse the repository at this point in the history
Closes #763
  • Loading branch information
GRISHNOV committed Apr 19, 2023
1 parent 80f0f63 commit a0670f6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
17 changes: 0 additions & 17 deletions cli/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,6 @@ func GetInstancesFromArgs(args []string, projectName string) ([]string, error) {
var instances []string

for _, instanceName := range args {
if instanceName == projectName {
return nil, fmt.Errorf(appNameSpecifiedError)
}

parts := strings.SplitN(instanceName, ".", 2)

if len(parts) > 1 {
return nil, fmt.Errorf(instanceIDSpecified)
}

if instanceName == "stateboard" {
return nil, fmt.Errorf("Please, specify flag --stateboard for processing stateboard instance")
}
Expand Down Expand Up @@ -579,10 +569,3 @@ func ParseDependencies(rawDeps []string) (PackDependencies, error) {
func ContainsUpperSymbols(src string) bool {
return strings.ToLower(src) != src
}

const (
appNameSpecifiedError = "Application name is specified. " +
"Please, specify instance name(s)"
instanceIDSpecified = `[APP_NAME].INSTANCE_NAME is specified. ` +
"Please, specify instance name(s)"
)
22 changes: 0 additions & 22 deletions cli/common/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,6 @@ func TestGetInstancesFromArgs(t *testing.T) {

projectName := "myapp"

// wrong format
args = []string{"myapp.instance-1", "myapp.instance-2"}
_, err = GetInstancesFromArgs(args, projectName)
assert.EqualError(err, instanceIDSpecified)

args = []string{"instance-1", "myapp.instance-2"}
_, err = GetInstancesFromArgs(args, projectName)
assert.EqualError(err, instanceIDSpecified)

args = []string{"myapp"}
_, err = GetInstancesFromArgs(args, projectName)
assert.True(strings.Contains(err.Error(), appNameSpecifiedError))

// duplicate instance name
args = []string{"instance-1", "instance-1"}
_, err = GetInstancesFromArgs(args, projectName)
Expand All @@ -139,15 +126,6 @@ func TestGetInstancesFromArgs(t *testing.T) {
instances, err = GetInstancesFromArgs(args, projectName)
assert.Nil(err)
assert.Equal([]string{"instance-1", "instance-2"}, instances)

// specified both app name and instance name
args = []string{"instance-1", "myapp"}
instances, err = GetInstancesFromArgs(args, projectName)
assert.EqualError(err, appNameSpecifiedError)

args = []string{"myapp", "instance-1"}
instances, err = GetInstancesFromArgs(args, projectName)
assert.EqualError(err, appNameSpecifiedError)
}

func TestCorrectDependencyParsing(t *testing.T) {
Expand Down

0 comments on commit a0670f6

Please sign in to comment.