Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ linters:
- bodyclose
- containedctx
- contextcheck
- copyloopvar
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forcetypeassert
- gci
- gocritic
Expand Down
7 changes: 4 additions & 3 deletions pkg/clusterstack/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package clusterstack

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -58,11 +59,11 @@ func GetCsctlConfig(path string) (*CsctlConfig, error) {
}

if cs.Config.Provider.Type == "" {
return nil, fmt.Errorf("provider type must not be empty")
return nil, errors.New("provider type must not be empty")
}

if len(cs.Config.Provider.Type) > 253 {
return nil, fmt.Errorf("provider name must not be greater than 253")
return nil, errors.New("provider name must not be greater than 253")
}

match, err := regexp.MatchString(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`, cs.Config.Provider.Type)
Expand All @@ -74,7 +75,7 @@ func GetCsctlConfig(path string) (*CsctlConfig, error) {
}

if cs.Config.ClusterStackName == "" {
return nil, fmt.Errorf("cluster stack name must not be empty")
return nil, errors.New("cluster stack name must not be empty")
}

// Validate kubernetes version
Expand Down
3 changes: 2 additions & 1 deletion pkg/clusterstack/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package clusterstack

import (
"errors"
"fmt"
"regexp"
"strconv"
Expand All @@ -30,7 +31,7 @@ func BumpVersion(version string) (string, error) {

// Check if a numeric part was found
if len(matches) < 2 {
return "", fmt.Errorf("invalid version format")
return "", errors.New("invalid version format")
}

// Extract and convert the numeric part to an integer
Expand Down
15 changes: 8 additions & 7 deletions pkg/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cmd
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -185,13 +186,13 @@ func GetCreateOptions(ctx context.Context, clusterStackPath string) (*CreateOpti
}
case customMode:
if clusterStackVersion == "" {
return nil, fmt.Errorf("please specify a semver for custom version with --cluster-stack-version flag")
return nil, errors.New("please specify a semver for custom version with --cluster-stack-version flag")
}
if clusterAddonVersion == "" {
return nil, fmt.Errorf("please specify a semver for custom version with --cluster-addon-version flag")
return nil, errors.New("please specify a semver for custom version with --cluster-addon-version flag")
}
if nodeImageVersion == "" {
return nil, fmt.Errorf("please specify a semver for custom version with --node-image-version flag")
return nil, errors.New("please specify a semver for custom version with --node-image-version flag")
}

createOption.Metadata, err = clusterstack.HandleCustomMode(createOption.Config.Config.KubernetesVersion, clusterStackVersion, clusterAddonVersion, nodeImageVersion)
Expand Down Expand Up @@ -222,7 +223,7 @@ func createAction(cmd *cobra.Command, args []string) error {
defer cleanTmpDirectory()

if len(args) != 1 {
return fmt.Errorf("please provide a valid command, create only accept one argument to path to the cluster stacks")
return errors.New("please provide a valid command, create only accept one argument to path to the cluster stacks")
}
clusterStackPath := args[0]

Expand Down Expand Up @@ -253,7 +254,7 @@ func (c *CreateOptions) validateHash() error {
if c.CurrentReleaseHash.ClusterAddonDir == c.LatestReleaseHash.ClusterAddonDir &&
c.CurrentReleaseHash.ClusterAddonValues == c.LatestReleaseHash.ClusterAddonValues &&
c.CurrentReleaseHash.NodeImageDir == c.LatestReleaseHash.NodeImageDir {
return fmt.Errorf("no change in the cluster stack")
return errors.New("no change in the cluster stack")
}

return nil
Expand Down Expand Up @@ -351,7 +352,7 @@ func (c *CreateOptions) generateRelease(ctx context.Context) error {

if publish {
if remote != "oci" {
return fmt.Errorf("not pushing assets. --publish is only implemented for remote OCI")
return errors.New("not pushing assets. --publish is only implemented for remote OCI")
}

ociClient, err := oci.NewClient()
Expand Down Expand Up @@ -410,7 +411,7 @@ func overwriteVersionInFile(chartYaml, newVersion string) error {
v := m["version"]
oldVersion, ok := v.(string)
if !ok {
return fmt.Errorf("failed to read version in yaml")
return errors.New("failed to read version in yaml")
}

m["version"] = newVersion
Expand Down
3 changes: 2 additions & 1 deletion pkg/hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/sha256"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -111,7 +112,7 @@ func (r ReleaseHash) ValidateWithLatestReleaseHash(latestReleaseHash ReleaseHash
if r.ClusterAddonDir == latestReleaseHash.ClusterAddonDir &&
r.ClusterAddonValues == latestReleaseHash.ClusterAddonValues &&
r.NodeImageDir == latestReleaseHash.NodeImageDir {
return fmt.Errorf("no change in the cluster stack")
return errors.New("no change in the cluster stack")
}

return nil
Expand Down
Loading