get.porter.sh/porter@v1.3.0/pkg/porter/options.go (about) 1 package porter 2 3 import ( 4 "context" 5 6 "get.porter.sh/porter/pkg/cnab" 7 "get.porter.sh/porter/pkg/manifest" 8 ) 9 10 // applyDefaultOptions applies more advanced defaults to the options 11 // based on values that beyond just what was supplied by the user 12 // such as information in the manifest itself. 13 func (p *Porter) applyDefaultOptions(ctx context.Context, opts *installationOptions) error { 14 if opts.Name != "" { 15 return nil 16 } 17 18 if opts.File != "" { 19 m, err := manifest.LoadManifestFrom(ctx, p.Config, opts.File) 20 if err != nil { 21 return err 22 } 23 24 opts.Name = m.Name 25 return nil 26 } 27 28 if opts.CNABFile != "" { 29 bun, err := cnab.LoadBundle(p.Context, opts.CNABFile) 30 if err != nil { 31 return err 32 } 33 34 opts.Name = bun.Name 35 return nil 36 } 37 38 return nil 39 }