-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: dntosas <[email protected]>
- Loading branch information
Showing
2,568 changed files
with
1,436,747 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
dist: bin | ||
project_name: capi2argo-cluster-operator | ||
env: | ||
- DOCKER_REPO="ghcr.io/dntosas" | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
binary: "{{ .ProjectName }}" | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
flags: | ||
- -trimpath | ||
- -mod=vendor | ||
ldflags: | ||
- -s -w | ||
- -X {{ .ProjectName }}/cmd.Version=dev | ||
- -X {{ .ProjectName }}/cmd.CommitHash={{ .FullCommit }} | ||
main: . | ||
|
||
dockers: | ||
# amd64 | ||
- image_templates: | ||
- ghcr.io/dntosas/{{ .ProjectName }}:dev-amd64 | ||
dockerfile: Dockerfile | ||
use: buildx | ||
goos: linux | ||
goarch: amd64 | ||
build_flag_templates: | ||
- "--pull" | ||
- "--platform=linux/amd64" | ||
# arm64 | ||
- image_templates: | ||
- ghcr.io/dntosas/{{ .ProjectName }}:dev-arm64 | ||
dockerfile: Dockerfile | ||
use: buildx | ||
goos: linux | ||
goarch: arm64 | ||
build_flag_templates: | ||
- "--pull" | ||
- "--platform=linux/arm64/v8" | ||
|
||
docker_manifests: | ||
# https://goreleaser.com/customization/docker_manifest/ | ||
- name_template: ghcr.io/dntosas/{{ .ProjectName }}:dev | ||
image_templates: | ||
- ghcr.io/dntosas/{{ .ProjectName }}:dev-amd64 | ||
- ghcr.io/dntosas/{{ .ProjectName }}:dev-arm64 | ||
|
||
release: | ||
disable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: E2E Tests | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
e2e: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.20.3' | ||
|
||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
logout: false | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
args: release --clean --config .github/config/goreleaser-dev.yaml | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PRIVATE_KEY }} | ||
|
||
- name: Create k8s Kind Cluster | ||
uses: helm/[email protected] | ||
|
||
- name: Run E2E tests | ||
run: make e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ jobs: | |
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.20.2' | ||
go-version: '1.20.3' | ||
|
||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ jobs: | |
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.20.2' | ||
go-version: '1.20.3' | ||
|
||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
@@ -44,7 +44,7 @@ jobs: | |
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
args: release --clean --config .github/config/goreleaser.yaml | ||
args: release --clean --config .github/config/goreleaser-prod.yaml | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PRIVATE_KEY }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ jobs: | |
- name: Install Helm | ||
uses: azure/[email protected] | ||
with: | ||
version: v3.9.0 | ||
version: v3.11.3 | ||
|
||
- name: Add Helm dependency repos | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/gruntwork-io/terratest/modules/helm" | ||
http_helper "github.com/gruntwork-io/terratest/modules/http-helper" | ||
"github.com/gruntwork-io/terratest/modules/k8s" | ||
"github.com/gruntwork-io/terratest/modules/random" | ||
// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestE2ECapi2Argo(t *testing.T) { | ||
// Path to the helm chart we will test | ||
helmChartPath := "../charts/capi2argo-cluster-operator" | ||
|
||
// Setup the kubectl config and context. Here we choose to use the defaults, which is: | ||
// - HOME/.kube/config for the kubectl config file | ||
// - Current context of the kubectl config file | ||
// We also specify that we are working in the default namespace (required to get the Pod) | ||
// kubectlOptions := k8s.NewKubectlOptions("", "", "default") | ||
|
||
// We generate a unique release name so that we can refer to after deployment. | ||
// By doing so, we can schedule the delete call here so that at the end of the test, we run | ||
// `helm delete RELEASE_NAME` to clean up any resources that were created. | ||
releaseName := fmt.Sprintf("caco-%s", strings.ToLower(random.UniqueId())) | ||
|
||
// Setup the chart options. For this test, we will set the following input values: | ||
options := &helm.Options{ | ||
SetValues: map[string]string{ | ||
"fullnameOverride": releaseName, | ||
"image.tag": "dev", | ||
}, | ||
ExtraArgs: map[string][]string{ | ||
"upgrade": {"--wait"}, | ||
}, | ||
} | ||
|
||
// Clean up deployment on when finished | ||
defer helm.Delete(t, options, releaseName, true) | ||
|
||
// Deploy the chart using `helm upgrade`. Note that we use the version without `E`, since we want to assert the | ||
// install succeeds without any errors. | ||
helm.Upgrade(t, options, helmChartPath, releaseName) | ||
|
||
// Now that the chart is deployed, verify the deployment and get the name of working pod. | ||
// filter := &metav1.ListOptions{ | ||
// LabelSelector: fmt.Sprintf("app.kubernetes.io/instance=%s", releaseName), | ||
// } | ||
// pod := k8s.ListPods(t, kubectlOptions, *filter) | ||
// podName := pod[0].Name | ||
|
||
// This function will open a tunnel to the Pod and hit astrolavos container endpoint. | ||
// VerifyExposedMetrics(t, kubectlOptions, podName) | ||
} | ||
|
||
// VerifyExposedMetrics will open a tunnel to the Pod and hit the endpoint to verify the metrics are exposed. | ||
func VerifyExposedMetrics(t *testing.T, kubectlOptions *k8s.KubectlOptions, podName string) { | ||
// Wait for the pod to come up. It takes some time for the Pod to start, so retry a few times. | ||
retries := 15 | ||
sleep := 5 * time.Second | ||
k8s.WaitUntilPodAvailable(t, kubectlOptions, podName, retries, sleep) | ||
|
||
// We will first open a tunnel to the pod, making sure to close it at the end of the test. | ||
tunnel := k8s.NewTunnel(kubectlOptions, k8s.ResourceTypePod, podName, 0, 3000) | ||
defer tunnel.Close() | ||
tunnel.ForwardPort(t) | ||
|
||
// Now that we have the tunnel, we will verify that we get back a 200 OK on /metrics endpoint plus metrics | ||
// for our defined target. | ||
// It takes some time for the Pod to start, so retry a few times. | ||
endpoint := fmt.Sprintf("http://%s/metrics", tunnel.Endpoint()) | ||
http_helper.HttpGetWithRetryWithCustomValidation( | ||
t, | ||
endpoint, | ||
nil, | ||
retries, | ||
sleep, | ||
func(statusCode int, body string) bool { | ||
return statusCode == 200 && strings.Contains(body, "endpoint=\"https://kubernetes\"") | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module github.com/dntosas/astrolavos/tests | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/gruntwork-io/terratest v0.41.10 | ||
k8s.io/apimachinery v0.20.6 | ||
) | ||
|
||
require ( | ||
cloud.google.com/go v0.83.0 // indirect | ||
github.com/aws/aws-sdk-go v1.40.56 // indirect | ||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect | ||
github.com/ghodss/yaml v1.0.0 // indirect | ||
github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0 // indirect | ||
github.com/go-logr/logr v0.2.0 // indirect | ||
github.com/go-sql-driver/mysql v1.4.1 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/gofuzz v1.1.0 // indirect | ||
github.com/google/uuid v1.2.0 // indirect | ||
github.com/googleapis/gnostic v0.4.1 // indirect | ||
github.com/gruntwork-io/go-commons v0.8.0 // indirect | ||
github.com/hashicorp/errwrap v1.0.0 // indirect | ||
github.com/hashicorp/go-multierror v1.1.0 // indirect | ||
github.com/imdario/mergo v0.3.11 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
github.com/json-iterator/go v1.1.11 // indirect | ||
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/pquerna/otp v1.2.0 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
github.com/urfave/cli v1.22.2 // indirect | ||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect | ||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect | ||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect | ||
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect | ||
golang.org/x/text v0.3.6 // indirect | ||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/protobuf v1.26.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
k8s.io/api v0.20.6 // indirect | ||
k8s.io/client-go v0.20.6 // indirect | ||
k8s.io/klog/v2 v2.4.0 // indirect | ||
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.0.3 // indirect | ||
sigs.k8s.io/yaml v1.2.0 // indirect | ||
) |
Oops, something went wrong.