Skip to content

Commit

Permalink
Don't overwrite "dev.okteto.com/auto-ingress: private"if it is set as…
Browse files Browse the repository at this point in the history
… an stack annotation (#1448)

Signed-off-by: Pablo Chico de Guzman <pchico83@gmail.com>
  • Loading branch information
pchico83 committed Apr 23, 2021
1 parent ef70ac4 commit d25c0d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cmd/stack/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func translateStatefulSet(name string, s *model.Stack) *appsv1.StatefulSet {
func translateService(svcName string, s *model.Stack) *apiv1.Service {
svc := s.Services[svcName]
annotations := translateAnnotations(svc)
if s.Services[svcName].Public {
if s.Services[svcName].Public && annotations[okLabels.OktetoAutoIngressAnnotation] == "" {
annotations[okLabels.OktetoAutoIngressAnnotation] = "true"
}
return &apiv1.Service{
Expand Down
13 changes: 13 additions & 0 deletions pkg/cmd/stack/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,19 @@ func Test_translateService(t *testing.T) {
if result.Spec.Type != apiv1.ServiceTypeLoadBalancer {
t.Errorf("Wrong service type: '%s'", result.Spec.Type)
}

svc = s.Services["svcName"]
svc.Public = true
svc.Annotations[okLabels.OktetoAutoIngressAnnotation] = "private"
s.Services["svcName"] = svc
result = translateService("svcName", s)
annotations[okLabels.OktetoAutoIngressAnnotation] = "private"
if !reflect.DeepEqual(result.Annotations, annotations) {
t.Errorf("Wrong service annotations: '%s'", result.Annotations)
}
if result.Spec.Type != apiv1.ServiceTypeLoadBalancer {
t.Errorf("Wrong service type: '%s'", result.Spec.Type)
}
}

func Test_translateEndpoints(t *testing.T) {
Expand Down

0 comments on commit d25c0d5

Please sign in to comment.