Skip to content

Commit

Permalink
Merge pull request #1804 from zimnx/mz/parametrize-must-gather
Browse files Browse the repository at this point in the history
Parametrize must-gather command
  • Loading branch information
scylla-operator-bot[bot] authored May 6, 2024
2 parents 2d58d7a + 339a5e6 commit dce40d8
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pkg/cmd/operator/mustgather.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ var (
type MustGatherOptions struct {
*GatherBaseOptions

AllResources bool
AllResources bool
CollectedResourceGroups []GroupResourceSpec
}

func NewMustGatherOptions(streams genericclioptions.IOStreams) *MustGatherOptions {
return &MustGatherOptions{
GatherBaseOptions: NewGatherBaseOptions("scylla-operator-must-gather", true),
AllResources: false,
options := &MustGatherOptions{
GatherBaseOptions: NewGatherBaseOptions("scylla-operator-must-gather", true),
AllResources: false,
CollectedResourceGroups: DefaultCollectedResourceGroups,
}

return options
}

func (o *MustGatherOptions) AddFlags(flagset *pflag.FlagSet) {
Expand Down Expand Up @@ -148,10 +152,12 @@ type resourceSpec struct {
Namespace, Name string
}

var mustGatherSpecs = []struct {
type GroupResourceSpec struct {
schema.GroupResource
Namespace, Name string
}{
}

var DefaultCollectedResourceGroups = []GroupResourceSpec{
{
GroupResource: schema.GroupResource{
Resource: "scyllaclusters",
Expand Down Expand Up @@ -286,8 +292,8 @@ func (o *MustGatherOptions) run(ctx context.Context) error {
return fmt.Errorf("can't discover preferred resources: %w", err)
}

resourceSpecs = make([]resourceSpec, 0, len(mustGatherSpecs))
for _, s := range mustGatherSpecs {
resourceSpecs = make([]resourceSpec, 0, len(o.CollectedResourceGroups))
for _, s := range o.CollectedResourceGroups {
ri, err := findResource(preferredResources, s.GroupResource)
if err != nil {
return fmt.Errorf("can't find resource in preferred resources: %w", err)
Expand Down

0 comments on commit dce40d8

Please sign in to comment.