aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2017-01-27 09:27:55 -0800
committerChristine Dodrill <me@christine.website>2017-01-27 09:27:55 -0800
commite76391cba2196c321852437462e14893057b40b8 (patch)
tree516e989c4b0118552399037dec79e8f890e99fd8
parent2d1c87705e02d78b7d5dafbac1d7d11f8fb3a336 (diff)
downloadx-e76391cba2196c321852437462e14893057b40b8.tar.xz
x-e76391cba2196c321852437462e14893057b40b8.zip
svc: implement update
-rw-r--r--svc/cmd/svc/main.go31
-rw-r--r--svc/cmd/svcd/dockerswarm-svcd/main.go5
2 files changed, 26 insertions, 10 deletions
diff --git a/svc/cmd/svc/main.go b/svc/cmd/svc/main.go
index 58e620a..3d72e1e 100644
--- a/svc/cmd/svc/main.go
+++ b/svc/cmd/svc/main.go
@@ -66,15 +66,13 @@ var (
listLabelKey = list.Flag("labelKey", "label key to match for").String()
listLabelValue = list.Flag("labelValue", "label value to match for (with labelKey)").String()
- update = app.Command("update", "Update an application")
- updateImage = update.Flag("image", "new docker image to use for this service").String()
- updateEnvAdd = update.Flag("env-add", "new environment variables to set").StringMap()
- updateEnvRm = update.Flag("env-rm", "environment variables to remove").StringMap()
- updateLabelAdd = update.Flag("label-add", "container labels to addB").StringMap()
- updateLabelRm = update.Flag("label-rm", "container labels to remove").StringMap()
- updateGrantUsers = update.Flag("grant-user", "grant a user permission to this service").Strings()
- updateRevokeUsers = update.Flag("revoke-user", "revoke a user's permission to this service").Strings()
- updateInstanceCount = update.Flag("instances", "updates the instance count of the service").Int()
+ update = app.Command("update", "Update an application")
+ updateImage = update.Flag("image", "new docker image to use for this service").String()
+ updateEnvAdd = update.Flag("env-add", "new environment variables to set").StringMap()
+ updateEnvRm = update.Flag("env-rm", "environment variables to remove").Strings()
+ updateGrantUsers = update.Flag("grant-user", "grant a user permission to this service").Strings()
+ updateRevokeUsers = update.Flag("revoke-user", "revoke a user's permission to this service").Strings()
+ updateName = update.Flag("name", "name of the service to update").Required().String()
)
func main() {
@@ -238,7 +236,20 @@ func main() {
log.Printf("%s created", app.Name)
return
case update.FullCommand():
- log.Println("update not implemented")
+ _, err := c.Update(context.Background(), &svc.AppUpdate{
+ Name: *updateName,
+ NewImage: *updateImage,
+ EnvAdd: *updateEnvAdd,
+ EnvRm: *updateEnvRm,
+ GrantUsers: *updateGrantUsers,
+ RevokeUsers: *updateRevokeUsers,
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ log.Println("success")
+ return
case inspect.FullCommand():
app, err := c.Inspect(context.Background(), &svc.AppInspect{
Name: *inspectName,
diff --git a/svc/cmd/svcd/dockerswarm-svcd/main.go b/svc/cmd/svcd/dockerswarm-svcd/main.go
index c69782b..bc22ec0 100644
--- a/svc/cmd/svcd/dockerswarm-svcd/main.go
+++ b/svc/cmd/svcd/dockerswarm-svcd/main.go
@@ -188,6 +188,11 @@ func (s *server) Create(ctx context.Context, manifest *svc.Manifest) (*svc.App,
}
func (s *server) Update(ctx context.Context, params *svc.AppUpdate) (*svc.App, error) {
+ user, err := s.checkAuth(ctx)
+ if err != nil {
+ return nil, err
+ }
+
au := s.state[params.Name]
if au == nil {
s.state[params.Name] = []string{admin}