Skip to content

Commit 319f153

Browse files
author
Quentin Perez
committed
Merge pull request #140 from moul/patch-tags
Support of 'scw _patch SERVER tags="tag1 tag2 tag3"'
2 parents 894b9fe + 88fceeb commit 319f153

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
11281128

11291129
#### Features
11301130

1131+
* Support of `_patch SERVER tags="tag1 tag2=value2 tag3"`
11311132
* `scw -D login` displays a fake password
11321133
* Support --skip-ssh-key `scw login` ([#129](https://github.com/scaleway/scaleway-cli/issues/129))
11331134
* Now `scw login` ask your login/password, you can also pass token and organization with -o and -t ([#59](https://github.com/scaleway/scaleway-cli/issues/59))

pkg/api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ type ScalewayServerPatchDefinition struct {
449449
Volumes *map[string]ScalewayVolume `json:"volumes,omitempty"`
450450
SecurityGroup *ScalewaySecurityGroup `json:"security_group,omitempty"`
451451
Organization *string `json:"organization,omitempty"`
452-
//Tags *[]string `json:"tags,omitempty"`
452+
Tags *[]string `json:"tags,omitempty"`
453453
}
454454

455455
// ScalewayServerDefinition represents a Scaleway C1 server with image definition

pkg/cli/x_patch.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func runPatch(cmd *Command, args []string) error {
4141
}
4242

4343
// Parsing FIELD=VALUE
44-
updateParts := strings.Split(args[1], "=")
44+
updateParts := strings.SplitN(args[1], "=", 2)
4545
if len(updateParts) != 2 {
4646
cmd.PrintShortUsage()
4747
}
@@ -86,6 +86,12 @@ func runPatch(cmd *Command, args []string) error {
8686
changes++
8787
payload.SecurityGroup.Identifier = newValue
8888
}
89+
case "tags":
90+
newTags := strings.Split(newValue, " ")
91+
log.Debugf("%s=%s => %s=%s", fieldName, currentServer.Tags, fieldName, newTags)
92+
// fixme test equality with reflect.DeepEqual ?
93+
changes++
94+
payload.Tags = &newTags
8995
default:
9096
log.Fatalf("'_patch server %s=' not implemented", fieldName)
9197
}

0 commit comments

Comments
 (0)