From d90bd6152b24ceb565e38e82fec80165a4df8944 Mon Sep 17 00:00:00 2001 From: Matt Nikkel Date: Tue, 1 Mar 2022 21:39:03 -0500 Subject: [PATCH] Add ImageTxts to sync subcommand --- cmd/hauler/cli/store/sync.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmd/hauler/cli/store/sync.go b/cmd/hauler/cli/store/sync.go index e35e619..b389df5 100644 --- a/cmd/hauler/cli/store/sync.go +++ b/cmd/hauler/cli/store/sync.go @@ -13,6 +13,7 @@ import ( "github.com/rancherfederal/hauler/pkg/apis/hauler.cattle.io/v1alpha1" "github.com/rancherfederal/hauler/pkg/apis/hauler.cattle.io/v1alpha2" tchart "github.com/rancherfederal/hauler/pkg/collection/chart" + "github.com/rancherfederal/hauler/pkg/collection/imagetxt" "github.com/rancherfederal/hauler/pkg/collection/k3s" "github.com/rancherfederal/hauler/pkg/content" "github.com/rancherfederal/hauler/pkg/log" @@ -158,6 +159,27 @@ func SyncCmd(ctx context.Context, o *SyncOpts, s *store.Store) error { return err } } + // collection.hauler.cattle.io/v1alpha1 ImageTxts + case v1alpha1.ImageTxtsContentKind: + var cfg v1alpha1.ImageTxts + if err := yaml.Unmarshal(doc, &cfg); err != nil { + return err + } + + for _, cfgIt := range cfg.Spec.ImageTxts { + it, err := imagetxt.New( + imagetxt.WithRef(cfgIt.Ref), + imagetxt.WithIncludeSources(cfgIt.Sources.Include...), + imagetxt.WithExcludeSources(cfgIt.Sources.Exclude...), + ) + if err != nil { + return fmt.Errorf("convert ImageTxt %s: %v", cfg.Name, err) + } + + if _, err := s.AddCollection(ctx, it); err != nil { + return fmt.Errorf("add ImageTxt %s to store: %v", cfg.Name, err) + } + } // collection.hauler.cattle.io/v1alpha1 unknown default: return fmt.Errorf("unsupported Kind %s for %s", gvk.Kind, gvk.GroupVersion().String())