Skip to content

Commit

Permalink
Add check for empty image-name
Browse files Browse the repository at this point in the history
  • Loading branch information
mikusaq committed Jan 2, 2025
1 parent 6a7c540 commit 787d22f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bap-builder/CmdArgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (cmd *CmdLineArgs) InitFlags() {
cmd.BuildPackageArgs.DockerImageName = cmd.buildPackageParser.String("", "image-name",
&argparse.Options{
Required: true,
Validate: checkForEmpty,
Help: "Docker image name for which packages will be build.\n" +
"Only packages that contains image-name in the DockerMatrix will be built.\n" +
"Given packages will be build by toolchain represented by image-name",
Expand Down Expand Up @@ -167,11 +168,21 @@ func (cmd *CmdLineArgs) InitFlags() {
cmd.CreateSysrootArgs.ImageName = cmd.createSysrootParser.String("", "image-name",
&argparse.Options{
Required: true,
Validate: checkForEmpty,
Help: "Name of docker image which are the packages build for",
},
)
}

func checkForEmpty(args []string) error {
if len(args) == 1 {
if len(args[0]) == 0 {
return fmt.Errorf("cannot be empty")
}
}
return nil
}

// ParseArgs
// Parse arguments from given 'args' list of strings.
// Return error if cmdline is not valid or nil in case of no problem.
Expand Down

0 comments on commit 787d22f

Please sign in to comment.