Skip to content

Commit

Permalink
fix e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: shubhindia <shubhindia123@gmail.com>
  • Loading branch information
shubhindia committed Oct 24, 2023
1 parent 72d29bd commit 0504cd0
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 144 deletions.
8 changes: 3 additions & 5 deletions pkg/transformer/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ func ConfigAnnotations(service kobject.ServiceConfig) map[string]string {
// Print either prints to stdout or to file/s
func Print(name, path string, trailing string, data []byte, toStdout, generateJSON bool, f *os.File, provider string) (string, error) {
file := ""
// simple hack to remove status from the output
re := regexp.MustCompile(`(?s)status:.*`)
data = re.ReplaceAll(data, nil)
if generateJSON {
file = fmt.Sprintf("%s-%s.json", name, trailing)
} else {
Expand All @@ -292,11 +295,6 @@ func Print(name, path string, trailing string, data []byte, toStdout, generateJS
} else {
// Write content separately to each file
file = filepath.Join(path, file)

// simple hack to remove status from the output
re := regexp.MustCompile(`(?s)status:.*`)
data = re.ReplaceAll(data, nil)

if err := os.WriteFile(file, data, 0644); err != nil {
return "", errors.Wrap(err, "Failed to write %s: "+trailing)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ spec:
targetPort: 0
selector:
io.kompose.service: redis
status:
loadBalancer: {}

---
apiVersion: v1
Expand All @@ -36,8 +34,6 @@ spec:
targetPort: 5000
selector:
io.kompose.service: web
status:
loadBalancer: {}

---
apiVersion: apps/v1
Expand Down Expand Up @@ -70,7 +66,6 @@ spec:
name: redis
resources: {}
restartPolicy: Always
status: {}

---
apiVersion: apps/v1
Expand Down Expand Up @@ -112,6 +107,4 @@ spec:
restartPolicy: Always
volumes:
- emptyDir: {}
name: code-volume
status: {}

name: code-volume
12 changes: 1 addition & 11 deletions script/test/fixtures/change-in-volume/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ spec:
targetPort: 0
selector:
io.kompose.service: redis
status:
loadBalancer: {}

---
apiVersion: v1
kind: Service
Expand All @@ -36,9 +33,6 @@ spec:
targetPort: 5000
selector:
io.kompose.service: web
status:
loadBalancer: {}

---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -70,8 +64,6 @@ spec:
name: redis
resources: {}
restartPolicy: Always
status: {}

---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -112,6 +104,4 @@ spec:
restartPolicy: Always
volumes:
- emptyDir: {}
name: code-volume
status: {}

name: code-volume
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ spec:
name: foo
resources: {}
restartPolicy: Always
status: {}

---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
Expand Down
7 changes: 1 addition & 6 deletions script/test/fixtures/compose-file-support/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ spec:
targetPort: 80
selector:
io.kompose.service: web
status:
loadBalancer: {}

---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -47,6 +44,4 @@ spec:
hostPort: 80
protocol: TCP
resources: {}
restartPolicy: Always
status: {}

restartPolicy: Always
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ spec:
path: configs.tar
name: db-cm0
name: db-cm0
status: {}

---
apiVersion: v1
binaryData:
Expand Down Expand Up @@ -105,8 +103,6 @@ spec:
path: test-a-key.key
name: web-cm1
name: web-cm1
status: {}

---
apiVersion: v1
data:
Expand Down
3 changes: 0 additions & 3 deletions script/test/fixtures/configmap-volume/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ spec:
path: configs.tar
name: db-cm0
name: db-cm0
status: {}

---
apiVersion: v1
Expand Down Expand Up @@ -97,8 +96,6 @@ spec:
path: test-a-key.key
name: web-cm1
name: web-cm1
status: {}

---
apiVersion: v1
data:
Expand Down
2 changes: 0 additions & 2 deletions script/test/fixtures/custom-build-push/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ spec:
name: nginx
resources: {}
restartPolicy: Always
status: {}

---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ spec:
targetPort: 6379
selector:
io.kompose.service: redis
status:
loadBalancer: {}

---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -77,5 +74,3 @@ spec:
maxSkew: 1
topologyKey: ssd
whenUnsatisfiable: ScheduleAnyway
status: {}

39 changes: 26 additions & 13 deletions script/test/fixtures/env/output-k8s.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.kompose.service: another-namenode
name: another-namenode
spec:
ports:
- name: "50070"
port: 50070
targetPort: 50070
- name: "8020"
port: 8020
targetPort: 8020
selector:
io.kompose.service: another-namenode
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.kompose.service: namenode
name: namenode
namespace: default
spec:
ports:
- name: "50070"
Expand All @@ -17,9 +34,6 @@ spec:
targetPort: 8020
selector:
io.kompose.service: namenode
status:
loadBalancer: {}

---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -28,7 +42,6 @@ metadata:
labels:
io.kompose.service: another-namenode
name: another-namenode
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -56,10 +69,15 @@ spec:
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
name: another-namenode
ports:
- containerPort: 50070
hostPort: 50070
protocol: TCP
- containerPort: 8020
hostPort: 8020
protocol: TCP
resources: {}
restartPolicy: Always
status: {}

---
apiVersion: v1
data:
Expand All @@ -71,8 +89,6 @@ metadata:
labels:
io.kompose.service: another-namenode-home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
namespace: default

---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -81,7 +97,6 @@ metadata:
labels:
io.kompose.service: namenode
name: namenode
namespace: default
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -119,6 +134,4 @@ spec:
hostPort: 8020
protocol: TCP
resources: {}
restartPolicy: Always
status: {}

restartPolicy: Always
2 changes: 1 addition & 1 deletion script/test/fixtures/envvars-interpolation/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ spec:
name: myservice
resources: {}
restartPolicy: Always
status: {}


13 changes: 5 additions & 8 deletions script/test/fixtures/expose/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ spec:
targetPort: 6379
selector:
io.kompose.service: redis
status:
loadBalancer: {}


---
apiVersion: v1
Expand All @@ -37,8 +36,7 @@ spec:
targetPort: 5000
selector:
io.kompose.service: web
status:
loadBalancer: {}


---
apiVersion: apps/v1
Expand Down Expand Up @@ -70,7 +68,7 @@ spec:
protocol: TCP
resources: {}
restartPolicy: Always
status: {}


---
apiVersion: apps/v1
Expand Down Expand Up @@ -111,7 +109,7 @@ spec:
protocol: TCP
resources: {}
restartPolicy: Always
status: {}


---
apiVersion: networking.k8s.io/v1
Expand Down Expand Up @@ -154,6 +152,5 @@ spec:
- batman.example.com
- batwoman.example.com
secretName: test-secret
status:
loadBalancer: {}


Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ spec:
selector:
io.kompose.service: front-end
type: LoadBalancer
status:
loadBalancer: {}


---
apiVersion: apps/v1
Expand Down Expand Up @@ -68,5 +67,5 @@ spec:
protocol: TCP
resources: {}
restartPolicy: Always
status: {}


Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ spec:
selector:
io.kompose.service: front-end
type: ClusterIP
status:
loadBalancer: {}


---
apiVersion: apps/v1
Expand Down Expand Up @@ -68,7 +67,7 @@ spec:
protocol: TCP
resources: {}
restartPolicy: Always
status: {}


---
apiVersion: networking.k8s.io/v1
Expand Down Expand Up @@ -97,6 +96,5 @@ spec:
number: 80
path: /
pathType: Prefix
status:
loadBalancer: {}


4 changes: 2 additions & 2 deletions script/test/fixtures/fsgroup/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- name: pgadmin-data
persistentVolumeClaim:
claimName: pgadmin-data
status: {}


---
apiVersion: v1
Expand All @@ -59,7 +59,7 @@ spec:
resources:
requests:
storage: 100Mi
status: {}


---
apiVersion: networking.k8s.io/v1
Expand Down
Loading

0 comments on commit 0504cd0

Please sign in to comment.