Files
Jonathon Anderson 3c895dd941 Refactor gRPC-based image functions
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2026-03-22 01:02:03 -06:00

33 lines
932 B
Go

package syncuser
import (
"fmt"
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
imageName := args[0]
if !image.ValidName(imageName) {
return fmt.Errorf("%s is not a valid image", imageName)
}
err := image.Syncuser(imageName, write)
if err != nil {
return fmt.Errorf("error in synchronize: %s", err)
}
if write && !build {
// when write = true and build = false, we will print a warnning, this is the default case
wwlog.Info("Syncuser is completed. Rebuild image or add `--build` flag for automatic rebuild after syncuser.")
} else if write && build {
// if write = true and build = true, then it'll trigger the image build after sync
if err := image.Build(imageName, true); err != nil {
return fmt.Errorf("error during image build: %s", err)
}
}
return nil
}