@@ -13,7 +13,7 @@ import (
13
13
"path/filepath"
14
14
)
15
15
16
- func getRegistry () (registryAddr string , registryInsecure bool , err error ) {
16
+ func getRegistry (cliContext * cli. Context ) (registryAddr string , registryInsecure bool , err error ) {
17
17
provisioner , err := getProvisioner ()
18
18
19
19
if err != nil {
@@ -39,12 +39,15 @@ func createBuildInterface(forceNoninteractive bool) build.Interface {
39
39
func buildCommandAction (cliContext * cli.Context ) error {
40
40
registry := ""
41
41
registryInsecure := false
42
- if cliContext .Bool ("push" ) {
42
+ if addr := cliContext .String ("registry" ); addr != "" {
43
+ registry = addr
44
+ } else if cliContext .Bool ("push" ) {
43
45
_ , err := getProvisioner ()
44
46
if err != nil {
45
47
return cli .NewExitError (fmt .Sprintf ("you must be in an environment with a provisioner to use --push while building: %s" , err .Error ()), 1 )
46
48
}
47
- registry , registryInsecure , err = getRegistry ()
49
+
50
+ registry , registryInsecure , err = getRegistry (cliContext )
48
51
if err != nil {
49
52
return cli .NewExitError (fmt .Sprintf ("you specified --push, but a registry was not found: %s. Try \" sanic deploy\" first." , err .Error ()), 1 )
50
53
}
@@ -108,12 +111,12 @@ func buildCommandAction(cliContext *cli.Context) error {
108
111
jobs := make ([]func (context.Context ) error , 0 , len (services ))
109
112
110
113
builder := build.Builder {
111
- Registry : registry ,
114
+ Registry : registry ,
112
115
RegistryInsecure : registryInsecure ,
113
- BuildTag : buildTag ,
114
- Logger : buildLogger ,
115
- Interface : buildInterface ,
116
- DoPush : cliContext .Bool ("push" ),
116
+ BuildTag : buildTag ,
117
+ Logger : buildLogger ,
118
+ Interface : buildInterface ,
119
+ DoPush : cliContext .Bool ("push" ),
117
120
}
118
121
119
122
for _ , service := range services {
@@ -159,11 +162,15 @@ var buildCommand = cli.Command{
159
162
Usage : "pushes to the configured registry for the current environment instead of loading locally" ,
160
163
},
161
164
cli.StringFlag {
162
- Name : "tag,t" ,
165
+ Name : "tag,t" ,
163
166
Usage : "sets the tag of all built images to the specified one" ,
164
167
},
168
+ cli.StringFlag {
169
+ Name : "registry" ,
170
+ Usage : "sets the registry of all built images to the specified one (i.e., for use with --push)" ,
171
+ },
165
172
cli.BoolFlag {
166
- Name : "verbose" ,
173
+ Name : "verbose" ,
167
174
Usage : "enables verbose logging, mostly for sanic development" ,
168
175
},
169
176
},
0 commit comments