From 74318e1c20058322271744dd8918f77a4b634713 Mon Sep 17 00:00:00 2001 From: "cluster-stack-bot[bot]" <143188378+cluster-stack-bot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:29:32 +0100 Subject: [PATCH] :seedling: Update Golang Dependencies group to v0.1.0-alpha.2 (#45) | datasource | package | from | to | | ---------- | ----------------------------------------------------- | -------------- | -------------- | | go | github.com/SovereignCloudStack/cluster-stack-operator | v0.1.0-alpha.1 | v0.1.0-alpha.2 | Co-authored-by: cluster-stack-bot[bot] <143188378+cluster-stack-bot[bot]@users.noreply.github.com> Co-authored-by: Michal Gubricky --- go.mod | 2 +- go.sum | 4 +- .../pkg/clusterstack/clusterstack.go | 4 +- .../pkg/release/release.go | 67 ++++++++++++++++--- .../pkg/version/version.go | 18 +++-- vendor/modules.txt | 2 +- 6 files changed, 74 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 435f8a8e..41830153 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/sovereignCloudStack/cluster-stack-provider-openstack go 1.21 require ( - github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.1 + github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2 github.com/gophercloud/gophercloud v1.8.0 github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56 github.com/onsi/ginkgo/v2 v2.14.0 diff --git a/go.sum b/go.sum index 07bd8ac8..f22d56c7 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.1 h1:ZzdupXrOqcm9dtnhbYOnLtkAhIjY6HNGGOYLnEOnAis= -github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.1/go.mod h1:CxGwKIWX4KbHRGJYq9eIINr6x6VOPbCXSMsud4whiF8= +github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2 h1:23sNJB4z0wiguCeG0W+GdusBrRNYGcKsUYLZo01wZNs= +github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2/go.mod h1:qXyqN2aZ+JCtVIVMNdr736b+3XNmaOhsXjGZuMUUUp0= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 h1:X8MJ0fnN5FPdcGF5Ij2/OW+HgiJrRg3AfHAx1PJtIzM= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= diff --git a/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/clusterstack/clusterstack.go b/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/clusterstack/clusterstack.go index 62c9cdf7..38145803 100644 --- a/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/clusterstack/clusterstack.go +++ b/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/clusterstack/clusterstack.go @@ -128,7 +128,7 @@ func New(provider, name, kubernetesVersion, csVersion string) (ClusterStack, err } // Validate validates a given ClusterStack. -func (cs ClusterStack) Validate() error { +func (cs *ClusterStack) Validate() error { if cs.Provider == "" { return ErrInvalidProvider } @@ -147,7 +147,7 @@ func (cs ClusterStack) Validate() error { return nil } -func (cs ClusterStack) String() string { +func (cs *ClusterStack) String() string { // release tag: myprovider-myclusterstack-1-26-v1 return strings.Join([]string{cs.Provider, cs.Name, cs.KubernetesVersion.String(), cs.Version.String()}, Separator) } diff --git a/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/release/release.go b/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/release/release.go index bb76e3aa..6777e76d 100644 --- a/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/release/release.go +++ b/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/release/release.go @@ -77,27 +77,70 @@ func New(tag, downloadPath string) (Release, bool, error) { return Release{}, false, fmt.Errorf("couldn't verify the download path %s with error: %w", downloadPath, err) } + metadata, err := ensureMetadata(downloadPath, metadataFileName) + if err != nil { + return Release{}, false, fmt.Errorf("failed to get metadata: %w", err) + } + + rel.Meta = metadata + + // release object is populated, we can validate it now. + if err := rel.Validate(); err != nil { + return Release{}, false, fmt.Errorf("failed to validate release: %w", err) + } + + return rel, false, nil +} + +func ensureMetadata(downloadPath, metadataFileName string) (Metadata, error) { // Read the metadata.yaml file from the release. metadataPath := filepath.Join(downloadPath, metadataFileName) f, err := os.ReadFile(filepath.Clean(filepath.Join(downloadPath, metadataFileName))) if err != nil { - return Release{}, false, fmt.Errorf("failed to read metadata file %s: %w", metadataPath, err) + return Metadata{}, fmt.Errorf("failed to read metadata file %s: %w", metadataPath, err) } metadata := Metadata{} // if unmarshal fails, it indicates incomplete metadata file. // But we don't want to enforce download again. if err = yaml.Unmarshal(f, &metadata); err != nil { - return Release{}, false, fmt.Errorf("failed to unmarshal metadata: %w", err) + return Metadata{}, fmt.Errorf("failed to unmarshal metadata: %w", err) } - rel.Meta = metadata + return metadata, nil +} - if err := rel.Validate(); err != nil { - return Release{}, false, fmt.Errorf("failed to validate release: %w", err) +// CheckHelmCharts checks all expected helm charts in the release directory. +// This is a separate method, since few controllers need to check for the +// presence of helm charts and few don't. +func (r *Release) CheckHelmCharts() error { + // check if the cluster class chart is present. + clusterClassChartName := r.clusterClassChartName() + clusterClassChartPath, err := r.helmChartNamePath(clusterClassChartName) + if err != nil { + return fmt.Errorf("failed to get cluster class chart path: %w", err) + } + if _, err := os.Stat(clusterClassChartPath); err != nil { + return fmt.Errorf("failed to verify the cluster addon chart path %s with error: %w", clusterClassChartPath, err) } - return rel, false, nil + // check if the cluster addon values file is present. + valuesPath := filepath.Join(r.LocalDownloadPath, clusterAddonValuesName) + if _, err := os.Stat(valuesPath); err != nil { + return fmt.Errorf("failed to verify the cluster addon values path %s with error: %w", valuesPath, err) + } + + // check if the cluster class chart is present. + clusterAddonChartName := r.clusterAddonChartName() + clusterAddonChartPath, err := r.helmChartNamePath(clusterAddonChartName) + if err != nil { + return fmt.Errorf("failed to get cluster addon chart path: %w", err) + } + if _, err := os.Stat(clusterAddonChartPath); err != nil { + return fmt.Errorf("failed to verify the cluster class chart path %s with error: %w", clusterAddonChartPath, err) + } + + return nil } // Validate validates the release. @@ -126,8 +169,10 @@ func (r *Release) clusterAddonChartName() string { } // ClusterAddonChartPath returns the helm chart name from the given path. -func (r *Release) ClusterAddonChartPath() (string, error) { - return r.helmChartNamePath(r.clusterAddonChartName()) +func (r *Release) ClusterAddonChartPath() string { + // we ignore the error here, since we already checked for the presence of the chart. + path, _ := r.helmChartNamePath(r.clusterAddonChartName()) + return path } // ClusterAddonValuesPath returns the path to the cluster addon values file. @@ -141,9 +186,11 @@ func (r *Release) clusterClassChartName() string { } // ClusterClassChartPath returns the absolute helm chart path for cluster class. -func (r *Release) ClusterClassChartPath() (string, error) { +func (r *Release) ClusterClassChartPath() string { nameFilter := r.clusterClassChartName() - return r.helmChartNamePath(nameFilter) + // we ignore the error here, since we already checked for the presence of the chart. + path, _ := r.helmChartNamePath(nameFilter) + return path } // helmChartNamePath returns the helm chart name from the given path. diff --git a/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/version/version.go b/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/version/version.go index 08d0aebd..69175d10 100644 --- a/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/version/version.go +++ b/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/version/version.go @@ -45,7 +45,7 @@ func New(version string) (Version, error) { var err error channel := ChannelStable - re := regexp.MustCompile(`^v\d+(-\b\w+\b[-]\d+)?$`) + re := regexp.MustCompile(`^v\d+(-\b\w+\b-\d+)?$`) match := re.FindStringSubmatch(version) if len(match) == 0 { @@ -118,19 +118,23 @@ func (csv Version) Compare(input Version) (int, error) { if csv.Channel != input.Channel { return 0, fmt.Errorf("cannot compare versions with different channels %s and %s", csv.Channel, input.Channel) } - if csv.Major > input.Major { + + switch { + case csv.Major > input.Major: return 1, nil - } else if csv.Major < input.Major { + case csv.Major < input.Major: return -1, nil - } else if csv.Major == input.Major { - if csv.Patch > input.Patch { + case csv.Major == input.Major: + switch { + case csv.Patch > input.Patch: return 1, nil - } else if csv.Patch < input.Patch { + case csv.Patch < input.Patch: return -1, nil - } else if csv.Patch == input.Patch { + case csv.Patch == input.Patch: return 0, nil } } + return 0, nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index f15f0f8b..2d87a129 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -18,7 +18,7 @@ github.com/ProtonMail/go-crypto/openpgp/internal/ecc github.com/ProtonMail/go-crypto/openpgp/internal/encoding github.com/ProtonMail/go-crypto/openpgp/packet github.com/ProtonMail/go-crypto/openpgp/s2k -# github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.1 +# github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2 ## explicit; go 1.19 github.com/SovereignCloudStack/cluster-stack-operator/pkg/clusterstack github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client