Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1660 from ibuildthecloud/dev-ports
Browse files Browse the repository at this point in the history
Make service default a bit more explicit
  • Loading branch information
ibuildthecloud committed May 25, 2023
2 parents 000c93c + ff24fa0 commit c44ac8e
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
spec:
appName: app-name
appNamespace: app-namespace
default: true
default: false
external: app-name.acorn-name
annotations:
allacornsa: value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
spec:
appName: app-name
appNamespace: app-namespace
default: true
default: false
labels:
"acorn.io/app-namespace": "app-namespace"
"acorn.io/app-name": "app-name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
spec:
appName: app-name
appNamespace: app-namespace
default: true
default: false
container: oneimage
labels:
"acorn.io/app-namespace": "app-namespace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
"acorn.io/container-name": "oneimage"
"acorn.io/public-name": "app-name.oneimage"
spec:
default: true
default: false
appName: app-name
appNamespace: app-namespace
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
"acorn.io/container-name": "oneimage"
"acorn.io/public-name": "app-name.oneimage"
spec:
default: true
default: false
appName: app-name
appNamespace: app-namespace
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
spec:
appName: app-name
appNamespace: app-namespace
default: true
default: false
container: oneimage
labels:
"acorn.io/app-namespace": "app-namespace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ spec:
"acorn.io/app-name": "app-name"
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
default: true
default: false
container: oneimage
type: ClusterIP
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
spec:
appName: app-name
appNamespace: app-namespace
default: true
default: false
external: app-name.acorn-name
labels:
"acorn.io/app-namespace": "app-namespace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/container-name": "oneimage"
"acorn.io/managed": "true"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
"cona3": "value"
"globala1": "value"
"globala2": "value"
default: true
default: false
container: con1
ports:
- port: 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
"cona3": "value"
"globala1": "value"
"globala2": "value"
default: true
default: false
container: con1
ports:
- port: 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
"acorn.io/managed": "true"
"acorn.io/public-name": "app-name.con1"
spec:
default: true
default: false
appName: app-name
appNamespace: app-namespace
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "twoimage"
container: twoimage
default: true
default: false
type: ClusterIP
ports:
- port: 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "twoimage"
container: twoimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
"acorn.io/managed": "true"
"acorn.io/container-name": "oneimage"
container: oneimage
default: true
default: false
ports:
- port: 80
targetPort: 81
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
appName: app-name
appNamespace: app-namespace
publishMode: all
default: false
default: true
labels:
acorn.io/app-name: app-name
acorn.io/app-namespace: app-namespace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
kind: Service
apiVersion: v1
metadata:
name: app-name
namespace: app-namespace
labels:
acorn.io/app-name: app-name
acorn.io/app-namespace: app-namespace
acorn.io/managed: "true"
acorn.io/router-name: router-name
spec:
ports:
- appProtocol: HTTP
name: "80"
port: 80
protocol: TCP
targetPort: 8080
type: ExternalName
externalName: router-name.app-created-namespace.svc.cluster.local
---

kind: Service
apiVersion: v1
metadata:
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/service/testdata/router/input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
publishMode: all
appName: app-name
appNamespace: app-namespace
default: true
default: false
routes:
- pathType: exact
path: /foo
Expand Down
18 changes: 13 additions & 5 deletions pkg/services/acorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,19 @@ func ToAcornServices(ctx context.Context, c kclient.Client, appInstance *v1.AppI
if err != nil {
return nil, err
}

defaultFound := false
for _, obj := range objs {
if defaultFound {
obj.(*v1.ServiceInstance).Spec.Default = false
} else if obj.(*v1.ServiceInstance).Spec.Default {
defaultFound = true
}
}
if !defaultFound && len(objs) > 0 {
objs[0].(*v1.ServiceInstance).Spec.Default = true
}

result = append(result, objs...)
result = append(result, forAcorns(appInstance)...)
result = append(result, forContainers(appInstance)...)
Expand All @@ -294,11 +307,6 @@ func ToAcornServices(ctx context.Context, c kclient.Client, appInstance *v1.AppI
}
result = append(result, routers...)

// determine default before adding linked services
if len(result) == 1 {
result[0].(*v1.ServiceInstance).Spec.Default = true
}

result = append(result, forLinkedServices(appInstance)...)
return
}

0 comments on commit c44ac8e

Please sign in to comment.