Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nisan Itzhakov committed Nov 15, 2023
1 parent 12804d4 commit 9186e2c
Show file tree
Hide file tree
Showing 260 changed files with 27,475 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
testbin/
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.md]
max_line_length = 100
59 changes: 59 additions & 0 deletions .github/workflows/kuttl_workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: kuttl_workflow
on:
workflow_call:
inputs:
istio_ver:
required: true
type: string
kind_image:
required: true
type: string

jobs:
kuttl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Versions from .tool-versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions
- name: Install asdf & tools
uses: asdf-vm/actions/install@v2
- name: custom environment variables
uses: krisalay/[email protected]
with:
filename: e2e-testing/env
- uses: helm/[email protected]
if: inputs.kind_image == ''
with:
node_image: "${{ env.KIND_CUSTOM_IMAGE }}"
version: "v${{ env.KIND_VERSION }}"
cluster_name: kuttl
- uses: helm/[email protected]
if: inputs.kind_image != ''
with:
node_image: ${{ inputs.kind_image }}
version: "v${{ env.KIND_VERSION }}"
cluster_name: kuttl
- name: add to PATH
run: |
mkdir -p ${HOME}/bin
echo "${HOME}/bin" >> "$GITHUB_PATH"
- name: install istio (custom version)
run: |
asdf install istioctl ${{ inputs.istio_ver }}
asdf local istioctl ${{ inputs.istio_ver }}
istioctl version --remote=false
if: inputs.istio_ver != ''
- name: Setup Cluster
run: ./e2e-testing/scripts/setup.sh up
env:
KIND_CLUSTER_NAME: kuttl
# Uncomment the next step to access a shell on github actions.
# - name: tmate debug session
# uses: mxschmitt/action-tmate@v3
- name: Run kuttl tests
run: |
# Let the system enough time to start
sleep 30
make kuttl
21 changes: 21 additions & 0 deletions .github/workflows/multiple-versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: multiple-versions
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:

jobs:
kuttl:
strategy:
matrix:
versions:
- kind_image: "kindest/node:v1.25.3"
istio: "1.16.2"
- kind_image: "kindest/node:v1.23.13"
istio: "1.14.6"
- kind_image: "kindest/node:v1.21.10"
istio: "1.12.2"
uses: ./.github/workflows/kuttl_workflow.yaml
with:
istio_ver: ${{ matrix.versions.istio }}
kind_image: ${{ matrix.versions.kind_image }}
36 changes: 36 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: tests
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
kuttl:
uses: ./.github/workflows/kuttl_workflow.yaml
with:
istio_ver: ''
kind_image: ''
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install asdf & tools
uses: asdf-vm/actions/install@v2
- run: make test lint
pre-merge-tasks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install asdf & tools
uses: asdf-vm/actions/install@v2
- name: Verify pre-merge tasks are committed.
run: |
make prepare
make pre-merge
if [[ `git status --porcelain` ]]; then
echo "There seem to be changes after 'pre-merge' tasks, did you run these tasks before committing?"
exit 1
else
echo "Pre-merge tasks are committed :)"
fi
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin
testbin/*

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~
.vscode

# generated during make bundle
/bundle.Dockerfile
/kubeconfig

# terraform
.terraform/

*.tfstate*
18 changes: 18 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Our default golangci-lint configuration
# If these linters fail then it should fail the build.
run:
timeout: 5m
linters:
disable-all: true
# these are the default list of enabled
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
presets:
- bugs
- unused
14 changes: 14 additions & 0 deletions .run/Build & Run.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build &amp; Run" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="dynamic-environment" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="ENABLE_WEBHOOKS" value="false" />
</envs>
<kind value="FILE" />
<package value="$PROJECT_DIR$/main.go" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/main.go" />
<method v="2" />
</configuration>
</component>
10 changes: 10 additions & 0 deletions .run/Make Build.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Make Build" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
<makefile filename="$PROJECT_DIR$/Makefile" target="build" workingDirectory="$PROJECT_DIR$" arguments="">
<envs>
<env name="ENABLE_WEBHOOKS" value="false" />
</envs>
</makefile>
<method v="2" />
</configuration>
</component>
8 changes: 8 additions & 0 deletions .run/Manifests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Manifests" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
<makefile filename="$PROJECT_DIR$/Makefile" target="manifests generate" workingDirectory="$PROJECT_DIR$/" arguments="">
<envs />
</makefile>
<method v="2" />
</configuration>
</component>
8 changes: 8 additions & 0 deletions .run/PreTest.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PreTest" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
<makefile filename="$PROJECT_DIR$/Makefile" target="manifests generate fmt vet envtest" workingDirectory="$PROJECT_DIR$/" arguments="">
<envs />
</makefile>
<method v="2" />
</configuration>
</component>
17 changes: 17 additions & 0 deletions .run/Test Handlers.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test Handlers" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="dynamic-environment" />
<working_directory value="$PROJECT_DIR$/pkg/handlers" />
<envs>
<env name="KUBEBUILDER_ASSETS" value="$USER_HOME$/Library/Application Support/io.kubebuilder.envtest/k8s/1.22.1-darwin-amd64" />
</envs>
<root_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<package value="github.com/riskified/dynamic-environment/pkg/handlers/" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestAPIs\E$" />
<method v="2" />
</configuration>
</component>
17 changes: 17 additions & 0 deletions .run/Test all.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test all" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="dynamic-environment" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="KUBEBUILDER_ASSETS" value="$USER_HOME$/Library/Application Support/io.kubebuilder.envtest/k8s/1.22.1-darwin-amd64" />
</envs>
<kind value="DIRECTORY" />
<package value="github.com/riskified/dynamic-environment" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="PreTest" run_configuration_type="MAKEFILE_TARGET_RUN_CONFIGURATION" />
</method>
</configuration>
</component>
17 changes: 17 additions & 0 deletions .run/Test v1alpha1 (api_v1alpha1).run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test v1alpha1 (api/v1alpha1)" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="dynamic-environment" />
<working_directory value="$PROJECT_DIR$/api/v1alpha1" />
<envs>
<env name="KUBEBUILDER_ASSETS" value="$USER_HOME$/Library/Application Support/io.kubebuilder.envtest/k8s/1.22.1-darwin-amd64" />
</envs>
<root_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<package value="github.com/riskified/dynamic-environment/api/v1alpha1" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestAPIs\E$" />
<method v="2" />
</configuration>
</component>
8 changes: 8 additions & 0 deletions .run/Test.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
<makefile filename="$PROJECT_DIR$/Makefile" target="test" workingDirectory="$PROJECT_DIR$/" arguments="">
<envs />
</makefile>
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TestAPIs in github.com/riskified/dynamic-environment/pkg/handlers" type="GoTestRunConfiguration" factoryName="Go Test" nameIsGenerated="true">
<module name="dynamic-environment" />
<working_directory value="$PROJECT_DIR$/pkg/handlers" />
<root_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<package value="github.com/riskified/dynamic-environment/pkg/handlers" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestAPIs\E$" />
<method v="2" />
</configuration>
</component>
7 changes: 7 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
golang 1.19.8
act 0.2.26
kuttl 0.15.0
operator-sdk 1.28.0
kind 0.18.0
istioctl 1.17.2
golangci-lint 1.53.2
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Build the manager binary
FROM golang:1.19 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/
COPY extensions/ extensions/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

ENTRYPOINT ["/manager"]
Loading

0 comments on commit 9186e2c

Please sign in to comment.