Skip to content

Commit dd85aba

Browse files
authored
Merge pull request #79 from latitudesh/fix/create-server-with-json
fix: project id on server creation
2 parents a894a5d + 6f8d15e commit dd85aba

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

cli/create_server_operation.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ func fetchUserProjects() []string {
167167
if proj.Attributes != nil && proj.Attributes.Name != nil {
168168
userProjects = append(userProjects, *proj.Attributes.Name)
169169
}
170+
if proj.ID != nil {
171+
userProjects = append(userProjects, *proj.ID)
172+
}
170173
}
171174
}
172175

internal/utils/json_value.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ func AssignValue(obj interface{}, jsonName string, value interface{}) {
1313

1414
// Prepare for user passing project Name instead of Slug.
1515
if jsonName == "project" {
16-
parametrizedProject := strings.ToLower(strings.Replace(valueToSet.String(), " ", "-", -1))
17-
valueToSet = reflect.ValueOf(parametrizedProject)
16+
projectValue := valueToSet.String()
17+
18+
if !strings.HasPrefix(projectValue, "proj_") {
19+
parametrizedProject := strings.ToLower(strings.Replace(projectValue, " ", "-", -1))
20+
valueToSet = reflect.ValueOf(parametrizedProject)
21+
}
1822
}
1923

2024
fieldValue.Set(valueToSet)

0 commit comments

Comments
 (0)