diff --git a/charts/kubechecks/Chart.yaml b/charts/kubechecks/Chart.yaml index 38561574..cd791d3a 100644 --- a/charts/kubechecks/Chart.yaml +++ b/charts/kubechecks/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: kubechecks description: A Helm chart for kubechecks -version: 0.3.2 -appVersion: "1.0.10" +version: 0.4.0 +appVersion: "1.1.1" type: application maintainers: - name: zapier diff --git a/charts/kubechecks/templates/configmap.yaml b/charts/kubechecks/templates/configmap.yaml index 62e80910..78341e53 100644 --- a/charts/kubechecks/templates/configmap.yaml +++ b/charts/kubechecks/templates/configmap.yaml @@ -1,3 +1,4 @@ +{{ if .Values.configMap.create }} apiVersion: v1 kind: ConfigMap metadata: @@ -5,6 +6,7 @@ metadata: labels: {{ include "kubechecks.labels" . | indent 4 }} data: -{{- range $index, $element := .Values.deployment.env }} - {{ $index | quote }}: {{ $element | quote }} -{{- end }} \ No newline at end of file +{{- range $key, $value := .Values.configMap.env }} + {{ $key | quote }}: {{ $value | quote }} +{{- end }} +{{ end }} diff --git a/charts/kubechecks/templates/deployment.yaml b/charts/kubechecks/templates/deployment.yaml index 8788cdac..84c8611e 100644 --- a/charts/kubechecks/templates/deployment.yaml +++ b/charts/kubechecks/templates/deployment.yaml @@ -43,19 +43,20 @@ spec: args: {{ . | toYaml | nindent 12 }} {{- end }} envFrom: + {{- if .Values.configMap.create }} - configMapRef: name: {{ include "kubechecks.name" . }} + {{- end }} + {{- if .Values.secrets.create }} - secretRef: name: {{ include "kubechecks.secretsName" . }} - env: - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: KUBECHECKS_OTEL_COLLECTOR_HOST - valueFrom: - fieldRef: - fieldPath: status.hostIP + {{- end }} + {{- with .Values.deployment.envFrom }} + {{- . | toYaml | nindent 12 }} + {{- end }} + {{- with .Values.deployment.env }} + env: {{ . | toYaml | nindent 12 }} + {{- end }} ports: - name: {{ .Values.service.name }} containerPort: 8080 diff --git a/charts/kubechecks/templates/secrets.yaml b/charts/kubechecks/templates/secrets.yaml index 7009197c..2f2cd9dd 100644 --- a/charts/kubechecks/templates/secrets.yaml +++ b/charts/kubechecks/templates/secrets.yaml @@ -10,4 +10,4 @@ data: {{- range $k, $v := .Values.secrets.env }} {{ $k| quote }}: {{ $v | b64enc | quote }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/kubechecks/tests/basics.min-values.yaml b/charts/kubechecks/tests/basics.min-values.yaml index 6e252d4e..74d6b35c 100644 --- a/charts/kubechecks/tests/basics.min-values.yaml +++ b/charts/kubechecks/tests/basics.min-values.yaml @@ -1,4 +1,5 @@ -deployment: +configMap: + create: true env: KUBECHECKS_ARGOCD_API_INSECURE: "false" KUBECHECKS_TEST_VALUE: "Hello" @@ -6,4 +7,4 @@ deployment: ingress: create: true annotations: - kubernetes.io/ingress.class: an-ingress-class \ No newline at end of file + kubernetes.io/ingress.class: an-ingress-class diff --git a/charts/kubechecks/tests/basic_configmap_test.yaml b/charts/kubechecks/tests/configmap_test.yaml similarity index 100% rename from charts/kubechecks/tests/basic_configmap_test.yaml rename to charts/kubechecks/tests/configmap_test.yaml diff --git a/charts/kubechecks/tests/basic_deployment_test.yaml b/charts/kubechecks/tests/deployment_test.yaml similarity index 89% rename from charts/kubechecks/tests/basic_deployment_test.yaml rename to charts/kubechecks/tests/deployment_test.yaml index b9c7580b..387b758b 100644 --- a/charts/kubechecks/tests/basic_deployment_test.yaml +++ b/charts/kubechecks/tests/deployment_test.yaml @@ -150,3 +150,21 @@ tests: value: - name: test-volume path: /ghi + - it: can have new envFrom + set: + deployment: + envFrom: + - configMapRef: + name: new-configmap + - secretMap: + name: new-secret + asserts: + - equal: + path: spec.template.spec.containers[0].envFrom + value: + - configMapRef: + name: kubechecks + - configMapRef: + name: new-configmap + - secretMap: + name: new-secret diff --git a/charts/kubechecks/tests/basic_ingress_test.yaml b/charts/kubechecks/tests/ingress_test.yaml similarity index 100% rename from charts/kubechecks/tests/basic_ingress_test.yaml rename to charts/kubechecks/tests/ingress_test.yaml diff --git a/charts/kubechecks/values.schema.json b/charts/kubechecks/values.schema.json new file mode 100644 index 00000000..c6a64174 --- /dev/null +++ b/charts/kubechecks/values.schema.json @@ -0,0 +1,217 @@ +{ + "$defs": { + "key-value-map": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "type": "object", + "properties": { + "autoscaling": { + "type": "object", + "additionalProperties": false, + "properties": { + "create": { + "type": "boolean" + }, + "minReplicas": { + "type": "integer" + }, + "maxReplicas": { + "type": "integer" + }, + "targetCPUUtilizationPercentage": { + "type": "integer" + }, + "targetMemoryUtilizationPercentage": { + "type": "integer" + } + } + }, + "commonLabels": { + "$ref": "#/$defs/key-value-map" + }, + "deployment": { + "type": "object", + "additionalProperties": false, + "properties": { + "affinity": { + "type": "object" + }, + "annotations": { + "$ref": "#/$defs/key-value-map" + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "env": { + "type": "array" + }, + "envFrom": { + "type": "array" + }, + "image": { + "type": "object", + "additionalProperties": false, + "properties": { + "pullPolicy": { + "type": "string" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + }, + "required": [ + "name", + "pullPolicy", + "tag" + ] + }, + "imagePullSecrets": { + "type": "array" + }, + "livenessProbe": { + "type": "object" + }, + "nodeSelector": { + "type": "object" + }, + "podAnnotations": { + "$ref": "#/$defs/key-value-map" + }, + "podSecurityContext": { + "type": "object" + }, + "readinessProbe": { + "type": "object" + }, + "replicaCount": { + "type": "integer" + }, + "resources": { + "type": "object" + }, + "securityContext": { + "type": "object" + }, + "startupProbe": { + "type": "object" + }, + "tolerations": { + "type": "array" + }, + "volumes": { + "type": "array" + }, + "volumeMounts": { + "type": "array" + } + } + }, + "ingress": { + "type": "object", + "additionalProperties": false, + "properties": { + "annotations": { + "$ref": "#/$defs/key-value-map" + }, + "create": { + "type": "boolean" + }, + "className": { + "type": "string" + }, + "hosts": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": false, + "properties": { + "paths": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "type": "string" + }, + "pathType": { + "type": "string" + } + } + }, + "minItems": 1 + } + } + } + }, + "labels": { + "$ref": "#/$defs/key-value-map" + }, + "tls": { + "type": "array" + } + } + }, + "secrets": { + "type": "object", + "additionalProperties": false, + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "env": { + "$ref": "#/$defs/key-value-map" + } + } + }, + "service": { + "type": "object", + "additionalProperties": false, + "properties": { + "create": { + "type": "boolean" + }, + "type": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "serviceAccount": { + "type": "object", + "additionalProperties": false, + "properties": { + "annotations": { + "$ref": "#/$defs/key-value-map" + }, + "create": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + } + } +} diff --git a/charts/kubechecks/values.yaml b/charts/kubechecks/values.yaml index 8dfe6b4e..9a11138a 100644 --- a/charts/kubechecks/values.yaml +++ b/charts/kubechecks/values.yaml @@ -1,6 +1,24 @@ # Labels to apply to all resources created by this Helm chart commonLabels: {} +configMap: + create: false + env: {} + # KUBECHECKS_ARGOCD_API_INSECURE: "false" + # KUBECHECKS_ARGOCD_API_PATH_PREFIX: / + # KUBECHECKS_ARGOCD_WEBHOOK_URL: https://argocd./api/webhook + # KUBECHECKS_FALLBACK_K8S_VERSION: "1.22.0" + # KUBECHECKS_LOG_LEVEL: debug + # KUBECHECKS_NAMESPACE: kubechecks + # KUBECHECKS_WEBHOOK_URL_BASE: https://kubechecks.. + # KUBECHECKS_WEBHOOK_URL_PREFIX: kubechecks + # KUBECHECKS_ARGOCD_API_SERVER_ADDR: argocd. + # ARGOCD_EXEC_TIMEOUT: 600s + # KUBECHECKS_OTEL_COLLECTOR_PORT: "4317" + # KUBECHECKS_OTEL_ENABLED: "true" + # KUBECHECKS_VCS_TYPE: "github" + # KUBECHECKS_TIDY_OUTDATED_COMMENTS_MODE: "hide" # other options delete + deployment: annotations: {} # reloader.stakater.com/auto: "true" @@ -45,21 +63,9 @@ deployment: # - ALL # readOnlyRootFilesystem: false - env: - # KUBECHECKS_ARGOCD_API_INSECURE: "false" - # KUBECHECKS_ARGOCD_API_PATH_PREFIX: / - # KUBECHECKS_ARGOCD_WEBHOOK_URL: https://argocd./api/webhook - # KUBECHECKS_FALLBACK_K8S_VERSION: "1.22.0" - # KUBECHECKS_LOG_LEVEL: debug - # KUBECHECKS_NAMESPACE: kubechecks - # KUBECHECKS_WEBHOOK_URL_BASE: https://kubechecks.. - # KUBECHECKS_WEBHOOK_URL_PREFIX: kubechecks - # KUBECHECKS_ARGOCD_API_SERVER_ADDR: argocd. - # ARGOCD_EXEC_TIMEOUT: 600s - # KUBECHECKS_OTEL_COLLECTOR_PORT: "4317" - # KUBECHECKS_OTEL_ENABLED: "true" - # KUBECHECKS_VCS_TYPE: "github" - # KUBECHECKS_TIDY_OUTDATED_COMMENTS_MODE: "hide" # other options delete + env: [] + + envFrom: [] startupProbe: failureThreshold: 30 @@ -91,7 +97,6 @@ secrets: env: {} # KUBECHECKS_VCS_TOKEN: - serviceAccount: # Specifies whether a service account should be created or used create: true @@ -124,7 +129,6 @@ ingress: # hosts: # - kubechecks.example.com - autoscaling: create: false # minReplicas: 1 diff --git a/pkg/github_client/client.go b/pkg/github_client/client.go index 1ae9d832..c0c130ef 100644 --- a/pkg/github_client/client.go +++ b/pkg/github_client/client.go @@ -111,8 +111,8 @@ func (c *Client) CreateRepo(_ context.Context, payload interface{}) (*repo.Repo, switch p := payload.(type) { case *github.PullRequestEvent: switch p.GetAction() { - case "opened", "synchronize", "reopened": - log.Info().Str("action", p.GetAction()).Msg("handling Github open, sync event from PR") + case "opened", "synchronize", "reopened", "edited": + log.Info().Str("action", p.GetAction()).Msg("handling Github event from PR") return buildRepoFromEvent(p), nil default: log.Info().Str("action", p.GetAction()).Msg("ignoring Github pull request event due to non commit based action")