Compare commits

...

54 Commits

Author SHA1 Message Date
Muhammad Safwan Karim
32ac22dc33 Merge pull request #1063 from stakater/bump-chart
Bump Chart Version
2025-12-10 21:50:03 +05:00
Safwan
3afe895045 bump chart 2025-12-10 17:17:28 +05:00
Safwan
64a18ff207 buno version 2025-12-10 17:10:27 +05:00
Muhammad Safwan Karim
b71fb19882 Merge pull request #1061 from MatthiasWerning/bugfix/controller-init
Fix configmaps key in ResourceMap leading to controllers not being able to mark themselves as initialized
2025-12-10 15:35:31 +05:00
Matthias Werning
27fb47ff52 Fix configmaps key in ResourceMap leading to controllers not being able to mark themselves as initialized 2025-12-10 09:10:52 +01:00
Muhammad Safwan Karim
d409b79a11 Merge pull request #1049 from Wamgleb/fix-pause-annotation-bug
fix:Rename pause-deployment-annotation to pause-deployment-time-annot…
2025-11-14 21:50:22 +05:00
Muhammad Safwan Karim
c3546066fa Merge pull request #1052 from artemptushkin/patch-1
Fix issue in yaml path
2025-11-14 21:48:00 +05:00
Muhammad Safwan Karim
7080ec27cc Merge pull request #1032 from arizon-dread/fix-openshift-runAsUser-documentation
fix the value reference to runAsUser for OpenShift
2025-11-13 18:13:54 +05:00
Artem Ptushkin
6f1ecffb25 Fix issue in yaml path
It requires `deployment` actually, see https://artifacthub.io/packages/helm/stakater/reloader?modal=values
2025-11-12 16:04:24 +01:00
Hlib Kalinchuk
765053f21e fix:Rename pause-deployment-annotation to pause-deployment-time-annotation in deployment.yaml 2025-11-07 14:36:59 +02:00
Muhammad Safwan Karim
fd9b7e2c1f Merge pull request #1046 from stakater/update-chart-2.2.5
Bump chart
2025-11-05 17:19:58 +05:00
Muhammad Safwan Karim
bfb720e9e9 Bump chart 2025-11-05 16:13:37 +05:00
Muhammad Safwan Karim
9607da6d8a Merge pull request #1042 from stakater/upgrade-to-go-1.25
Upgradde to go 1.25.3 (latest)
2025-11-05 14:54:46 +05:00
Safwan
32046ebfe0 Fixed spelling 2025-11-05 14:04:49 +05:00
Safwan
5d4b9f5a32 Resolved comments 2025-11-05 14:02:06 +05:00
Felix Tonnvik
620959a03b updated qa link-check to retry on status 429 2025-11-05 09:54:04 +01:00
Safwan
008c45e9ac fixed markdown lint indentation 2025-11-05 13:21:45 +05:00
Safwan
fa201d9762 Clarification about workflow in the readme 2025-11-05 13:09:04 +05:00
Safwan
174b57cdad Fixed linting 2025-11-04 17:39:24 +05:00
Safwan
4476fad274 Update golangci-lint version in workflow 2025-11-04 17:04:40 +05:00
Safwan
16b26be5c2 Upgradde to go 1.25.3 (latest) 2025-11-04 17:01:38 +05:00
Muhammad Safwan Karim
7c429714ae Merge pull request #1023 from stakater/renovate/github.com-argoproj-argo-rollouts-1.x
fix(deps): update module github.com/argoproj/argo-rollouts to v1.8.3
2025-11-04 14:49:38 +05:00
Muhammad Safwan Karim
64c3d8487b Merge pull request #1025 from stakater/renovate/python-3.x
chore(deps): update python docker tag to v3.14
2025-11-04 14:49:04 +05:00
Muhammad Safwan Karim
405069e691 Merge pull request #1039 from stakater/helm/release-2.2.4
Bump chart
2025-11-04 14:47:22 +05:00
Muhammad Safwan Karim
4694b7570e Bump chart 2025-11-04 14:40:54 +05:00
Muhammad Safwan Karim
3a9ca713bb Merge pull request #1037 from stakater/renovate/ghcr.io-stakater-reloader-1.x
chore(deps): update ghcr.io/stakater/reloader docker tag to v1.4.9
2025-11-04 14:37:12 +05:00
renovate[bot]
3de9c688f2 chore(deps): update ghcr.io/stakater/reloader docker tag to v1.4.9 2025-11-04 09:31:37 +00:00
Muhammad Safwan Karim
90b9713b7f Merge pull request #1027 from stakater/renovate/github.com-spf13-cobra-1.x
fix(deps): update module github.com/spf13/cobra to v1.10.1
2025-11-04 14:30:46 +05:00
Muhammad Safwan Karim
9139f838cf Merge pull request #1029 from stakater/renovate/actions-checkout-5.x
chore(deps): update actions/checkout action to v5
2025-11-04 14:28:30 +05:00
Muhammad Safwan Karim
59738b2d6d Merge pull request #1031 from stakater/renovate/sigstore-cosign-installer-4.x
chore(deps): update sigstore/cosign-installer action to v4
2025-11-04 14:26:34 +05:00
Muhammad Safwan Karim
91bdb47dad Merge pull request #1030 from stakater/renovate/actions-setup-go-6.x
chore(deps): update actions/setup-go action to v6
2025-11-04 14:26:07 +05:00
Felix Tonnvik
2835e5952f Merge pull request #1035 from stakater/release-v1.4.9
Release v1.4.9
2025-11-04 09:43:21 +01:00
Felix Tonnvik
cadf4489e8 Merge branch 'master' into release-v1.4.9 2025-11-03 18:05:44 +01:00
Felix Tonnvik
32f83fabc9 Merge pull request #1034 from stakater/update-version-g213t1o
Bump version to 1.4.9 on release-v1.4.9 branch
2025-11-03 18:00:49 +01:00
Felix-Stakater
09f2a63b00 Bump version to 1.4.9
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-11-03 16:57:23 +00:00
Felix Tonnvik
c860dcc402 Merge pull request #1033 from SebastienSyd/master
fix: bump go version to 1.24.9 to fix CVEs
2025-11-03 17:49:45 +01:00
Sebastien NICOT
5f2cf19213 fix: bump go version to fix CVEs 2025-11-03 17:08:16 +01:00
Erik Svensson
8980e1fd80 fix the value reference so it matches the chart value in the documentation 2025-11-03 08:57:13 +01:00
renovate[bot]
644e5d51d3 chore(deps): update sigstore/cosign-installer action to v4 2025-10-31 11:42:26 +00:00
renovate[bot]
65dc259b7b chore(deps): update actions/setup-go action to v6 2025-10-31 11:42:19 +00:00
renovate[bot]
3cf845b596 chore(deps): update actions/checkout action to v5 2025-10-31 11:42:13 +00:00
renovate[bot]
9af46a363c fix(deps): update module github.com/spf13/cobra to v1.10.1 2025-10-31 11:42:02 +00:00
renovate[bot]
999141df8c chore(deps): update python docker tag to v3.14 2025-10-31 11:41:39 +00:00
renovate[bot]
e99bb34451 fix(deps): update module github.com/argoproj/argo-rollouts to v1.8.3 2025-10-31 11:41:27 +00:00
Muhammad Safwan Karim
196373a688 Merge pull request #907 from stakater/renovate/nginxinc-nginx-unprivileged-1.x
chore(deps): update nginxinc/nginx-unprivileged docker tag to v1.29
2025-10-31 16:21:59 +05:00
Muhammad Safwan Karim
c3022c1255 Merge pull request #873 from stakater/renovate/peter-evans-create-pull-request-7.x
chore(deps): update peter-evans/create-pull-request action to v7.0.8
2025-10-31 16:20:38 +05:00
Muhammad Safwan Karim
c988b77933 Merge pull request #1022 from stakater/renovate/stakater-.github-0.x
chore(deps): update stakater/.github action to v0.0.163
2025-10-31 16:18:23 +05:00
renovate[bot]
e3e7cef752 chore(deps): update nginxinc/nginx-unprivileged docker tag to v1.29 2025-10-31 11:17:27 +00:00
Muhammad Safwan Karim
f7d4fca874 Merge pull request #1021 from stakater/renovate/stakater-vale-package-0.x
chore(deps): update dependency stakater/vale-package to v0.0.87
2025-10-31 16:14:56 +05:00
Muhammad Safwan Karim
956b3934da Merge pull request #914 from stakater/renovate/k8s.io-utils-digest
fix(deps): update k8s.io/utils digest to bc988d5
2025-10-31 16:14:13 +05:00
renovate[bot]
39352e4f4d chore(deps): update stakater/.github action to v0.0.163 2025-10-31 11:10:32 +00:00
renovate[bot]
0078e3f814 chore(deps): update dependency stakater/vale-package to v0.0.87 2025-10-31 11:08:47 +00:00
renovate[bot]
6d640e2ca1 chore(deps): update peter-evans/create-pull-request action to v7.0.8 2025-10-31 07:46:18 +00:00
renovate[bot]
11c99a7c13 fix(deps): update k8s.io/utils digest to bc988d5 2025-10-31 07:46:14 +00:00
33 changed files with 180 additions and 170 deletions

View File

@@ -3,5 +3,6 @@
{
"pattern": "^(?!http).+"
}
]
],
"retryOn429": true
}

View File

@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
@@ -57,7 +57,7 @@ jobs:
git diff
- name: Create pull request
uses: peter-evans/create-pull-request@v7.0.6
uses: peter-evans/create-pull-request@v7.0.8
with:
commit-message: "Bump version to ${{ inputs.TARGET_VERSION }}"
title: "Bump version to ${{ inputs.TARGET_VERSION }} on ${{ inputs.TARGET_BRANCH }} branch"

View File

@@ -26,7 +26,7 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
@@ -55,7 +55,7 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0

View File

@@ -25,7 +25,7 @@ env:
jobs:
qa:
uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.131
uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.163
with:
MD_CONFIG: .github/md_config.json
DOC_SRC: README.md
@@ -40,7 +40,7 @@ jobs:
name: Build
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
@@ -57,7 +57,7 @@ jobs:
charts: deployments/kubernetes/chart/reloader
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
check-latest: true
@@ -80,11 +80,7 @@ jobs:
make install
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
only-new-issues: false
args: --timeout 10m
run: make lint
- name: Helm Lint
run: |

View File

@@ -16,13 +16,13 @@ on:
jobs:
qa:
uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.134
uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.163
with:
MD_CONFIG: .github/md_config.json
DOC_SRC: docs
MD_LINT_CONFIG: .markdownlint.yaml
build:
uses: stakater/.github/.github/workflows/pull_request_container_build.yaml@v0.0.134
uses: stakater/.github/.github/workflows/pull_request_container_build.yaml@v0.0.163
with:
DOCKER_FILE_PATH: Dockerfile-docs
CONTAINER_REGISTRY_URL: ghcr.io/stakater

View File

@@ -31,7 +31,7 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
token: ${{ secrets.PUBLISH_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
@@ -73,7 +73,7 @@ jobs:
exit 1
- name: Install Cosign
uses: sigstore/cosign-installer@v3.10.1
uses: sigstore/cosign-installer@v4.0.0
- name: Login to GHCR Registry
uses: docker/login-action@v3

View File

@@ -30,13 +30,13 @@ jobs:
if: ${{ github.event.label.name == 'build-and-push-pr-image' }}
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
check-latest: true
@@ -47,11 +47,7 @@ jobs:
make install
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
only-new-issues: false
args: --timeout 10m
run: make lint
- name: Generate Tags
id: generate_tag

View File

@@ -29,7 +29,7 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
token: ${{ secrets.PUBLISH_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
@@ -42,7 +42,7 @@ jobs:
version: v3.11.3
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
check-latest: true
@@ -53,11 +53,7 @@ jobs:
make install
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
only-new-issues: false
args: --timeout 10m
run: make lint
- name: Install kubectl
run: |

View File

@@ -15,7 +15,7 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0

View File

@@ -24,7 +24,7 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
token: ${{ secrets.PUBLISH_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
@@ -37,7 +37,7 @@ jobs:
version: v3.11.3
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
check-latest: true
@@ -48,11 +48,7 @@ jobs:
make install
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
only-new-issues: false
args: --timeout 10m
run: make lint
- name: Install kubectl
run: |

View File

@@ -1,7 +1,7 @@
StylesPath = styles
MinAlertLevel = warning
Packages = https://github.com/stakater/vale-package/releases/download/v0.0.86/Stakater.zip
Packages = https://github.com/stakater/vale-package/releases/download/v0.0.87/Stakater.zip
Vocab = Stakater
# Only check MarkDown files

View File

@@ -2,7 +2,7 @@ ARG BUILDER_IMAGE
ARG BASE_IMAGE
# Build the manager binary
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE:-golang:1.24.6} AS builder
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE:-golang:1.25.3} AS builder
ARG TARGETOS
ARG TARGETARCH

View File

@@ -1,4 +1,4 @@
FROM python:3.13-alpine as builder
FROM python:3.14-alpine as builder
# set workdir
RUN mkdir -p $HOME/application
@@ -17,7 +17,7 @@ RUN python theme_common/scripts/combine_mkdocs_config_yaml.py theme_common/mkdoc
# build the docs
RUN mkdocs build
FROM nginxinc/nginx-unprivileged:1.27-alpine as deploy
FROM nginxinc/nginx-unprivileged:1.29-alpine as deploy
COPY --from=builder $HOME/application/site/ /usr/share/nginx/html/reloader/
COPY docs-nginx.conf /etc/nginx/conf.d/default.conf

View File

@@ -41,7 +41,7 @@ YQ ?= $(LOCALBIN)/yq
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.57.2
GOLANGCI_LINT_VERSION ?= v2.6.1
YQ_VERSION ?= v4.27.5
YQ_DOWNLOAD_URL = "https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$(OS)_$(ARCH)"
@@ -75,7 +75,7 @@ $(ENVTEST): $(LOCALBIN)
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary (ideally with version)
@@ -102,6 +102,9 @@ run:
build:
"$(GOCMD)" build ${GOFLAGS} ${LDFLAGS} -o "${BINARY}"
lint: golangci-lint ## Run golangci-lint on the codebase
$(GOLANGCI_LINT) run ./...
build-image:
docker buildx build \
--platform ${OS}/${ARCH} \

View File

@@ -211,12 +211,13 @@ To enable this feature, update the `reloader.env.secret` section in your `values
```yaml
reloader:
env:
secret:
ALERT_ON_RELOAD: "true" # Enable alerting (default: false)
ALERT_SINK: "slack" # Options: slack, teams, gchat or webhook (default: webhook)
ALERT_WEBHOOK_URL: "<your-webhook-url>" # Required if ALERT_ON_RELOAD is true
ALERT_ADDITIONAL_INFO: "Triggered by Reloader in staging environment"
deployment:
env:
secret:
ALERT_ON_RELOAD: "true" # Enable alerting (default: false)
ALERT_SINK: "slack" # Options: slack, teams, gchat or webhook (default: webhook)
ALERT_WEBHOOK_URL: "<your-webhook-url>" # Required if ALERT_ON_RELOAD is true
ALERT_ADDITIONAL_INFO: "Triggered by Reloader in staging environment"
```
### 7. ⏸️ Pause Deployments
@@ -433,11 +434,14 @@ _Repository GitHub releases_: As requested by the community in [issue 685](https
To make a GitHub release:
1. Code owners create a release branch `release-vX.Y.Z`
1. Code owners run a dispatch mode workflow to automatically generate version and manifests on the release branch
1. Code owners create a release branch `release-vX.Y.Z` from `master`
1. Code owners run [Init Release](https://github.com/stakater/Reloader/actions/workflows/init-branch-release.yaml) workflow to automatically generate version and manifests on the release branch
- Set the `TARGET_BRANCH` parameter to release branch i.e. `release-vX.Y.Z`
- Set the `TARGET_VERSION` to release version without 'v' i.e. `X.Y.Z`
1. A PR is created to bump the image version on the release branch, example: [PR-798](https://github.com/stakater/Reloader/pull/798)
1. Code owners create a GitHub release with tag `vX.Y.Z` and target branch `release-vX.Y.Z`, which triggers creation of images
1. Code owners create a PR with `release/helm-chart` label to update the Helm chart version, example: [PR-846](https://github.com/stakater/Reloader/pull/846)
1. Code owners create another branch from `master` and bump the helm chart version as well as Reloader image version.
- Code owners create a PR with `release/helm-chart` label, example: [PR-846](https://github.com/stakater/Reloader/pull/846)
_Repository git tagging_: Push to the main branch will create a merge-image and merge-tag named `merge-${{ github.event.number }}`, for example `merge-800` when pull request number 800 is merged.

View File

@@ -1 +1 @@
1.1.0
1.4.11

View File

@@ -1,8 +1,8 @@
apiVersion: v1
name: reloader
description: Reloader chart that runs on kubernetes
version: 2.2.3
appVersion: v1.4.8
version: 2.2.6
appVersion: v1.4.11
keywords:
- Reloader
- kubernetes

View File

@@ -132,7 +132,7 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}}
### OpenShift Considerations
- Recent OpenShift versions (tested on 4.13.3) require:
- Users to be in a dynamically assigned UID range
- **Solution**: Unset `runAsUser` via `deployment.securityContext.runAsUser=null`
- **Solution**: Unset `runAsUser` via `reloader.deployment.securityContext.runAsUser=null`
- Let OpenShift assign UID automatically during installation
### Core Functionality Flags

View File

@@ -280,7 +280,7 @@ spec:
- "{{ .Values.reloader.custom_annotations.pausePeriod }}"
{{- end }}
{{- if .Values.reloader.custom_annotations.pauseTime }}
- "--pause-deployment-annotation"
- "--pause-deployment-time-annotation"
- "{{ .Values.reloader.custom_annotations.pauseTime }}"
{{- end }}
{{- if .Values.reloader.webhookUrl }}

View File

@@ -17,7 +17,7 @@ fullnameOverride: ""
image:
name: stakater/reloader
repository: ghcr.io/stakater/reloader
tag: v1.4.8
tag: v1.4.11
# digest: sha256:1234567
pullPolicy: IfNotPresent
@@ -130,7 +130,7 @@ reloader:
labels:
provider: stakater
group: com.stakater.platform
version: v1.4.8
version: v1.4.11
# Support for extra environment variables.
env:
# Open supports Key value pair as environment variables.

View File

@@ -17,7 +17,7 @@ spec:
app: reloader-reloader
spec:
containers:
- image: "ghcr.io/stakater/reloader:v1.1.0"
- image: "ghcr.io/stakater/reloader:v1.4.11"
imagePullPolicy: IfNotPresent
name: reloader-reloader
env:

View File

@@ -141,7 +141,7 @@ spec:
fieldPath: metadata.namespace
- name: RELOADER_DEPLOYMENT_NAME
value: reloader-reloader
image: ghcr.io/stakater/reloader:latest
image: ghcr.io/stakater/reloader:v1.4.11
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 5

10
go.mod
View File

@@ -1,21 +1,21 @@
module github.com/stakater/Reloader
go 1.24.6
go 1.25.3
require (
github.com/argoproj/argo-rollouts v1.8.2
github.com/argoproj/argo-rollouts v1.8.3
github.com/openshift/api v0.0.0-20250411135543-10a8fa583797
github.com/openshift/client-go v0.0.0-20250402181141-b3bad3b645f2
github.com/parnurzeal/gorequest v0.3.0
github.com/prometheus/client_golang v1.22.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.9.1
github.com/spf13/cobra v1.10.1
github.com/stretchr/testify v1.10.0
k8s.io/api v0.32.3
k8s.io/apimachinery v0.32.3
k8s.io/client-go v0.32.3
k8s.io/kubectl v0.32.3
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
)
require (
@@ -50,7 +50,7 @@ require (
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.16.0 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/oauth2 v0.29.0 // indirect

16
go.sum
View File

@@ -1,5 +1,5 @@
github.com/argoproj/argo-rollouts v1.8.2 h1:DBvkYvFTEH/zJ9MxJerqz/NMWEgZcHY5vxztyCBS5ak=
github.com/argoproj/argo-rollouts v1.8.2/go.mod h1:xZIw+dg+B4IqMv5fNPenIBUiPb9xljL2st1xxkjhaC0=
github.com/argoproj/argo-rollouts v1.8.3 h1:blbtQva4IK9r6gFh+dWkCrLnFdPOWiv9ubQYu36qeaA=
github.com/argoproj/argo-rollouts v1.8.3/go.mod h1:kCAUvIfMGfOyVf3lvQbBt0nqQn4Pd+zB5/YwKv+UBa8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
@@ -104,10 +104,10 @@ github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -185,8 +185,8 @@ k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUy
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8=
k8s.io/kubectl v0.32.3 h1:VMi584rbboso+yjfv0d8uBHwwxbC438LKq+dXd5tOAI=
k8s.io/kubectl v0.32.3/go.mod h1:6Euv2aso5GKzo/UVMacV6C7miuyevpfI91SvBvV9Zdg=
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e h1:KqK5c/ghOm8xkHYhlodbp6i6+r+ChV2vuAuVRdFbLro=
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=

View File

@@ -9,6 +9,15 @@ import (
"github.com/sirupsen/logrus"
)
type AlertSink string
const (
AlertSinkSlack AlertSink = "slack"
AlertSinkTeams AlertSink = "teams"
AlertSinkGoogleChat AlertSink = "gchat"
AlertSinkRaw AlertSink = "raw"
)
// function to send alert msg to webhook service
func SendWebhookAlert(msg string) {
webhook_url, ok := os.LookupEnv("ALERT_WEBHOOK_URL")
@@ -31,14 +40,15 @@ func SendWebhookAlert(msg string) {
msg = fmt.Sprintf("%s : %s", alert_additional_info, msg)
}
if alert_sink == "slack" {
switch AlertSink(alert_sink) {
case AlertSinkSlack:
sendSlackAlert(webhook_url, webhook_proxy, msg)
} else if alert_sink == "teams" {
case AlertSinkTeams:
sendTeamsAlert(webhook_url, webhook_proxy, msg)
} else if alert_sink == "gchat" {
case AlertSinkGoogleChat:
sendGoogleChatAlert(webhook_url, webhook_proxy, msg)
} else {
msg = strings.Replace(msg, "*", "", -1)
default:
msg = strings.ReplaceAll(msg, "*", "")
sendRawWebhookAlert(webhook_url, webhook_proxy, msg)
}
}

View File

@@ -83,9 +83,9 @@ func GetDeploymentItem(clients kube.Clients, name string, namespace string) (run
return nil, err
}
if deployment.Spec.Template.ObjectMeta.Annotations == nil {
if deployment.Spec.Template.Annotations == nil {
annotations := make(map[string]string)
deployment.Spec.Template.ObjectMeta.Annotations = annotations
deployment.Spec.Template.Annotations = annotations
}
return deployment, nil
@@ -101,9 +101,9 @@ func GetDeploymentItems(clients kube.Clients, namespace string) []runtime.Object
items := make([]runtime.Object, len(deployments.Items))
// Ensure we always have pod annotations to add to
for i, v := range deployments.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
if v.Spec.Template.Annotations == nil {
annotations := make(map[string]string)
deployments.Items[i].Spec.Template.ObjectMeta.Annotations = annotations
deployments.Items[i].Spec.Template.Annotations = annotations
}
items[i] = &deployments.Items[i]
}
@@ -132,9 +132,9 @@ func GetCronJobItems(clients kube.Clients, namespace string) []runtime.Object {
items := make([]runtime.Object, len(cronjobs.Items))
// Ensure we always have pod annotations to add to
for i, v := range cronjobs.Items {
if v.Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations == nil {
if v.Spec.JobTemplate.Spec.Template.Annotations == nil {
annotations := make(map[string]string)
cronjobs.Items[i].Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations = annotations
cronjobs.Items[i].Spec.JobTemplate.Spec.Template.Annotations = annotations
}
items[i] = &cronjobs.Items[i]
}
@@ -163,9 +163,9 @@ func GetJobItems(clients kube.Clients, namespace string) []runtime.Object {
items := make([]runtime.Object, len(jobs.Items))
// Ensure we always have pod annotations to add to
for i, v := range jobs.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
if v.Spec.Template.Annotations == nil {
annotations := make(map[string]string)
jobs.Items[i].Spec.Template.ObjectMeta.Annotations = annotations
jobs.Items[i].Spec.Template.Annotations = annotations
}
items[i] = &jobs.Items[i]
}
@@ -194,8 +194,8 @@ func GetDaemonSetItems(clients kube.Clients, namespace string) []runtime.Object
items := make([]runtime.Object, len(daemonSets.Items))
// Ensure we always have pod annotations to add to
for i, v := range daemonSets.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
daemonSets.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if v.Spec.Template.Annotations == nil {
daemonSets.Items[i].Spec.Template.Annotations = make(map[string]string)
}
items[i] = &daemonSets.Items[i]
}
@@ -224,8 +224,8 @@ func GetStatefulSetItems(clients kube.Clients, namespace string) []runtime.Objec
items := make([]runtime.Object, len(statefulSets.Items))
// Ensure we always have pod annotations to add to
for i, v := range statefulSets.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
statefulSets.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if v.Spec.Template.Annotations == nil {
statefulSets.Items[i].Spec.Template.Annotations = make(map[string]string)
}
items[i] = &statefulSets.Items[i]
}
@@ -254,8 +254,8 @@ func GetRolloutItems(clients kube.Clients, namespace string) []runtime.Object {
items := make([]runtime.Object, len(rollouts.Items))
// Ensure we always have pod annotations to add to
for i, v := range rollouts.Items {
if v.Spec.Template.ObjectMeta.Annotations == nil {
rollouts.Items[i].Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if v.Spec.Template.Annotations == nil {
rollouts.Items[i].Spec.Template.Annotations = make(map[string]string)
}
items[i] = &rollouts.Items[i]
}
@@ -265,98 +265,98 @@ func GetRolloutItems(clients kube.Clients, namespace string) []runtime.Object {
// GetDeploymentAnnotations returns the annotations of given deployment
func GetDeploymentAnnotations(item runtime.Object) map[string]string {
if item.(*appsv1.Deployment).ObjectMeta.Annotations == nil {
item.(*appsv1.Deployment).ObjectMeta.Annotations = make(map[string]string)
if item.(*appsv1.Deployment).Annotations == nil {
item.(*appsv1.Deployment).Annotations = make(map[string]string)
}
return item.(*appsv1.Deployment).ObjectMeta.Annotations
return item.(*appsv1.Deployment).Annotations
}
// GetCronJobAnnotations returns the annotations of given cronjob
func GetCronJobAnnotations(item runtime.Object) map[string]string {
if item.(*batchv1.CronJob).ObjectMeta.Annotations == nil {
item.(*batchv1.CronJob).ObjectMeta.Annotations = make(map[string]string)
if item.(*batchv1.CronJob).Annotations == nil {
item.(*batchv1.CronJob).Annotations = make(map[string]string)
}
return item.(*batchv1.CronJob).ObjectMeta.Annotations
return item.(*batchv1.CronJob).Annotations
}
// GetJobAnnotations returns the annotations of given job
func GetJobAnnotations(item runtime.Object) map[string]string {
if item.(*batchv1.Job).ObjectMeta.Annotations == nil {
item.(*batchv1.Job).ObjectMeta.Annotations = make(map[string]string)
if item.(*batchv1.Job).Annotations == nil {
item.(*batchv1.Job).Annotations = make(map[string]string)
}
return item.(*batchv1.Job).ObjectMeta.Annotations
return item.(*batchv1.Job).Annotations
}
// GetDaemonSetAnnotations returns the annotations of given daemonSet
func GetDaemonSetAnnotations(item runtime.Object) map[string]string {
if item.(*appsv1.DaemonSet).ObjectMeta.Annotations == nil {
item.(*appsv1.DaemonSet).ObjectMeta.Annotations = make(map[string]string)
if item.(*appsv1.DaemonSet).Annotations == nil {
item.(*appsv1.DaemonSet).Annotations = make(map[string]string)
}
return item.(*appsv1.DaemonSet).ObjectMeta.Annotations
return item.(*appsv1.DaemonSet).Annotations
}
// GetStatefulSetAnnotations returns the annotations of given statefulSet
func GetStatefulSetAnnotations(item runtime.Object) map[string]string {
if item.(*appsv1.StatefulSet).ObjectMeta.Annotations == nil {
item.(*appsv1.StatefulSet).ObjectMeta.Annotations = make(map[string]string)
if item.(*appsv1.StatefulSet).Annotations == nil {
item.(*appsv1.StatefulSet).Annotations = make(map[string]string)
}
return item.(*appsv1.StatefulSet).ObjectMeta.Annotations
return item.(*appsv1.StatefulSet).Annotations
}
// GetRolloutAnnotations returns the annotations of given rollout
func GetRolloutAnnotations(item runtime.Object) map[string]string {
if item.(*argorolloutv1alpha1.Rollout).ObjectMeta.Annotations == nil {
item.(*argorolloutv1alpha1.Rollout).ObjectMeta.Annotations = make(map[string]string)
if item.(*argorolloutv1alpha1.Rollout).Annotations == nil {
item.(*argorolloutv1alpha1.Rollout).Annotations = make(map[string]string)
}
return item.(*argorolloutv1alpha1.Rollout).ObjectMeta.Annotations
return item.(*argorolloutv1alpha1.Rollout).Annotations
}
// GetDeploymentPodAnnotations returns the pod's annotations of given deployment
func GetDeploymentPodAnnotations(item runtime.Object) map[string]string {
if item.(*appsv1.Deployment).Spec.Template.ObjectMeta.Annotations == nil {
item.(*appsv1.Deployment).Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if item.(*appsv1.Deployment).Spec.Template.Annotations == nil {
item.(*appsv1.Deployment).Spec.Template.Annotations = make(map[string]string)
}
return item.(*appsv1.Deployment).Spec.Template.ObjectMeta.Annotations
return item.(*appsv1.Deployment).Spec.Template.Annotations
}
// GetCronJobPodAnnotations returns the pod's annotations of given cronjob
func GetCronJobPodAnnotations(item runtime.Object) map[string]string {
if item.(*batchv1.CronJob).Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations == nil {
item.(*batchv1.CronJob).Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if item.(*batchv1.CronJob).Spec.JobTemplate.Spec.Template.Annotations == nil {
item.(*batchv1.CronJob).Spec.JobTemplate.Spec.Template.Annotations = make(map[string]string)
}
return item.(*batchv1.CronJob).Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations
return item.(*batchv1.CronJob).Spec.JobTemplate.Spec.Template.Annotations
}
// GetJobPodAnnotations returns the pod's annotations of given job
func GetJobPodAnnotations(item runtime.Object) map[string]string {
if item.(*batchv1.Job).Spec.Template.ObjectMeta.Annotations == nil {
item.(*batchv1.Job).Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if item.(*batchv1.Job).Spec.Template.Annotations == nil {
item.(*batchv1.Job).Spec.Template.Annotations = make(map[string]string)
}
return item.(*batchv1.Job).Spec.Template.ObjectMeta.Annotations
return item.(*batchv1.Job).Spec.Template.Annotations
}
// GetDaemonSetPodAnnotations returns the pod's annotations of given daemonSet
func GetDaemonSetPodAnnotations(item runtime.Object) map[string]string {
if item.(*appsv1.DaemonSet).Spec.Template.ObjectMeta.Annotations == nil {
item.(*appsv1.DaemonSet).Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if item.(*appsv1.DaemonSet).Spec.Template.Annotations == nil {
item.(*appsv1.DaemonSet).Spec.Template.Annotations = make(map[string]string)
}
return item.(*appsv1.DaemonSet).Spec.Template.ObjectMeta.Annotations
return item.(*appsv1.DaemonSet).Spec.Template.Annotations
}
// GetStatefulSetPodAnnotations returns the pod's annotations of given statefulSet
func GetStatefulSetPodAnnotations(item runtime.Object) map[string]string {
if item.(*appsv1.StatefulSet).Spec.Template.ObjectMeta.Annotations == nil {
item.(*appsv1.StatefulSet).Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if item.(*appsv1.StatefulSet).Spec.Template.Annotations == nil {
item.(*appsv1.StatefulSet).Spec.Template.Annotations = make(map[string]string)
}
return item.(*appsv1.StatefulSet).Spec.Template.ObjectMeta.Annotations
return item.(*appsv1.StatefulSet).Spec.Template.Annotations
}
// GetRolloutPodAnnotations returns the pod's annotations of given rollout
func GetRolloutPodAnnotations(item runtime.Object) map[string]string {
if item.(*argorolloutv1alpha1.Rollout).Spec.Template.ObjectMeta.Annotations == nil {
item.(*argorolloutv1alpha1.Rollout).Spec.Template.ObjectMeta.Annotations = make(map[string]string)
if item.(*argorolloutv1alpha1.Rollout).Spec.Template.Annotations == nil {
item.(*argorolloutv1alpha1.Rollout).Spec.Template.Annotations = make(map[string]string)
}
return item.(*argorolloutv1alpha1.Rollout).Spec.Template.ObjectMeta.Annotations
return item.(*argorolloutv1alpha1.Rollout).Spec.Template.Annotations
}
// GetDeploymentContainers returns the containers of given deployment
@@ -481,9 +481,9 @@ func ReCreateJobFromjob(clients kube.Clients, namespace string, resource runtime
}
// Remove fields that should not be specified when creating a new Job
job.ObjectMeta.ResourceVersion = ""
job.ObjectMeta.UID = ""
job.ObjectMeta.CreationTimestamp = meta_v1.Time{}
job.ResourceVersion = ""
job.UID = ""
job.CreationTimestamp = meta_v1.Time{}
job.Status = batchv1.JobStatus{}
// Remove problematic labels

View File

@@ -373,19 +373,19 @@ func TestPatchResources(t *testing.T) {
assert.NoError(t, err)
patchedResource, err := callbacks.GetDeploymentItem(clients, "test-deployment", fixtures.namespace)
assert.NoError(t, err)
assert.Equal(t, "test", patchedResource.(*appsv1.Deployment).ObjectMeta.Annotations["test"])
assert.Equal(t, "test", patchedResource.(*appsv1.Deployment).Annotations["test"])
}},
{"DaemonSet", createTestDaemonSetWithAnnotations, callbacks.PatchDaemonSet, deleteTestDaemonSet, func(err error) {
assert.NoError(t, err)
patchedResource, err := callbacks.GetDaemonSetItem(clients, "test-daemonset", fixtures.namespace)
assert.NoError(t, err)
assert.Equal(t, "test", patchedResource.(*appsv1.DaemonSet).ObjectMeta.Annotations["test"])
assert.Equal(t, "test", patchedResource.(*appsv1.DaemonSet).Annotations["test"])
}},
{"StatefulSet", createTestStatefulSetWithAnnotations, callbacks.PatchStatefulSet, deleteTestStatefulSet, func(err error) {
assert.NoError(t, err)
patchedResource, err := callbacks.GetStatefulSetItem(clients, "test-statefulset", fixtures.namespace)
assert.NoError(t, err)
assert.Equal(t, "test", patchedResource.(*appsv1.StatefulSet).ObjectMeta.Annotations["test"])
assert.Equal(t, "test", patchedResource.(*appsv1.StatefulSet).Annotations["test"])
}},
{"CronJob", createTestCronJobWithAnnotations, callbacks.PatchCronJob, deleteTestCronJob, func(err error) {
assert.EqualError(t, err, "not supported patching: CronJob")
@@ -621,17 +621,17 @@ func deleteTestStatefulSets(clients kube.Clients, namespace string) error {
func createResourceWithPodAnnotations(obj runtime.Object, annotations map[string]string) runtime.Object {
switch v := obj.(type) {
case *appsv1.Deployment:
v.Spec.Template.ObjectMeta.Annotations = annotations
v.Spec.Template.Annotations = annotations
case *appsv1.DaemonSet:
v.Spec.Template.ObjectMeta.Annotations = annotations
v.Spec.Template.Annotations = annotations
case *appsv1.StatefulSet:
v.Spec.Template.ObjectMeta.Annotations = annotations
v.Spec.Template.Annotations = annotations
case *batchv1.CronJob:
v.Spec.JobTemplate.Spec.Template.ObjectMeta.Annotations = annotations
v.Spec.JobTemplate.Spec.Template.Annotations = annotations
case *batchv1.Job:
v.Spec.Template.ObjectMeta.Annotations = annotations
v.Spec.Template.Annotations = annotations
case *argorolloutv1alpha1.Rollout:
v.Spec.Template.ObjectMeta.Annotations = annotations
v.Spec.Template.Annotations = annotations
}
return obj
}

View File

@@ -124,9 +124,9 @@ func (c *Controller) Add(obj interface{}) {
func (c *Controller) resourceInIgnoredNamespace(raw interface{}) bool {
switch object := raw.(type) {
case *v1.ConfigMap:
return c.ignoredNamespaces.Contains(object.ObjectMeta.Namespace)
return c.ignoredNamespaces.Contains(object.Namespace)
case *v1.Secret:
return c.ignoredNamespaces.Contains(object.ObjectMeta.Namespace)
return c.ignoredNamespaces.Contains(object.Namespace)
}
return false
}
@@ -212,7 +212,7 @@ func (c *Controller) Run(threadiness int, stopCh chan struct{}) {
// Wait for all involved caches to be synced, before processing items from the queue is started
if !cache.WaitForCacheSync(stopCh, c.informer.HasSynced) {
runtime.HandleError(fmt.Errorf("Timed out waiting for caches to sync"))
runtime.HandleError(fmt.Errorf("timed out waiting for caches to sync"))
return
}
@@ -226,9 +226,9 @@ func (c *Controller) Run(threadiness int, stopCh chan struct{}) {
func (c *Controller) runWorker() {
// At this point the controller is fully initialized and we can start processing the resources
if c.resource == "secrets" {
if c.resource == string(v1.ResourceSecrets) {
secretControllerInitialized = true
} else if c.resource == "configMaps" {
} else if c.resource == string(v1.ResourceConfigMaps) {
configmapControllerInitialized = true
}

View File

@@ -2341,7 +2341,7 @@ func TestController_resourceInNamespaceSelector(t *testing.T) {
indexer: tt.fields.indexer,
queue: tt.fields.queue,
informer: tt.fields.informer,
namespace: tt.fields.namespace.ObjectMeta.Name,
namespace: tt.fields.namespace.Name,
namespaceSelector: tt.fields.namespaceSelector,
}

View File

@@ -9,7 +9,6 @@ import (
"github.com/stakater/Reloader/internal/pkg/options"
"github.com/stakater/Reloader/pkg/kube"
"github.com/stretchr/testify/assert"
app "k8s.io/api/apps/v1"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -374,14 +373,14 @@ func TestPauseDeployment(t *testing.T) {
}
// Simple helper function for test cases
func FindDeploymentByName(deployments []runtime.Object, deploymentName string) (*app.Deployment, error) {
func FindDeploymentByName(deployments []runtime.Object, deploymentName string) (*appsv1.Deployment, error) {
for _, deployment := range deployments {
accessor, err := meta.Accessor(deployment)
if err != nil {
return nil, fmt.Errorf("error getting accessor for item: %v", err)
}
if accessor.GetName() == deploymentName {
deploymentObj, ok := deployment.(*app.Deployment)
deploymentObj, ok := deployment.(*appsv1.Deployment)
if !ok {
return nil, fmt.Errorf("failed to cast to Deployment")
}

View File

@@ -160,7 +160,12 @@ func sendWebhook(url string) (string, []error) {
// the reloader seems to retry automatically so no retry logic added
return "", err
}
defer resp.Body.Close()
defer func() {
closeErr := resp.Body.Close()
if closeErr != nil {
logrus.Error(closeErr)
}
}()
var buffer bytes.Buffer
_, bufferErr := io.Copy(&buffer, resp.Body)
if bufferErr != nil {
@@ -350,7 +355,8 @@ func upgradeResource(clients kube.Clients, config common.Config, upgradeFuncs ca
func getVolumeMountName(volumes []v1.Volume, mountType string, volumeName string) string {
for i := range volumes {
if mountType == constants.ConfigmapEnvVarPostfix {
switch mountType {
case constants.ConfigmapEnvVarPostfix:
if volumes[i].ConfigMap != nil && volumes[i].ConfigMap.Name == volumeName {
return volumes[i].Name
}
@@ -362,7 +368,7 @@ func getVolumeMountName(volumes []v1.Volume, mountType string, volumeName string
}
}
}
} else if mountType == constants.SecretEnvVarPostfix {
case constants.SecretEnvVarPostfix:
if volumes[i].Secret != nil && volumes[i].Secret.SecretName == volumeName {
return volumes[i].Name
}
@@ -399,9 +405,9 @@ func getContainerWithEnvReference(containers []v1.Container, resourceName string
for j := range envs {
envVarSource := envs[j].ValueFrom
if envVarSource != nil {
if resourceType == constants.SecretEnvVarPostfix && envVarSource.SecretKeyRef != nil && envVarSource.SecretKeyRef.LocalObjectReference.Name == resourceName {
if resourceType == constants.SecretEnvVarPostfix && envVarSource.SecretKeyRef != nil && envVarSource.SecretKeyRef.Name == resourceName {
return &containers[i]
} else if resourceType == constants.ConfigmapEnvVarPostfix && envVarSource.ConfigMapKeyRef != nil && envVarSource.ConfigMapKeyRef.LocalObjectReference.Name == resourceName {
} else if resourceType == constants.ConfigmapEnvVarPostfix && envVarSource.ConfigMapKeyRef != nil && envVarSource.ConfigMapKeyRef.Name == resourceName {
return &containers[i]
}
}
@@ -409,9 +415,9 @@ func getContainerWithEnvReference(containers []v1.Container, resourceName string
envsFrom := containers[i].EnvFrom
for j := range envsFrom {
if resourceType == constants.SecretEnvVarPostfix && envsFrom[j].SecretRef != nil && envsFrom[j].SecretRef.LocalObjectReference.Name == resourceName {
if resourceType == constants.SecretEnvVarPostfix && envsFrom[j].SecretRef != nil && envsFrom[j].SecretRef.Name == resourceName {
return &containers[i]
} else if resourceType == constants.ConfigmapEnvVarPostfix && envsFrom[j].ConfigMapRef != nil && envsFrom[j].ConfigMapRef.LocalObjectReference.Name == resourceName {
} else if resourceType == constants.ConfigmapEnvVarPostfix && envsFrom[j].ConfigMapRef != nil && envsFrom[j].ConfigMapRef.Name == resourceName {
return &containers[i]
}
}

View File

@@ -94,7 +94,7 @@ func getAnnotations(name string, autoReload bool, secretAutoReload bool, configm
annotations[options.ConfigmapReloaderAutoAnnotation] = "true"
}
if !(len(annotations) > 0) {
if len(annotations) == 0 {
annotations = map[string]string{
options.ConfigmapUpdateOnChangeAnnotation: name,
options.SecretUpdateOnChangeAnnotation: name}
@@ -479,18 +479,19 @@ func GetDeploymentWithPodAnnotations(namespace string, deploymentName string, bo
},
}
if !both {
deployment.ObjectMeta.Annotations = nil
deployment.Annotations = nil
}
deployment.Spec.Template.ObjectMeta.Annotations = getAnnotations(deploymentName, true, false, false, map[string]string{})
deployment.Spec.Template.Annotations = getAnnotations(deploymentName, true, false, false, map[string]string{})
return deployment
}
func GetDeploymentWithTypedAutoAnnotation(namespace string, deploymentName string, resourceType string) *appsv1.Deployment {
replicaset := int32(1)
var objectMeta metav1.ObjectMeta
if resourceType == SecretResourceType {
switch resourceType {
case SecretResourceType:
objectMeta = getObjectMeta(namespace, deploymentName, false, true, false, map[string]string{})
} else if resourceType == ConfigmapResourceType {
case ConfigmapResourceType:
objectMeta = getObjectMeta(namespace, deploymentName, false, false, true, map[string]string{})
}
@@ -514,9 +515,10 @@ func GetDeploymentWithExcludeAnnotation(namespace string, deploymentName string,
annotation := map[string]string{}
if resourceType == SecretResourceType {
switch resourceType {
case SecretResourceType:
annotation[options.SecretExcludeReloaderAnnotation] = deploymentName
} else if resourceType == ConfigmapResourceType {
case ConfigmapResourceType:
annotation[options.ConfigmapExcludeReloaderAnnotation] = deploymentName
}
@@ -747,12 +749,13 @@ func GetResourceSHAFromAnnotation(podAnnotations map[string]string) string {
// ConvertResourceToSHA generates SHA from secret or configmap data
func ConvertResourceToSHA(resourceType string, namespace string, resourceName string, data string) string {
values := []string{}
if resourceType == SecretResourceType {
switch resourceType {
case SecretResourceType:
secret := GetSecret(namespace, resourceName, data)
for k, v := range secret.Data {
values = append(values, k+"="+string(v[:]))
}
} else if resourceType == ConfigmapResourceType {
case ConfigmapResourceType:
configmap := GetConfigmap(namespace, resourceName, data)
for k, v := range configmap.Data {
values = append(values, k+"="+v)

View File

@@ -7,7 +7,7 @@ import (
// ResourceMap are resources from where changes are going to be detected
var ResourceMap = map[string]runtime.Object{
"configMaps": &v1.ConfigMap{},
"configmaps": &v1.ConfigMap{},
"secrets": &v1.Secret{},
"namespaces": &v1.Namespace{},
"namespaces": &v1.Namespace{},
}