Skip to content

Commit

Permalink
Merge pull request #5 from hercynium/linter-improvements
Browse files Browse the repository at this point in the history
Make the linters happy
  • Loading branch information
hercynium authored Oct 13, 2024
2 parents 6782077 + 6d492c4 commit 6b85597
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
enable:
- dupl
- errcheck
- exportloopref
- copyloopvar
- goconst
- gocyclo
- gofmt
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# This variable is used to construct full image tags for bundle and catalog images.
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# sscaffidi/istio-fortsa-bundle:$VERSION and sscaffidi/istio-fortsa-catalog:$VERSION.
IMAGE_TAG_BASE ?= sscaffidi/istio-fortsa
# ghcr.io/hercynium/istio-fortsa-bundle:$VERSION and ghcr.io/hercynium/istio-fortsa-catalog:$VERSION.
IMAGE_TAG_BASE ?= ghcr.io/hercynium/istio-fortsa

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
Expand Down Expand Up @@ -209,10 +209,10 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
KUSTOMIZE_VERSION ?= v5.4.3
CONTROLLER_TOOLS_VERSION ?= v0.16.4 # v0.14.0
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.57.2
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
5 changes: 4 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ func main() {
//+kubebuilder:scaffold:builder

// populate the Istio Data before even starting the controllers
istioData.RefreshIstioData(context.TODO(), kubeClient)
if err := istioData.RefreshIstioData(context.TODO(), kubeClient); err != nil {
setupLog.Error(err, "unable to get initial istio data")
os.Exit(1)
}

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
Expand Down
2 changes: 1 addition & 1 deletion internal/util/istio/tags/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestGetTags(t *testing.T) {
[]runtime.Object{
invalidWebhook("invalid", "foo"),
namespace("default", "canary"),
namespace("test1", "canary"),
namespace("test1", "stable"),
},
},
{
Expand Down
15 changes: 12 additions & 3 deletions internal/util/k8s/rollout/rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func DoRolloutRestart(ctx context.Context, client ctrlclient.Client, obj ctrlcli
switch obj.GetObjectKind().GroupVersionKind().Kind {
case "Deployment":
objX := &appsv1.Deployment{}
client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX)
err := client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX)
if err != nil {
return err
}
patch := ctrlclient.StrategicMergeFrom(objX.DeepCopy())
if objX.Spec.Template.ObjectMeta.Annotations == nil {
objX.Spec.Template.ObjectMeta.Annotations = make(map[string]string)
Expand All @@ -44,7 +47,10 @@ func DoRolloutRestart(ctx context.Context, client ctrlclient.Client, obj ctrlcli
return client.Patch(ctx, objX, patch)
case "DaemonSet":
objX := &appsv1.DaemonSet{}
client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX)
err := client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX)
if err != nil {
return err
}
patch := ctrlclient.StrategicMergeFrom(objX.DeepCopy())
if objX.Spec.Template.ObjectMeta.Annotations == nil {
objX.Spec.Template.ObjectMeta.Annotations = make(map[string]string)
Expand All @@ -55,7 +61,10 @@ func DoRolloutRestart(ctx context.Context, client ctrlclient.Client, obj ctrlcli
return client.Patch(ctx, objX, patch)
case "StatefulSet":
objX := &appsv1.StatefulSet{}
client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX)
err := client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX)
if err != nil {
return err
}
patch := ctrlclient.StrategicMergeFrom(objX.DeepCopy())
if objX.Spec.Template.ObjectMeta.Annotations == nil {
objX.Spec.Template.ObjectMeta.Annotations = make(map[string]string)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ import (
// Run e2e tests using the Ginkgo runner.
func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
fmt.Fprintf(GinkgoWriter, "Starting istio-fortsa suite\n")
_, _ = fmt.Fprintf(GinkgoWriter, "Starting istio-fortsa suite\n")
RunSpecs(t, "e2e suite")
}
24 changes: 6 additions & 18 deletions test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,13 @@ const (
certmanagerVersion = "v1.14.4"
certmanagerURLTmpl = "https://github.com/jetstack/cert-manager/releases/download/%s/cert-manager.yaml"

istio1Version = "1.22.4"
istioHelmChartRepo = "https://istio-release.storage.googleapis.com/charts"
istio2Version = "1.23.1"
//istio1Version = "1.22.4"
//istioHelmChartRepo = "https://istio-release.storage.googleapis.com/charts"
//istio2Version = "1.23.1"
)

/*
kind delete cluster
kind create cluster --config kind-config.yaml
kubectl create ns istio-system
helm install istio-base-v1-22-4 https://istio-release.storage.googleapis.com/charts/base-1.22.4.tgz -n istio-system --set revision=test-1
helm install istio-istiod-v1-22-4 https://istio-release.storage.googleapis.com/charts/istiod-1.22.4.tgz -n istio-system --set pilot.resources.requests.cpu=100m --set pilot.resources.requests.memory=128m --set revision=test-1
helm install istio-istiod-v1-23-1 https://istio-release.storage.googleapis.com/charts/istiod-1.23.1.tgz -n istio-system --set pilot.resources.requests.cpu=100m --set pilot.resources.requests.memory=256m --set revision=test-2
*/

func warnError(err error) {
fmt.Fprintf(GinkgoWriter, "warning: %v\n", err)
_, _ = fmt.Fprintf(GinkgoWriter, "warning: %v\n", err)
}

// InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics.
Expand All @@ -68,12 +56,12 @@ func Run(cmd *exec.Cmd) ([]byte, error) {
cmd.Dir = dir

if err := os.Chdir(cmd.Dir); err != nil {
fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err)
_, _ = fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err)
}

cmd.Env = append(os.Environ(), "GO111MODULE=on")
command := strings.Join(cmd.Args, " ")
fmt.Fprintf(GinkgoWriter, "running: %s\n", command)
_, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command)
output, err := cmd.CombinedOutput()
if err != nil {
return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output))
Expand Down

0 comments on commit 6b85597

Please sign in to comment.