Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 98b829a

Browse files
committed
Rename --prefix and repository_prefix to namespace
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent ecf93d5 commit 98b829a

12 files changed

Lines changed: 47 additions & 45 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ It should look like this:
4646
version: 0.1.0
4747
name: hello
4848
description: ""
49-
repository_prefix: ""
49+
namespace: ""
5050
maintainers:
5151
- name: yourusername
5252
email: ""
@@ -180,14 +180,14 @@ the `docker-app init` command. This will create a directory instead of a singe f
180180
You can push any application to the Hub using `docker-app push`:
181181

182182
``` bash
183-
$ docker-app push --prefix myHubUser --tag latest
183+
$ docker-app push --namespace myHubUser --tag latest
184184
```
185185

186186
This command will create an image named `myHubUser/hello.dockerapp:latest` on your local Docker
187187
daemon, and push it to the Hub.
188188

189189
By default, this command uses the application version defined in `metadata.yml` as the tag,
190-
and the value of the metadata field `repository_prefix` as the repository prefix.
190+
and the value of the metadata field `namespace` as the image namespace.
191191

192192
All `docker-app` commands accept a local image name as input, which means you can run on a different host:
193193

cmd/docker-app/push.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@ import (
66
"github.com/spf13/cobra"
77
)
88

9-
var (
10-
pushPrefix string
11-
pushTag string
12-
)
9+
type pushOptions struct {
10+
namespace string
11+
tag string
12+
}
1313

1414
func pushCmd() *cobra.Command {
15+
var opts pushOptions
1516
cmd := &cobra.Command{
1617
Use: "push [<app-name>]",
1718
Short: "Push the application to a registry",
1819
Args: cli.RequiresMaxArgs(1),
1920
RunE: func(cmd *cobra.Command, args []string) error {
20-
return packager.Push(firstOrEmpty(args), pushPrefix, pushTag)
21+
return packager.Push(firstOrEmpty(args), opts.namespace, opts.tag)
2122
},
2223
}
23-
cmd.Flags().StringVarP(&pushPrefix, "prefix", "p", "", "repository prefix to use (default: repository_prefix in metadata)")
24-
cmd.Flags().StringVarP(&pushTag, "tag", "t", "", "tag to use (default: version in metadata")
24+
cmd.Flags().StringVar(&opts.namespace, "namespace", "", "namespace to use (default: namespace in metadata)")
25+
cmd.Flags().StringVarP(&opts.tag, "tag", "t", "", "tag to use (default: version in metadata")
2526
return cmd
2627
}

cmd/docker-app/save.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,26 @@ import (
88
"github.com/spf13/cobra"
99
)
1010

11-
var (
12-
savePrefix string
13-
saveTag string
14-
)
11+
type saveOptions struct {
12+
namespace string
13+
tag string
14+
}
1515

1616
func saveCmd() *cobra.Command {
17+
var opts saveOptions
1718
cmd := &cobra.Command{
1819
Use: "save [<app-name>]",
1920
Short: "Save the application as an image to the docker daemon(in preparation for push)",
2021
Args: cli.RequiresMaxArgs(1),
2122
RunE: func(cmd *cobra.Command, args []string) error {
22-
imageName, err := packager.Save(firstOrEmpty(args), savePrefix, saveTag)
23+
imageName, err := packager.Save(firstOrEmpty(args), opts.namespace, opts.tag)
2324
if imageName != "" {
2425
fmt.Printf("Saved application as image: %s\n", imageName)
2526
}
2627
return err
2728
},
2829
}
29-
cmd.Flags().StringVarP(&savePrefix, "prefix", "p", "", "repository prefix to use (default: repository_prefix in metadata)")
30-
cmd.Flags().StringVarP(&saveTag, "tag", "t", "", "tag to use (default: version in metadata)")
30+
cmd.Flags().StringVar(&opts.namespace, "namespace", "", "namespace to use (default: namespace in metadata)")
31+
cmd.Flags().StringVarP(&opts.tag, "tag", "t", "", "tag to use (default: version in metadata)")
3132
return cmd
3233
}

e2e/binary_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ version: 0.1.0
204204
name: app_test
205205
# A short description of the application
206206
description: my cool app
207-
# Repository prefix to use when pushing to a registry. This is typically your Hub username.
208-
#repository_prefix: myHubUsername
207+
# Namespace to use when pushing to a registry. This is typically your Hub username.
208+
#namespace: myHubUsername
209209
# List of application maitainers with name and email for each
210210
maintainers:
211211
- name: bob
@@ -368,14 +368,14 @@ func TestImageBinary(t *testing.T) {
368368
runCommand("docker", args...)
369369
}()
370370
// save with tag/prefix override
371-
assertCommand(t, dockerApp, "save", "-t", "mytag", "-p", registry+"/myuser", "render/envvariables")
371+
assertCommand(t, dockerApp, "save", "-t", "mytag", "--namespace", registry+"/myuser", "render/envvariables")
372372
assertCommandOutput(t, "image-inspect-labels.golden", "docker", "inspect", "-f", "{{.Config.Labels.maintainers}}", registry+"/myuser/envvariables.dockerapp:mytag")
373373
// save with tag/prefix from metadata
374374
assertCommand(t, dockerApp, "save", "render/envvariables")
375375
assertCommandOutput(t, "image-inspect-labels.golden", "docker", "inspect", "-f", "{{.Config.Labels.maintainers}}", "alice/envvariables.dockerapp:0.1.0")
376376
// push to a registry
377-
assertCommand(t, dockerApp, "push", "-p", registry+"/myuser", "render/envvariables")
378-
assertCommand(t, dockerApp, "push", "-p", registry+"/myuser", "-t", "latest", "render/envvariables")
377+
assertCommand(t, dockerApp, "push", "--namespace", registry+"/myuser", "render/envvariables")
378+
assertCommand(t, dockerApp, "push", "--namespace", registry+"/myuser", "-t", "latest", "render/envvariables")
379379
assertCommand(t, "docker", "image", "rm", registry+"/myuser/envvariables.dockerapp:0.1.0")
380380
assertCommand(t, dockerApp, "inspect", registry+"/myuser/envvariables.dockerapp:0.1.0")
381381
assertCommand(t, dockerApp, "inspect", registry+"/myuser/envvariables.dockerapp")

e2e/render/envvariables.dockerapp/metadata.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 0.1.0
22
name: myapp
33
description: ""
4-
repository_prefix: "alice"
4+
namespace: "alice"
55
maintainers:
66
- name: bearclaw
77
email: bearclaw@bearclaw.bearclaw

e2e/testdata/init-singlefile.dockerapp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ version: 0.1.0
55
name: tac
66
# A short description of the application
77
description: my cool app
8-
# Repository prefix to use when pushing to a registry. This is typically your Hub username.
9-
#repository_prefix: myHubUsername
8+
# Namespace to use when pushing to a registry. This is typically your Hub username.
9+
#namespace: myHubUsername
1010
# List of application maitainers with name and email for each
1111
maintainers:
1212
- name: bob

examples/hello-world/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ cat hello-world.dockerapp
1818
version: 0.1.0
1919
name: hello-world
2020
description: ""
21-
repository_prefix: ""
21+
namespace: ""
2222
maintainers:
2323
- name: dimrok
2424
email: ""

examples/hello-world/hello-world.dockerapp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
version: 0.1.0
55
name: hello-world
66
description: "Hello world!"
7-
repository_prefix: "myhubuser"
7+
namespace: "myhubuser"
88
maintainers:
99
- name: user
1010
email: "user@email.com"

internal/packager/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ version: {{ .Version }}
231231
name: {{ .Name }}
232232
# A short description of the application
233233
description: {{ .Description }}
234-
# Repository prefix to use when pushing to a registry. This is typically your Hub username.
235-
{{ if len .RepositoryPrefix }}repository_prefix: {{ .RepositoryPrefix }} {{ else }}#repository_prefix: myHubUsername{{ end }}
234+
# Namespace to use when pushing to a registry. This is typically your Hub username.
235+
{{ if len .Namespace}}namespace: {{ .Namespace }} {{ else }}#namespace: myHubUsername{{ end }}
236236
# List of application maitainers with name and email for each
237237
{{ if len .Maintainers }}maintainers:
238238
{{ range .Maintainers }} - name: {{ .Name }}

internal/packager/init_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ version: 0.1.0
8080
name: writemetadata_test
8181
# A short description of the application
8282
description:
83-
# Repository prefix to use when pushing to a registry. This is typically your Hub username.
84-
#repository_prefix: myHubUsername
83+
# Namespace to use when pushing to a registry. This is typically your Hub username.
84+
#namespace: myHubUsername
8585
# List of application maitainers with name and email for each
8686
maintainers:
8787
- name: bearclaw

0 commit comments

Comments
 (0)