From bb02d7d972ecb41d1f5fbf75f37d4f742c2a2e5f Mon Sep 17 00:00:00 2001 From: YuJack Date: Thu, 26 Oct 2023 15:46:38 +0800 Subject: [PATCH] feat: fetch metadata from env and remove useless code --- cmd/manager.go | 2 ++ pkg/manager/cluster.go | 11 +++-------- pkg/manager/manager.go | 2 ++ pkg/manager/types.go | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/manager.go b/cmd/manager.go index 395a6b7e7..46e7e0516 100644 --- a/cmd/manager.go +++ b/cmd/manager.go @@ -56,4 +56,6 @@ func init() { managerCmd.PersistentFlags().StringVar(&sbm.SpecifyCollector, "specify-collector", os.Getenv("SUPPORT_BUNDLE_COLLECTOR"), "Execute specify collector script. e.g., longhorn") managerCmd.PersistentFlags().StringSliceVar(&sbm.ExcludeResourceList, "exclude-resources", getEnvStringSlice("SUPPORT_BUNDLE_EXCLUDE_RESOURCES"), "List of resources to exclude. e.g., settings.harvesterhci.io,secrets") managerCmd.PersistentFlags().StringSliceVar(&sbm.BundleCollectors, "extra-collectors", getEnvStringSlice("SUPPORT_BUNDLE_EXTRA_COLLECTORS"), "Get extra resource for the specific components e.g., harvester") + managerCmd.PersistentFlags().StringVar(&sbm.Description, "description", os.Getenv("SUPPORT_BUNDLE_DESCRIPTION"), "The support bundle description") + managerCmd.PersistentFlags().StringVar(&sbm.IssueURL, "issue-url", os.Getenv("SUPPORT_BUNDLE_ISSUE_URL"), "The support bundle issue url") } diff --git a/pkg/manager/cluster.go b/pkg/manager/cluster.go index 00ebef68d..80e2ee1d9 100644 --- a/pkg/manager/cluster.go +++ b/pkg/manager/cluster.go @@ -43,19 +43,14 @@ func (c *Cluster) GenerateClusterBundle(bundleDir string) (string, error) { return "", errors.Wrap(err, "cannot get kubernetes version") } - sb, err := c.sbm.state.GetSupportBundle(c.sbm.PodNamespace, c.sbm.BundleName) - if err != nil { - return "", errors.Wrap(err, "cannot get support bundle") - } - bundleMeta := &BundleMeta{ - BundleName: sb.Name, + BundleName: c.sbm.BundleName, BundleVersion: BundleVersion, KubernetesVersion: kubeVersion.GitVersion, ProjectNamespaceUUID: string(namespace.UID), BundleCreatedAt: utils.Now(), - IssueURL: sb.Spec.IssueURL, - IssueDescription: sb.Spec.Description, + IssueURL: c.sbm.IssueURL, + IssueDescription: c.sbm.Description, } bundleName := fmt.Sprintf("supportbundle_%s_%s.zip", diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index 39d0315a9..e413d9c83 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -41,6 +41,8 @@ type SupportBundleManager struct { NodeSelector string TaintToleration string RegistrySecret string + IssueURL string + Description string ExcludeResources []schema.GroupResource ExcludeResourceList []string diff --git a/pkg/manager/types.go b/pkg/manager/types.go index 50e6c7596..082f8ccf8 100644 --- a/pkg/manager/types.go +++ b/pkg/manager/types.go @@ -23,6 +23,5 @@ type BundleMeta struct { } type StateStoreInterface interface { - GetSupportBundle(namespace, supportbundle string) (*types.SupportBundle, error) GetState(namespace, supportbundle string) (types.SupportBundleState, error) }