Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
barchw committed Dec 16, 2024
1 parent 4cdd0d6 commit eb998b5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
16 changes: 6 additions & 10 deletions api/v1alpha2/istio_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ import (
iopv1alpha1 "istio.io/istio/operator/pkg/apis"
)

const (
cpu string = "cpu"
memory string = "memory"
globalField = "global"
proxyField = "proxy"
resourcesField = "resources"
limitsField = "limits"
requestsField = "requests"
)

func (i *Istio) MergeInto(op iopv1alpha1.IstioOperator) (iopv1alpha1.IstioOperator, error) {
mergedConfigOp, err := i.mergeConfig(op)
if err != nil {
Expand Down Expand Up @@ -145,6 +135,9 @@ func (m *meshConfigBuilder) BuildExternalAuthorizerConfiguration(authorizers []*
}
var providerMap map[string]interface{}
err = json.Unmarshal(marshaledProvider, &providerMap)
if err != nil {
return nil
}

extensionProviders = append(extensionProviders, providerMap)
err = m.c.SetPath("extensionProviders", &extensionProviders)
Expand Down Expand Up @@ -292,6 +285,9 @@ func (i *Istio) mergeResources(op iopv1alpha1.IstioOperator) (iopv1alpha1.IstioO
}
}
op.Spec.Values, err = values.ConvertMap[json.RawMessage](valuesMap)
if err != nil {
return op, err
}
}

if i.Spec.Components.Cni != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/clusterconfig/clusterconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ func DiscoverClusterFlavour(ctx context.Context, k8sClient client.Client) (Clust
}

for _, node := range nodeList.Items {
if matcherGKE.MatchString(node.Status.NodeInfo.KubeProxyVersion) {
if matcherGKE.MatchString(node.Status.NodeInfo.KubeletVersion) {
return GKE, nil
} else if matcherk3d.MatchString(node.Status.NodeInfo.KubeProxyVersion) {
} else if matcherk3d.MatchString(node.Status.NodeInfo.KubeletVersion) {
return k3d, nil
} else if matcherGardener.MatchString(node.Status.NodeInfo.OSImage) {
return Gardener, nil
Expand Down
10 changes: 5 additions & 5 deletions internal/clusterconfig/clusterconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
)

const (
k3sMockKubeProxyVersion string = "v1.25.6+k3s1"
gkeMockKubeProxyVersion string = "v1.24.9-gke.3200"
k3sMockKubeletVersion string = "v1.26.6+k3s1"
gkeMockKubeletVersion string = "v1.30.6-gke.1125000"
)

var _ = Describe("GetClusterProvider", func() {
Expand All @@ -32,7 +32,7 @@ var _ = Describe("GetClusterProvider", func() {
Spec: corev1.NodeSpec{ProviderID: "kubernetes://asdadsads"},
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
KubeProxyVersion: k3sMockKubeProxyVersion,
KubeletVersion: k3sMockKubeletVersion,
},
},
}
Expand Down Expand Up @@ -73,7 +73,7 @@ var _ = Describe("EvaluateClusterConfiguration", func() {
},
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
KubeProxyVersion: k3sMockKubeProxyVersion,
KubeletVersion: k3sMockKubeletVersion,
},
},
}
Expand Down Expand Up @@ -107,7 +107,7 @@ var _ = Describe("EvaluateClusterConfiguration", func() {
},
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
KubeProxyVersion: gkeMockKubeProxyVersion,
KubeletVersion: gkeMockKubeletVersion,
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions internal/istiooperator/istiooperator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var _ = Describe("Merge", func() {

meshConfigSnakeCase := jsonTagsToSnakeCase(iop.Spec.MeshConfig)
err = json.Unmarshal([]byte(meshConfigSnakeCase), &meshConfigTyped)
Expect(err).ShouldNot(HaveOccurred())

numTrustedProxies := meshConfigTyped.DefaultConfig.GetGatewayTopology().GetNumTrustedProxies()
Expect(numTrustedProxies).To(Equal(numTrustedProxies))
Expand Down Expand Up @@ -133,6 +134,7 @@ var _ = Describe("Merge", func() {
snakeCaseMeshConfig := jsonTagsToSnakeCase(iop.Spec.MeshConfig)

err = json.Unmarshal([]byte(snakeCaseMeshConfig), &typedMeshConfig)
Expect(err).ShouldNot(HaveOccurred())

numTrustedProxies := typedMeshConfig.DefaultConfig.GetGatewayTopology().GetNumTrustedProxies()

Expand Down
13 changes: 6 additions & 7 deletions internal/istiooperator/merge_experimental_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/kyma-project/istio/operator/internal/istiooperator"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"istio.io/api/extensions/v1alpha1"
istiov1alpha1 "istio.io/istio/operator/pkg/apis"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -58,8 +57,8 @@ var _ = Describe("Merge", func() {
Expect(istiooperator.ParseExperimentalFeatures(&istioCR, &iop)).To(Succeed())
Expect(iop.Spec.Components.Pilot).ToNot(BeNil())
Expect(iop.Spec.Components.Pilot.Kubernetes.Env).To(ContainElements(
&v1alpha1.EnvVar{Name: "PILOT_ENABLE_ALPHA_GATEWAY_API", Value: "true"},
&v1alpha1.EnvVar{Name: "PILOT_MULTI_NETWORK_DISCOVER_GATEWAY_API", Value: "true"}))
&v1.EnvVar{Name: "PILOT_ENABLE_ALPHA_GATEWAY_API", Value: "true"},
&v1.EnvVar{Name: "PILOT_MULTI_NETWORK_DISCOVER_GATEWAY_API", Value: "true"}))
})
It("should update IstioOperator with managed environment variables when all experimental options are set to true and source struct is empty", func() {
istioCR := v1alpha2.Istio{ObjectMeta: metav1.ObjectMeta{
Expand All @@ -77,8 +76,8 @@ var _ = Describe("Merge", func() {
Expect(istiooperator.ParseExperimentalFeatures(&istioCR, &iop)).To(Succeed())
Expect(iop.Spec.Components.Pilot).ToNot(BeNil())
Expect(iop.Spec.Components.Pilot.Kubernetes.Env).To(ContainElements(
&v1alpha1.EnvVar{Name: "PILOT_ENABLE_ALPHA_GATEWAY_API", Value: "true"},
&v1alpha1.EnvVar{Name: "PILOT_MULTI_NETWORK_DISCOVER_GATEWAY_API", Value: "true"}))
&v1.EnvVar{Name: "PILOT_ENABLE_ALPHA_GATEWAY_API", Value: "true"},
&v1.EnvVar{Name: "PILOT_MULTI_NETWORK_DISCOVER_GATEWAY_API", Value: "true"}))
})
It("should update IstioOperator with managed environment variables when all experimental options are set to true source struct already contains those variables set to non-managed ones", func() {
istioCR := v1alpha2.Istio{ObjectMeta: metav1.ObjectMeta{
Expand All @@ -101,8 +100,8 @@ var _ = Describe("Merge", func() {
Expect(istiooperator.ParseExperimentalFeatures(&istioCR, &iop)).To(Succeed())
Expect(iop.Spec.Components.Pilot).ToNot(BeNil())
Expect(iop.Spec.Components.Pilot.Kubernetes.Env).To(ContainElements(
&v1alpha1.EnvVar{Name: "PILOT_ENABLE_ALPHA_GATEWAY_API", Value: "true"},
&v1alpha1.EnvVar{Name: "PILOT_MULTI_NETWORK_DISCOVER_GATEWAY_API", Value: "true"}))
&v1.EnvVar{Name: "PILOT_ENABLE_ALPHA_GATEWAY_API", Value: "true"},
&v1.EnvVar{Name: "PILOT_MULTI_NETWORK_DISCOVER_GATEWAY_API", Value: "true"}))
})
It("should succeed if experimental fields are not defined", func() {
istioCR := v1alpha2.Istio{ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit eb998b5

Please sign in to comment.