Added wwctl image build --syncuser
- #1321 Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Added support for comma-separated hostlist patterns. #1635
|
||||
- Added default value for `warewulf.conf:dhcp.template`. #1725
|
||||
- Added `UniqueField` template function. #829
|
||||
- Added `wwctl image build --syncuser`. #1321
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/api/image"
|
||||
apiimage "github.com/warewulf/warewulf/internal/pkg/api/image"
|
||||
"github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
|
||||
"github.com/warewulf/warewulf/internal/pkg/image"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SyncUser {
|
||||
for _, name := range args {
|
||||
if err := image.SyncUids(name, true); err != nil {
|
||||
return fmt.Errorf("syncuser error: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cbp := &wwapiv1.ImageBuildParameter{
|
||||
ImageNames: args,
|
||||
Force: BuildForce,
|
||||
All: BuildAll,
|
||||
}
|
||||
return image.ImageBuild(cbp)
|
||||
return apiimage.ImageBuild(cbp)
|
||||
}
|
||||
|
||||
@@ -23,11 +23,13 @@ var (
|
||||
}
|
||||
BuildForce bool
|
||||
BuildAll bool
|
||||
SyncUser bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "(re)Build all images")
|
||||
baseCmd.PersistentFlags().BoolVarP(&BuildForce, "force", "f", false, "Force rebuild, even if it isn't necessary")
|
||||
baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to image")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
Reference in New Issue
Block a user