Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Add a jaas_ prefix to the service name #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To remove the service after it completes, run with the `--remove` or `-r` flag:
```
# jaas run --image alexellis2/href-counter:latest --env url=http://blog.alexellis.io/

Service created: peaceful_shirley (uva6bcqyubm1b4c80dghjhb44)
Service created: jaas_peaceful_shirley (uva6bcqyubm1b4c80dghjhb44)
ID: uva6bcqyubm1b4c80dghjhb44 Update at: 2017-03-14 22:19:54.381973142 +0000 UTC
...

Expand All @@ -86,6 +86,8 @@ Printing service logs
Removing service...
```

To help you identify services created with jaas, the service name will be prefixed with jaas.

* Docker authentication for registries

You can use `jaas` with Docker images in private registries or registries which require authentication.
Expand Down
8 changes: 7 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/namesgenerator"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -127,7 +128,11 @@ func runTask(taskRequest TaskRequest) error {
spec.TaskTemplate.Placement = placement
}

createResponse, _ := c.ServiceCreate(context.Background(), spec, createOptions)
createResponse, err := c.ServiceCreate(context.Background(), spec, createOptions)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
opts := types.ServiceInspectOptions{InsertDefaults: true}

service, _, _ := c.ServiceInspectWithRaw(context.Background(), createResponse.ID, opts)
Expand All @@ -153,6 +158,7 @@ func makeSpec(image string, envVars []string) swarm.ServiceSpec {
},
},
}
spec.Name = "jaas_" + namesgenerator.GetRandomName(0)
return spec
}

Expand Down