add container build after container sync
Signed-off-by: jason yang <xyang@ciq.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
4a2969f298
commit
4072730172
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
|
||||
"github.com/warewulf/warewulf/internal/pkg/container"
|
||||
"github.com/warewulf/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
@@ -20,5 +21,23 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if write && !build {
|
||||
// when write = true and build = false, we will print a warnning, this is the default case
|
||||
wwlog.Warn("Syncuser is completed, please remember to rebuild container or add `--build` flag for automatic rebuild after syncuser")
|
||||
} else if write && build {
|
||||
// if write = true and build = true, then it'll trigger the container build after sync
|
||||
cbp := &wwapiv1.ContainerBuildParameter{
|
||||
ContainerNames: []string{containerName},
|
||||
Force: true,
|
||||
All: false,
|
||||
Default: false,
|
||||
}
|
||||
err := container_build.ContainerBuild(cbp)
|
||||
if err != nil {
|
||||
wwlog.Error("Error during container build: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,10 +25,12 @@ uid/gid collision is detected. File ownerships are also changed.`,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
write bool
|
||||
build bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVar(&write, "write", false, "Synchronize uis/gids and write files in container")
|
||||
baseCmd.PersistentFlags().BoolVar(&build, "build", false, "Build container after syncuser is completed")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
Reference in New Issue
Block a user