Skip to content

Commit

Permalink
fix: make broker servicename k8s api compliant[HYB-584] (#124)
Browse files Browse the repository at this point in the history
* fix: make broker servicename k8s api compliant

* fix: updating chart version
  • Loading branch information
saumilmac authored Aug 29, 2024
1 parent 2e16f97 commit df30110
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion charts/snyk-broker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: snyk-broker
version: 2.7.5
version: 2.7.6
description: A Helm chart for Kubernetes
type: application
8 changes: 6 additions & 2 deletions charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ Create the name of the broker service to use
*/}}
{{- define "snyk-broker.brokerServiceName" -}}
{{- if not .Values.disableSuffixes -}}
{{- .Values.scmType }}-broker-service-{{ .Release.Name }}
{{- $service := "-broker-service-" -}}
{{- $serviceLength := len $service -}}
{{- $releaseNameLength := len .Release.Name -}}
{{- $truncatedLength := int (sub 63 (add $serviceLength $releaseNameLength)) -}}
{{- .Values.scmType | trunc $truncatedLength }}{{ $service }}{{ .Release.Name }}
{{- else }}
{{- .Values.scmType}}-broker-service
{{- .Values.scmType | trunc 47 }}-broker-service
{{- end -}}
{{- end -}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ templates:
- broker_service.yaml
- secrets.yaml
- serviceaccount.yaml
values:
- ./fixtures/default_values.yaml

tests:
- it: default values
Expand Down
2 changes: 0 additions & 2 deletions charts/snyk-broker/tests/broker_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ templates:
- broker_service.yaml
- secrets.yaml
- serviceaccount.yaml
values:
- ./fixtures/default_values.yaml

tests:
- it: default values
Expand Down
16 changes: 16 additions & 0 deletions charts/snyk-broker/tests/broker_servicename_length_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
suite: test broker servicename length
chart:
version: 0.0.0
templates:
- broker_service.yaml

tests:
- it: should truncate scmType correctly when combined with release name and suffix
values:
- ./fixtures/default_values_cra.yaml
release:
name: "myrelease-really-long-release-name"
asserts:
- equal:
path: metadata.name
value: "container-reg-broker-service-myrelease-really-long-release-name"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Broker Token is a value from Snyk. Get this from the integration settings page or your Snyk Representative
brokerToken: "12345a6b-78d9-1e2f-3abc-456def789123"

snykToken: "12345a6b-78d9-1e2f-3abc-456def789123"
# brokerClientUrl is the address of the broker. This needs to be the address of itself. In the case of Kubernetes, you need to ensure that you are pointing to the cluster ingress you have setup.
# Ex: http://kubernetes-ingress.domain.com:8000/broker
brokerClientUrl: "http://brokerclient"
Expand Down
3 changes: 3 additions & 0 deletions charts/snyk-broker/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
},
"additionalProperties": false
},
"disableSuffixes": {
"type": "boolean"
},
"brokerDispatcherUrl": {
"type": "string",
"default": "https://api.snyk.io",
Expand Down
4 changes: 4 additions & 0 deletions charts/snyk-broker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ replicaCount: 2
# Adds additional labels to broker deployment
labels: {}

# Beginning with version 2.0.0, all created objects have a suffix based on the release name, allowing for multiple Brokers in the same namespace.
# For backward compatibility, version 2.1.0 introduces a disableSuffixes flag to revert to the 1.x.x behavior.
disableSuffixes: false

##### SCM Generic #####

# scmType is used to define the Source Control that you are connecting to.
Expand Down

0 comments on commit df30110

Please sign in to comment.