Skip to content

Commit

Permalink
... make linter happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
guettli committed Sep 4, 2024
1 parent 2e8c566 commit 1eb880a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ main
*.tgz.yaml
*.build.yaml
.release

# .config/go/telemetry/local/
.config
19 changes: 5 additions & 14 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- copyloopvar
- forcetypeassert
- gci
- goconst
Expand Down Expand Up @@ -86,10 +86,7 @@ linters-settings:
allow-unused: false
allow-leading-space: false
require-specific: true
staticcheck:
go: "1.21"
stylecheck:
go: "1.21"
checks: ["all", "-ST1006"]
dot-import-whitelist:
- "github.com/onsi/gomega"
Expand Down Expand Up @@ -247,9 +244,6 @@ linters-settings:
# Suggest the use of rpc.DefaultXXPath.
# Default: false
default-rpc-path: true
# Suggest the use of os.DevNull.
# Default: false
os-dev-null: true
# Suggest the use of sql.LevelXX.String().
# Default: false
sql-isolation-level: true
Expand All @@ -259,9 +253,6 @@ linters-settings:
# Suggest the use of constant.Kind.String().
# Default: false
constant-kind: true
# Suggest the use of syslog.Priority.
# Default: false
syslog-priority: true
wrapcheck:
ignoreSigs:
- status.Error(
Expand All @@ -285,11 +276,11 @@ issues:
- linters:
- wrapcheck
path: _test\.go
exclude-dirs:
- vendor$
- test/vendor$
run:
timeout: 10m
go: "1.21"
go: "1.22"
allow-parallel-runners: true
modules-download-mode: vendor
skip-dirs:
- vendor$
- test/vendor$
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ MGT_CLUSTER_KUBECONFIG ?= ".mgt-cluster-kubeconfig.yaml"

# Kubebuilder.
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.29.3
# versions
# versions
CTLPTL_VERSION := 0.8.25

##@ Binaries
Expand Down Expand Up @@ -445,7 +445,7 @@ ifeq ($(BUILD_IN_CONTAINER),true)
else
go version
golangci-lint version
GO111MODULE=on golangci-lint run -v --out-format=github-actions
GO111MODULE=on golangci-lint run -v --out-format=colored-line-number
endif

.PHONY: lint-yaml
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/SovereignCloudStack/cluster-stack-operator

go 1.21
go 1.22

require (
github.com/go-logr/logr v1.4.2
Expand Down
19 changes: 11 additions & 8 deletions internal/controller/clusteraddon_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re

releaseAsset, download, err := release.New(release.ConvertFromClusterClassToClusterStackFormat(cluster.Spec.Topology.Class), r.ReleaseDirectory)
if err != nil {
conditions.MarkFalse(clusterAddon, csov1alpha1.ClusterStackReleaseAssetsReadyCondition, csov1alpha1.IssueWithReleaseAssetsReason, clusterv1.ConditionSeverityError, err.Error())
conditions.MarkFalse(clusterAddon, csov1alpha1.ClusterStackReleaseAssetsReadyCondition, csov1alpha1.IssueWithReleaseAssetsReason, clusterv1.ConditionSeverityError, "%s", err.Error())
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
}
if download {
Expand All @@ -204,9 +204,9 @@ func (r *ClusterAddonReconciler) Reconcile(ctx context.Context, req reconcile.Re
csov1alpha1.ClusterStackReleaseAssetsReadyCondition,
csov1alpha1.IssueWithReleaseAssetsReason,
clusterv1.ConditionSeverityError,
msg,
"%s", msg,
)
record.Warnf(clusterAddon, "ValidateHelmChartFailed", msg)
record.Warn(clusterAddon, "ValidateHelmChartFailed", msg)
return reconcile.Result{}, nil
}

Expand Down Expand Up @@ -947,9 +947,9 @@ func (r *ClusterAddonReconciler) downloadOldClusterStackRelease(ctx context.Cont
csov1alpha1.AssetsClientAPIAvailableCondition,
csov1alpha1.FailedCreateAssetsClientReason,
clusterv1.ConditionSeverityError,
err.Error(),
"%s", err.Error(),
)
record.Warnf(clusterAddon, "FailedCreateAssetsClient", err.Error())
record.Warn(clusterAddon, "FailedCreateAssetsClient", err.Error())

// give the assets client a second change
if isSet {
Expand All @@ -963,7 +963,10 @@ func (r *ClusterAddonReconciler) downloadOldClusterStackRelease(ctx context.Cont
// check if old cluster stack release is present or not.
releaseAsset, download, err := release.New(release.ConvertFromClusterClassToClusterStackFormat(clusterAddon.Spec.ClusterStack), r.ReleaseDirectory)
if err != nil {
conditions.MarkFalse(clusterAddon, csov1alpha1.ClusterStackReleaseAssetsReadyCondition, csov1alpha1.IssueWithReleaseAssetsReason, clusterv1.ConditionSeverityError, err.Error())
conditions.MarkFalse(clusterAddon,
csov1alpha1.ClusterStackReleaseAssetsReadyCondition,
csov1alpha1.IssueWithReleaseAssetsReason,
clusterv1.ConditionSeverityError, "%s", err.Error())
return nil, true, nil
}
if download {
Expand Down Expand Up @@ -991,9 +994,9 @@ func (r *ClusterAddonReconciler) downloadOldClusterStackRelease(ctx context.Cont
csov1alpha1.ClusterStackReleaseAssetsReadyCondition,
csov1alpha1.IssueWithReleaseAssetsReason,
clusterv1.ConditionSeverityError,
msg,
"%s", msg,
)
record.Warnf(clusterAddon, "ValidateHelmChartFailed", msg)
record.Warn(clusterAddon, "ValidateHelmChartFailed", msg)
return nil, false, nil
}

Expand Down
12 changes: 6 additions & 6 deletions internal/controller/clusterstack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ func (r *ClusterStackReconciler) Reconcile(ctx context.Context, req reconcile.Re
csov1alpha1.AssetsClientAPIAvailableCondition,
csov1alpha1.FailedCreateAssetsClientReason,
clusterv1.ConditionSeverityError,
err.Error(),
"%s", err.Error(),
)
record.Warnf(clusterStack, "FailedCreateAssetsClient", err.Error())
record.Warn(clusterStack, "FailedCreateAssetsClient", err.Error())

// give the assets client a second change
if isSet {
Expand All @@ -140,7 +140,7 @@ func (r *ClusterStackReconciler) Reconcile(ctx context.Context, req reconcile.Re
csov1alpha1.ReleasesSyncedCondition,
csov1alpha1.FailedToSyncReason,
clusterv1.ConditionSeverityWarning,
err.Error(),
"%s", err.Error(),
)
logger.Error(err, "failed to get latest release from remote repository")
}
Expand All @@ -165,7 +165,7 @@ func (r *ClusterStackReconciler) Reconcile(ctx context.Context, req reconcile.Re
if err := r.Delete(ctx, toDelete[i]); err != nil && !apierrors.IsNotFound(err) {
// ignore not found errors when deleting
reterr := fmt.Errorf("failed to delete cluster stack release %s: %w", csr.Name, err)
record.Eventf(clusterStack, "FailedToDeleteClusterStackRelease", reterr.Error())
record.Event(clusterStack, "FailedToDeleteClusterStackRelease", reterr.Error())
return reconcile.Result{}, reterr
}
}
Expand Down Expand Up @@ -198,7 +198,7 @@ func (r *ClusterStackReconciler) Reconcile(ctx context.Context, req reconcile.Re
csov1alpha1.ProviderClusterStackReleasesSyncedCondition,
csov1alpha1.FailedToCreateOrUpdateReason,
clusterv1.ConditionSeverityWarning,
err.Error(),
"%s", err.Error(),
)
}
return reconcile.Result{}, fmt.Errorf("failed to create or update provider specific ClusterStackRelease %s/%s: %w", req.Namespace, csr.Name, err)
Expand All @@ -210,7 +210,7 @@ func (r *ClusterStackReconciler) Reconcile(ctx context.Context, req reconcile.Re
csov1alpha1.ClusterStackReleasesSyncedCondition,
csov1alpha1.FailedToCreateOrUpdateReason,
clusterv1.ConditionSeverityWarning,
err.Error(),
"%s", err.Error(),
)
return reconcile.Result{}, fmt.Errorf("failed to get or create ClusterStackRelease %s/%s: %w", req.Namespace, csr.Name, err)
}
Expand Down
9 changes: 6 additions & 3 deletions internal/controller/clusterstackrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ func (r *ClusterStackReleaseReconciler) Reconcile(ctx context.Context, req recon

releaseAssets, download, err := release.New(releaseTag, r.ReleaseDirectory)
if err != nil {
conditions.MarkFalse(clusterStackRelease, csov1alpha1.ClusterStackReleaseAssetsReadyCondition, csov1alpha1.IssueWithReleaseAssetsReason, clusterv1.ConditionSeverityError, err.Error())
conditions.MarkFalse(clusterStackRelease,
csov1alpha1.ClusterStackReleaseAssetsReadyCondition,
csov1alpha1.IssueWithReleaseAssetsReason,
clusterv1.ConditionSeverityError, "%s", err.Error())
return reconcile.Result{RequeueAfter: 1 * time.Minute}, fmt.Errorf("failed to create release: %w", err)
}

Expand All @@ -127,9 +130,9 @@ func (r *ClusterStackReleaseReconciler) Reconcile(ctx context.Context, req recon
csov1alpha1.AssetsClientAPIAvailableCondition,
csov1alpha1.FailedCreateAssetsClientReason,
clusterv1.ConditionSeverityError,
err.Error(),
"%s", err.Error(),
)
record.Warnf(clusterStackRelease, "FailedCreateAssetsClient", err.Error())
record.Warn(clusterStackRelease, "FailedCreateAssetsClient", err.Error())

// give the assets client a second change
if isSet {
Expand Down
2 changes: 1 addition & 1 deletion pkg/assetsclient/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *realGhClient) ListRelease(ctx context.Context) ([]string, error) {
return nil, fmt.Errorf("failed to list releases: %w", err)
}

if response != nil && response.StatusCode != 200 {
if response != nil && response.StatusCode != http.StatusOK {
return nil, fmt.Errorf("got unexpected status from call to remote repository: %s", response.Status)
}

Expand Down

0 comments on commit 1eb880a

Please sign in to comment.