@@ -21,8 +21,7 @@ import (
2121)
2222
2323type bundleOptions struct {
24- invocationImageName string
25- out string
24+ out string
2625}
2726
2827func bundleCmd (dockerCli command.Cli ) * cobra.Command {
@@ -36,13 +35,12 @@ func bundleCmd(dockerCli command.Cli) *cobra.Command {
3635 },
3736 }
3837
39- cmd .Flags ().StringVarP (& opts .invocationImageName , "invocation-image" , "i" , "" , "specify the name of invocation image to build" )
4038 cmd .Flags ().StringVarP (& opts .out , "out" , "o" , "bundle.json" , "path to the output bundle.json (- for stdout)" )
4139 return cmd
4240}
4341
4442func runBundle (dockerCli command.Cli , appName string , opts bundleOptions ) error {
45- bundle , err := makeBundle (dockerCli , appName , opts . invocationImageName )
43+ bundle , err := makeBundle (dockerCli , appName )
4644 if err != nil {
4745 return err
4846 }
@@ -61,22 +59,22 @@ func runBundle(dockerCli command.Cli, appName string, opts bundleOptions) error
6159 return ioutil .WriteFile (opts .out , bundleBytes , 0644 )
6260}
6361
64- func makeBundle (dockerCli command.Cli , appName , invocationImageName string ) (* bundle.Bundle , error ) {
62+ func makeBundle (dockerCli command.Cli , appName string ) (* bundle.Bundle , error ) {
6563 app , err := packager .Extract (appName )
6664 if err != nil {
6765 return nil , err
6866 }
6967 defer app .Cleanup ()
70- return makeBundleFromApp (dockerCli , app , invocationImageName )
68+ return makeBundleFromApp (dockerCli , app )
7169}
7270
73- func makeBundleFromApp (dockerCli command.Cli , app * types.App , invocationImageName string ) (* bundle.Bundle , error ) {
71+ func makeBundleFromApp (dockerCli command.Cli , app * types.App ) (* bundle.Bundle , error ) {
7472 meta := app .Metadata ()
75- invocationImageName , err := makeImageName (meta , invocationImageName , "-invoc" )
73+ invocationImageName , err := makeImageName (meta )
7674 if err != nil {
7775 return nil , err
7876 }
79- if _ , err := makeImageName (app . Metadata (), "" , "" ); err != nil {
77+ if _ , err := makeImageName (meta ); err != nil {
8078 return nil , err
8179 }
8280
@@ -100,12 +98,10 @@ func makeBundleFromApp(dockerCli command.Cli, app *types.App, invocationImageNam
10098 return packager .ToCNAB (app , invocationImageName )
10199}
102100
103- func makeImageName (meta metadata.AppMetadata , name , suffix string ) (string , error ) {
104- if name == "" {
105- name = fmt .Sprintf ("%s:%s%s" , meta .Name , meta .Version , suffix )
106- }
101+ func makeImageName (meta metadata.AppMetadata ) (string , error ) {
102+ name := fmt .Sprintf ("%s:%s-invoc" , meta .Name , meta .Version )
107103 if _ , err := reference .ParseNormalizedNamed (name ); err != nil {
108- return "" , errors .Wrapf (err , "image name %q is invalid, please check namespace, name and version fields" , name )
104+ return "" , errors .Wrapf (err , "image name %q is invalid, please check name and version fields" , name )
109105 }
110106 return name , nil
111107}
0 commit comments