Skip to content

Commit

Permalink
Merge pull request #20 from webhookrelay/extra_env_support
Browse files Browse the repository at this point in the history
Extra env support
  • Loading branch information
rusenask authored Nov 10, 2022
2 parents f4c053d + d7a8a81 commit 8e68a88
Show file tree
Hide file tree
Showing 11 changed files with 286 additions and 51 deletions.
44 changes: 3 additions & 41 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,22 @@ workspace:
base: /go
path: src/github.com/webhookrelay/webhookrelay-operator

volumes:
- name: dockersocket
host:
path: /var/run/docker.sock

steps:
- name: test
pull: golang:1.17
pull: golang:1.19
image: golang
commands:
- make test

- name: build
pull: default
image: golang:1.17
image: golang:1.19
commands:
- make build

- name: lint-code
pull: default
image: golang:1.17
image: golang:1.19
commands:
- make golangci-lint
- make lint
Expand All @@ -42,36 +37,3 @@ steps:
- git remote add k8s https://github.com/webhookrelay/webhookrelay-operator
- git fetch k8s master
- ct lint --config .scripts/ct.yaml

- name: publish-multiarch-images
image: quay.io/unikiosk/test-base
commands:
# Get latest tag version
- git fetch --tags
# Set the hosts
- docker login --username "$${DOCKER_USERNAME}" --password "$${DOCKER_PASSWORD}"
# Create buildx cluster
- docker buildx create --name cluster
- DOCKER_HOST=$${DOCKER_ARM_BUILDER} docker buildx create --name cluster --append
- docker buildx use cluster
- docker buildx ls
# Build the image
- make buildx-images
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_ARM_BUILDER:
from_secret: docker_arm_builder
volumes:
- name: dockersocket
path: /var/run/docker.sock

# TODO: enable once OK
# trigger:
# branch:
# - master
# ref:
# include:
# - refs/tags/**
29 changes: 29 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: image

on:
push:
branches: ['master']
workflow_dispatch:

permissions:
contents: read
packages: write
id-token: write

jobs:
image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
- uses: imjasonh/[email protected]
env:
KO_DOCKER_REPO: webhookrelay/webhookrelay-operator
- env:
auth_token: ${{ secrets.auth_token }}
run: |
echo "${{ secrets.DOCKER_USERNAME }}" | ko login docker.io --username "${{ secrets.DOCKER_PASSWORD }}" --password-stdin
make ko-build
12 changes: 6 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ linters:
disable-all: true
enable:
- bodyclose
- deadcode
# - deadcode
- depguard
- dogsled
- dupl
Expand All @@ -80,28 +80,28 @@ linters:
- gocyclo
- gofmt
- goimports
- golint
# - golint
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
# - interfacer
- lll
- misspell
- nakedret
- nolintlint
- rowserrcheck
- scopelint
# - scopelint
- staticcheck
- structcheck
# - structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
# - varcheck
# - whitespace

# don't enable:
Expand Down
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ build:
-o ./build/_output/bin/webhookrelay-operator \
./cmd/manager

ko-build:
GOFLAGS="$(LDFLAGS)" ko build -B --platform=all -t latest -t $(GIT_REVISION) ./cmd/*

##############################
# DEV #
##############################
Expand Down Expand Up @@ -56,12 +59,24 @@ image-operator:

# Cross-platform images
buildx-images:
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 \
docker buildx build --builder synpse \
--push \
--cache-from=type=registry,ref=webhookrelay/webhookrelay-operator \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t webhookrelay/webhookrelay-operator:latest \
-f build/Dockerfile .

# buildkit-images:
# buildctl build \
# --frontend dockerfile.v0 \
# --local context=. \
# --local dockerfile=./build \
# --opt platform=linux/amd64,linux/arm64,linux/arm/v7 \
# --output type=image,name=docker.io/webhookrelay/webhookrelay-operator:latest,push=true \
# ...

lint:
$(GOLANGCI_LINT) run
$(GOLANGCI_LINT) run --timeout 5m

##############################
# Third-party tools #
Expand All @@ -82,5 +97,5 @@ yq: ## Install yq.

golangci-lint: ## Install golangci-lint
@if [ ! -f $(GOLANGCI_LINT) ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BUILD_DIR) v1.27.0; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BUILD_DIR) v1.50.1; \
fi
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ spec:
lockPath: true # set to 'false' to reuse any extra path WHR received
disabled: false # set to 'true' to disable output
destination: http://destination:5050/webhooks
# Use custom Docker image
#image: "quay.io/your-custom/image:latest"
# Add custom env variables to the agent container
extraEnvVars:
- name: WEBSOCKET_TRANSPORT
value: "true"
```
Create the CR:
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17 as build
FROM golang:1.19 as build
COPY . /go/src/github.com/webhookrelay/webhookrelay-operator
WORKDIR /go/src/github.com/webhookrelay/webhookrelay-operator
RUN make build
Expand Down
104 changes: 104 additions & 0 deletions charts/webhookrelay-operator/crds/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,110 @@ spec:
type: array
type: object
type: array
extraEnvVars:
description: Extra environment variables to pass to the relay agent
container
items:
description: EnvVar represents an environment variable present in
a Container.
properties:
name:
description: Name of the environment variable. Must be a C_IDENTIFIER.
type: string
value:
description: 'Variable references $(VAR_NAME) are expanded using
the previous defined environment variables in the container
and any service environment variables. If a variable cannot
be resolved, the reference in the input string will be unchanged.
The $(VAR_NAME) syntax can be escaped with a double $$, ie:
$$(VAR_NAME). Escaped references will never be expanded, regardless
of whether the variable exists or not. Defaults to "".'
type: string
valueFrom:
description: Source for the environment variable's value. Cannot
be used if value is not empty.
properties:
configMapKeyRef:
description: Selects a key of a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the ConfigMap or its key
must be defined
type: boolean
required:
- key
type: object
fieldRef:
description: 'Selects a field of the pod: supports metadata.name,
metadata.namespace, metadata.labels, metadata.annotations,
spec.nodeName, spec.serviceAccountName, status.hostIP,
status.podIP, status.podIPs.'
properties:
apiVersion:
description: Version of the schema the FieldPath is
written in terms of, defaults to "v1".
type: string
fieldPath:
description: Path of the field to select in the specified
API version.
type: string
required:
- fieldPath
type: object
resourceFieldRef:
description: 'Selects a resource of the container: only
resources limits and requests (limits.cpu, limits.memory,
limits.ephemeral-storage, requests.cpu, requests.memory
and requests.ephemeral-storage) are currently supported.'
properties:
containerName:
description: 'Container name: required for volumes,
optional for env vars'
type: string
divisor:
anyOf:
- type: integer
- type: string
description: Specifies the output format of the exposed
resources, defaults to "1"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
resource:
description: 'Required: resource to select'
type: string
required:
- resource
type: object
secretKeyRef:
description: Selects a key of a secret in the pod's namespace
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
type: object
required:
- name
type: object
type: array
image:
description: Image is webhookrelayd container, defaults to webhookrelay/webhookrelayd:latest
type: string
Expand Down
Loading

0 comments on commit 8e68a88

Please sign in to comment.