1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Merge branch 'main' into add-main-controller-logic

This commit is contained in:
Lucas Severo Alves 2021-01-27 12:11:09 +01:00
commit 04f3dd4119
8 changed files with 103 additions and 8 deletions

5
.github/ci/ct.yaml vendored Normal file
View file

@ -0,0 +1,5 @@
chart-dirs:
- deploy/charts
helm-extra-args: "--timeout=5m"
check-version-increment: false
target-branch: main

View file

@ -7,8 +7,12 @@ on:
- '*/*' # matches every branch containing a single '/' - '*/*' # matches every branch containing a single '/'
- '**' # matches every branch - '**' # matches every branch
- '!main' # excludes main - '!main' # excludes main
paths-ignore:
- 'deploy/**'
pull_request: pull_request:
branches: [ '!main' ] branches: [ '!main' ]
paths-ignore:
- 'deploy/**'
env: env:
KUBEBUILDER_VERSION: 2.3.1 KUBEBUILDER_VERSION: 2.3.1

55
.github/workflows/helm.yml vendored Normal file
View file

@ -0,0 +1,55 @@
name: Helm
on:
push:
tags:
- '*'
paths:
- 'deploy/charts/**'
pull_request:
branches: main
paths:
- 'deploy/charts/**'
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Generate chart
run: |
make crds-to-chart
- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.4.2
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.0.1
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config=.github/ci/ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config=.github/ci/ct.yaml
- name: Create kind cluster
uses: helm/kind-action@v1.1.0
if: steps.list-changed.outputs.changed == 'true'
- name: Run chart-testing (install)
run: ct install --config=.github/ci/ct.yaml

View file

@ -5,8 +5,12 @@ on:
branches: [ main ] branches: [ main ]
tags: tags:
- '*' - '*'
paths-ignore:
- 'deploy/**'
pull_request: pull_request:
branches: [ main ] branches: [ main ]
paths-ignore:
- 'deploy/**'
env: env:
KUBEBUILDER_VERSION: 2.3.1 KUBEBUILDER_VERSION: 2.3.1

2
.gitignore vendored
View file

@ -24,3 +24,5 @@ bin
# Code test output # Code test output
cover.out cover.out
deploy/charts/external-secrets/templates/crds/*.yaml

View file

@ -7,6 +7,8 @@ SHELL := /bin/bash
IMG ?= controller:latest IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) # Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true" CRD_OPTIONS ?= "crd:trivialVersions=true"
HELM_DIR ?= deploy/charts/external-secrets
CRD_DIR ?= config/crd/bases
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN)) ifeq (,$(shell go env GOBIN))
@ -43,7 +45,13 @@ deploy: manifests ## Deploy controller in the Kubernetes cluster of current cont
kustomize build config/default | kubectl apply -f - kustomize build config/default | kubectl apply -f -
manifests: controller-gen ## Generate manifests e.g. CRD, RBAC etc. manifests: controller-gen ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=$(CRD_DIR)
# Remove extra header lines in generated CRDs
@for i in $(CRD_DIR)/*.yaml; do \
tail -n +3 <"$$i" >"$$i.bkp" && \
cp "$$i.bkp" "$$i" && \
rm "$$i.bkp"; \
done
lint/check: # Check install of golanci-lint lint/check: # Check install of golanci-lint
@if ! golangci-lint --version > /dev/null 2>&1; then \ @if ! golangci-lint --version > /dev/null 2>&1; then \
@ -77,6 +85,22 @@ docker-build: test ## Build the docker image
docker-push: ## Push the docker image docker-push: ## Push the docker image
docker push ${IMG} docker push ${IMG}
helm-docs: ## Generate helm docs
cd $(HELM_DIR); \
docker run --rm -v $(shell pwd)/$(HELM_DIR):/helm-docs -u $(shell id -u) jnorwood/helm-docs:latest
crds-to-chart: # Copy crds to helm chart directory
cp $(CRD_DIR)/*.yaml $(HELM_DIR)/templates/crds/
# Add helm chart if statement for installing CRDs
@for i in $(HELM_DIR)/templates/crds/*.yaml; do \
cp "$$i" "$$i.bkp" && \
echo "{{- if .Values.installCRDs }}" > "$$i" && \
cat "$$i.bkp" >> "$$i" && \
echo "{{- end }}" >> "$$i" && \
rm "$$i.bkp"; \
done
# find or download controller-gen # find or download controller-gen
# download controller-gen if necessary # download controller-gen if necessary
controller-gen: controller-gen:

13
main.go
View file

@ -25,8 +25,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/log/zap"
// +kubebuilder:scaffold:imports // +kubebuilder:scaffold:imports
externalsecretsv1alpha1 "github.com/external-secrets/external-secrets/api/v1alpha1" esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
"github.com/external-secrets/external-secrets/controllers" "github.com/external-secrets/external-secrets/pkg/controllers/externalsecret"
"github.com/external-secrets/external-secrets/pkg/controllers/secretstore"
) )
var ( var (
@ -37,7 +38,7 @@ var (
func init() { func init() {
_ = clientgoscheme.AddToScheme(scheme) _ = clientgoscheme.AddToScheme(scheme)
_ = externalsecretsv1alpha1.AddToScheme(scheme) _ = esv1alpha1.AddToScheme(scheme)
// +kubebuilder:scaffold:scheme // +kubebuilder:scaffold:scheme
} }
@ -57,14 +58,14 @@ func main() {
MetricsBindAddress: metricsAddr, MetricsBindAddress: metricsAddr,
Port: 9443, Port: 9443,
LeaderElection: enableLeaderElection, LeaderElection: enableLeaderElection,
LeaderElectionID: "1fc40399.io", LeaderElectionID: "external-secrets-controller",
}) })
if err != nil { if err != nil {
setupLog.Error(err, "unable to start manager") setupLog.Error(err, "unable to start manager")
os.Exit(1) os.Exit(1)
} }
if err = (&controllers.SecretStoreReconciler{ if err = (&secretstore.Reconciler{
Client: mgr.GetClient(), Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("SecretStore"), Log: ctrl.Log.WithName("controllers").WithName("SecretStore"),
Scheme: mgr.GetScheme(), Scheme: mgr.GetScheme(),
@ -72,7 +73,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "SecretStore") setupLog.Error(err, "unable to create controller", "controller", "SecretStore")
os.Exit(1) os.Exit(1)
} }
if err = (&controllers.ExternalSecretReconciler{ if err = (&externalsecret.Reconciler{
Client: mgr.GetClient(), Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("ExternalSecret"), Log: ctrl.Log.WithName("controllers").WithName("ExternalSecret"),
Scheme: mgr.GetScheme(), Scheme: mgr.GetScheme(),

View file

@ -30,7 +30,7 @@ import (
esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1" esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
"github.com/external-secrets/external-secrets/pkg/provider" "github.com/external-secrets/external-secrets/pkg/provider"
utils "github.com/external-secrets/external-secrets/pkg/utils" "github.com/external-secrets/external-secrets/pkg/utils"
// Loading registered providers. // Loading registered providers.
_ "github.com/external-secrets/external-secrets/pkg/provider/register" _ "github.com/external-secrets/external-secrets/pkg/provider/register"