MCPcopy
hub / github.com/genuinetools/img / ValidateArgs

Method ValidateArgs

build.go:111–134  ·  view source on GitHub ↗
(c *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

109}
110
111func (cmd *buildCommand) ValidateArgs(c *cobra.Command, args []string) error {
112 if len(args) < 1 {
113 return fmt.Errorf("must pass a path to build")
114 }
115
116 if c.Flag("output").Changed {
117 out, err := build.ParseOutput([]string{cmd.output})
118 if err != nil || len(out) != 1 {
119 return err
120 }
121 if name, ok := out[0].Attrs["name"]; ok && name != "" {
122 validated, err := validateTag(name)
123 if err != nil {
124 return err
125 }
126 out[0].Attrs["name"] = validated
127 }
128 cmd.bkoutput = out[0]
129 } else if cmd.tags.Len() < 1 {
130 return errors.New("please specify an image tag with `-t` or an output spec with `-o`")
131 }
132
133 return nil
134}
135
136func (cmd *buildCommand) Run(args []string) (err error) {
137 reexec()

Callers

nothing calls this directly

Calls 2

validateTagFunction · 0.85
LenMethod · 0.80

Tested by

no test coverage detected