Skip to content

Commit

Permalink
Update e2e tests (#1538)
Browse files Browse the repository at this point in the history
* fix: update ingress class name assign
  • Loading branch information
AhmedGrati authored Nov 21, 2022
1 parent af82f7e commit 36593e8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pkg/kobject/kobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ type ServiceConfig struct {
ExposeServicePath string `compose:"kompose.service.expose.path"`
BuildLabels map[string]string `compose:"build-labels"`
ExposeServiceTLS string `compose:"kompose.service.expose.tls-secret"`
ExposeServiceIngressClassName *string `compose:"kompose.service.expose.ingress-class-name"`
ExposeServiceIngressClassName string `compose:"kompose.service.expose.ingress-class-name"`
ImagePullSecret string `compose:"kompose.image-pull-secret"`
Stdin bool `compose:"stdin_open"`
Tty bool `compose:"tty"`
Expand Down
7 changes: 2 additions & 5 deletions pkg/loader/compose/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
// Again, in v3, we use the "long syntax" for volumes in terms of parsing
// https://docs.docker.com/compose/compose-file/#long-syntax-3
serviceConfig.VolList = loadV3Volumes(composeServiceConfig.Volumes)

if err := parseKomposeLabels(composeServiceConfig.Labels, &serviceConfig); err != nil {
return kobject.KomposeObject{}, err
}
Expand All @@ -538,7 +537,6 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
}

handleV3Volume(&komposeObject, &composeObject.Volumes)

return komposeObject, nil
}

Expand Down Expand Up @@ -652,7 +650,6 @@ func parseKomposeLabels(labels map[string]string, serviceConfig *kobject.Service
// Label handler
// Labels used to influence conversion of kompose will be handled
// from here for docker-compose. Each loader will have such handler.

if serviceConfig.Labels == nil {
serviceConfig.Labels = make(map[string]string)
}
Expand All @@ -673,7 +670,7 @@ func parseKomposeLabels(labels map[string]string, serviceConfig *kobject.Service
case LabelServiceExposeTLSSecret:
serviceConfig.ExposeServiceTLS = value
case LabelServiceExposeIngressClassName:
serviceConfig.ExposeServiceIngressClassName = &value
serviceConfig.ExposeServiceIngressClassName = value
case LabelImagePullSecret:
serviceConfig.ImagePullSecret = value
case LabelImagePullPolicy:
Expand All @@ -687,7 +684,7 @@ func parseKomposeLabels(labels map[string]string, serviceConfig *kobject.Service
return errors.New("kompose.service.expose.tls-secret was specified without kompose.service.expose")
}

if serviceConfig.ExposeService == "" && serviceConfig.ExposeServiceIngressClassName != nil {
if serviceConfig.ExposeService == "" && serviceConfig.ExposeServiceIngressClassName != "" {
return errors.New("kompose.service.expose.ingress-class-name was specified without kompose.service.expose")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/transformer/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ func (k *Kubernetes) initIngress(name string, service kobject.ServiceConfig, por
}
}

if service.ExposeServiceIngressClassName != nil {
ingress.Spec.IngressClassName = service.ExposeServiceIngressClassName
if service.ExposeServiceIngressClassName != "" {
ingress.Spec.IngressClassName = &service.ExposeServiceIngressClassName
}

return ingress
Expand Down
30 changes: 16 additions & 14 deletions script/test/fixtures/expose/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
web:
image: tuna/docker-counter23
ports:
- "5000:5000"
links:
- redis
labels:
kompose.service.expose: "batman.example.com/dev,batwoman.example.com"
kompose.service.expose.tls-secret: "test-secret"
kompose.service.expose.ingress-class-name: "nginx"
redis:
image: redis:3.0
ports:
- "6379"
version: '3.5'
services:
web:
image: tuna/docker-counter23
ports:
- "5000:5000"
links:
- redis
labels:
kompose.service.expose: "batman.example.com/dev,batwoman.example.com"
kompose.service.expose.tls-secret: "test-secret"
kompose.service.expose.ingress-class-name: "nginx"
redis:
image: redis:3.0
ports:
- "6379"
6 changes: 3 additions & 3 deletions script/test/fixtures/expose/output-ocp.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"imageChangeParams": {
"automatic": true,
"containerNames": [
"redis"
"redis"
],
"from": {
"kind": "ImageStreamTag",
Expand Down Expand Up @@ -146,7 +146,7 @@
},
"tags": [
{
"name": "latest",
"name": "3.0",
"annotations": null,
"from": {
"kind": "DockerImage",
Expand Down Expand Up @@ -192,7 +192,7 @@
"imageChangeParams": {
"automatic": true,
"containerNames": [
"web"
"web"
],
"from": {
"kind": "ImageStreamTag",
Expand Down
6 changes: 4 additions & 2 deletions script/test/fixtures/service-group/output-k8s.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
],
"env": [
{
"name": "TZ"
"name": "TZ",
"value": "${TZ}"
}
],
"resources": {},
Expand All @@ -89,7 +90,8 @@
"image": "librenms/dispatcher:latest",
"env": [
{
"name": "TZ"
"name": "TZ",
"value": "${TZ}"
}
],
"resources": {},
Expand Down
2 changes: 1 addition & 1 deletion script/test/fixtures/statefulset/output-os.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
},
"tags": [
{
"name": "latest",
"name": "5.7",
"annotations": null,
"from": {
"kind": "DockerImage",
Expand Down
2 changes: 1 addition & 1 deletion script/test/fixtures/v2/output-os.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
},
"tags": [
{
"name": "latest",
"name": "3.0",
"annotations": null,
"from": {
"kind": "DockerImage",
Expand Down

0 comments on commit 36593e8

Please sign in to comment.