Skip to content

Commit

Permalink
fix golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
anoipm committed Apr 25, 2024
1 parent 8a0cb99 commit 309523d
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions components/operator/controllers/testhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,6 @@ func (h *testHelper) createNamespace() {
By(fmt.Sprintf("Namespace created: %s", h.namespaceName))
}

func (h *testHelper) createSecret(name string, data map[string]string) {
By(fmt.Sprintf("Creating secret: %s/%s", h.namespaceName, name))
secret := corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: h.namespaceName,
},
StringData: data,
}
Expect(k8sClient.Create(h.ctx, &secret)).To(Succeed())
By(fmt.Sprintf("Secret created: %s/%s", h.namespaceName, name))
}

func (h *testHelper) createRegistrySecret(name string, data registrySecretData) {
secretData := data.toMap()
h.createSecret(name, secretData)
}

func (h *testHelper) getKubernetesObjectFunc(objectName string, obj client.Object) func() (bool, error) {
return func() (bool, error) {
return h.getKubernetesObject(objectName, obj)
Expand Down Expand Up @@ -279,51 +261,6 @@ func (h *testHelper) createCheckRegistrySecretFunc(registrySecret string, expect
}
}

func (h *testHelper) createCheckOptionalDependenciesFunc(deploymentName string, expected dockerRegistryData) func() (bool, error) {
return func() (bool, error) {
var deploy appsv1.Deployment
ok, err := h.getKubernetesObject(deploymentName, &deploy)
if !ok || err != nil {
return ok, err
}

eventProxyURL := v1alpha1.DefaultEventingEndpoint
if expected.EventPublisherProxyURL != nil {
eventProxyURL = *expected.EventPublisherProxyURL
}

traceCollectorURL := v1alpha1.EndpointDisabled
if expected.TraceCollectorURL != nil {
traceCollectorURL = *expected.TraceCollectorURL
}

if err := deploymentContainsEnv(deploy, "APP_FUNCTION_PUBLISHER_PROXY_ADDRESS", eventProxyURL); err != nil {
return false, err
}

if err := deploymentContainsEnv(deploy, "APP_FUNCTION_TRACE_COLLECTOR_ENDPOINT", traceCollectorURL); err != nil {
return false, err
}

return true, nil
}
}

func deploymentContainsEnv(deployment appsv1.Deployment, name, value string) error {
envs := deployment.Spec.Template.Spec.Containers[0].Env
for i := range envs {
if envs[i].Name == name && envs[i].Value == value {
return nil
}

if envs[i].Name == name && envs[i].Value != value {
return fmt.Errorf("wrong value for %s env: expected %s, got %s", name, value, envs[i].Value)
}
}

return fmt.Errorf("env %s does not exist", name)
}

func secretContainsRequired(configurationSecret corev1.Secret) (bool, error) {
for _, k := range []string{"username", "password", "pullRegAddr", "pushRegAddr", ".dockerconfigjson"} {
_, ok := configurationSecret.Data[k]
Expand Down

0 comments on commit 309523d

Please sign in to comment.