mirror of
https://github.com/hauler-dev/hauler.git
synced 2026-08-19 20:36:30 +00:00
update manifest name to match store by default
This commit is contained in:
@@ -517,9 +517,12 @@ func addStoreCreateManifest(rso *flags.StoreRootOpts, ro *flags.CliRootOpts) *co
|
||||
cmd := &cobra.Command{
|
||||
Use: "manifest",
|
||||
Short: "Create a hauler content manifest from the store's metadata",
|
||||
Example: ` # generate a manifest for the default store into ./hauler-manifest.yaml
|
||||
Example: ` # generate a manifest for the default store into ./store-manifest.yaml
|
||||
hauler store create manifest
|
||||
|
||||
# generate a manifest for a specific store into ./my-store-manifest.yaml
|
||||
hauler store create manifest --store /path/to/my-store
|
||||
|
||||
# generate a manifest for a specific store into a custom path
|
||||
hauler store create manifest --store /path/to/store --output my-manifest.yaml`,
|
||||
Args: cobra.ExactArgs(0),
|
||||
|
||||
@@ -184,6 +184,11 @@ func CreateManifestCmd(ctx context.Context, o *flags.CreateManifestOpts, s *stor
|
||||
|
||||
base := sanitizeName(filepath.Base(s.Root))
|
||||
|
||||
output := o.Output
|
||||
if output == "" {
|
||||
output = base + "-manifest.yaml"
|
||||
}
|
||||
|
||||
var out strings.Builder
|
||||
if len(images) > 0 {
|
||||
if err := writeDoc(&out, "", consts.ImagesContentKind, base+"-images", struct {
|
||||
@@ -211,12 +216,12 @@ func CreateManifestCmd(ctx context.Context, o *flags.CreateManifestOpts, s *stor
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.WriteFile(o.Output, []byte(out.String()), 0o644); err != nil {
|
||||
return fmt.Errorf("writing manifest to [%s]: %w", o.Output, err)
|
||||
if err := os.WriteFile(output, []byte(out.String()), 0o644); err != nil {
|
||||
return fmt.Errorf("writing manifest to [%s]: %w", output, err)
|
||||
}
|
||||
|
||||
outPath := o.Output
|
||||
if abs, err := filepath.Abs(o.Output); err == nil {
|
||||
outPath := output
|
||||
if abs, err := filepath.Abs(output); err == nil {
|
||||
outPath = abs
|
||||
}
|
||||
l.Infof("wrote manifest with [%d] image(s), [%d] chart(s), [%d] file(s) to [%s]", len(images), len(charts), len(files), outPath)
|
||||
|
||||
@@ -11,5 +11,5 @@ type CreateManifestOpts struct {
|
||||
func (o *CreateManifestOpts) AddFlags(cmd *cobra.Command) {
|
||||
f := cmd.Flags()
|
||||
|
||||
f.StringVarP(&o.Output, "output", "o", "hauler-manifest.yaml", "(Optional) Path to write the generated manifest to")
|
||||
f.StringVarP(&o.Output, "output", "o", "", "(Optional) Path to write the generated manifest to (default \"$STORENAME-manifest.yaml\")")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user