Skip to content

Commit

Permalink
Merge branch 'main' of github.com:UffizziCloud/uffizzi_controller int…
Browse files Browse the repository at this point in the history
…o main
  • Loading branch information
axisofentropy committed Mar 30, 2022
2 parents 6e266b4 + 4d31d13 commit 4280615
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 93 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test, Lint, Build, and Publish Image
on:
push:
branches:
- qa
- develop
- main
pull_request:
types: [opened,synchronize,reopened]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.44
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'
- name: Run tests
run: make test
build-and-push-some-branches:
runs-on: ubuntu-latest
needs:
- lint
- test
if: ${{ github.ref_name == 'main' || github.ref_name == 'qa' || github.ref_name == 'develop' || github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: uffizzi/controller
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=branch,enable=${{ github.ref_name == 'qa' || github.ref_name == 'develop' }}
type=ref,event=pr
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update Docker Hub Description for Default Branch
uses: peter-evans/[email protected]
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: uffizzi/controller
88 changes: 0 additions & 88 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
APP_NAME=uffizzi
CI_PROJECT_ID="sapient-flare-242118"
GCP_REGION=us-central1-c

CI_REPO_URL="gcr.io/${CI_PROJECT_ID}"
GCP_REPO_URL="gcr.io/${GCP_PROJECT_ID}"

CONTROLLER_IMAGE_NAME="${APP_NAME}-controller"
CONTROLLER_IMAGE="${CI_REPO_URL}/${CONTROLLER_IMAGE_NAME}"
Expand Down Expand Up @@ -48,88 +43,5 @@ fix_lint:
test:
ENV=test go test ./...

# CI targets

image_names:
export CONTROLLER_IMAGE=${CONTROLLER_IMAGE}:${VERSION}

ci_registry_login:
echo ${CI_SERVICE_ACCOUNT_KEY} | docker login -u _json_key --password-stdin https://gcr.io

registry_login:
cat ${SERVICE_ACCOUNT_KEY} | docker login -u _json_key --password-stdin https://gcr.io

build_controller:
docker pull "${CONTROLLER_IMAGE}:${CI_COMMIT_REF_SLUG}" || true
docker pull "${CONTROLLER_IMAGE}:latest" || true
docker build \
--cache-from "${CONTROLLER_IMAGE}:${CI_COMMIT_REF_SLUG}" \
--cache-from "${CONTROLLER_IMAGE}:latest" \
--build-arg SENTRY_RELEASE=${SHORT_VERSION} \
-t ${CONTROLLER_IMAGE}:${VERSION} \
-t "${CONTROLLER_IMAGE}:${CI_COMMIT_REF_SLUG}" \
-t ${CONTROLLER_IMAGE}:${SHORT_VERSION} \
-t ${CONTROLLER_IMAGE}:latest \
.

push_controller:
docker push ${CONTROLLER_IMAGE}:${VERSION}
docker push ${CONTROLLER_IMAGE}:${SHORT_VERSION}
docker push ${CONTROLLER_IMAGE}:${CI_COMMIT_REF_SLUG} || true
docker push ${CONTROLLER_IMAGE}:latest

push_gcp_controller:
docker push ${GCP_CONTROLLER_IMAGE}:${VERSION}
docker push ${GCP_CONTROLLER_IMAGE}:${SHORT_VERSION}
docker push ${GCP_CONTROLLER_IMAGE}:${CI_COMMIT_REF_SLUG} || true
docker push ${GCP_CONTROLLER_IMAGE}:latest

sentry_environment:
export SENTRY_ORG=${APP_NAME}-cloud
export SENTRY_PROJECT=${APP_NAME}-controller

sentry_release:
sentry-cli releases new ${SHORT_VERSION}
sentry-cli releases set-commits --auto ${SHORT_VERSION}
sentry-cli releases finalize ${SHORT_VERSION}
sentry-cli releases deploys ${SHORT_VERSION} new -e ${ENV}

pull_ci_image:
docker pull ${CONTROLLER_IMAGE}:${VERSION}
docker pull ${CONTROLLER_IMAGE}:${SHORT_VERSION}
docker pull ${CONTROLLER_IMAGE}:${CI_COMMIT_REF_SLUG} || true
docker pull ${CONTROLLER_IMAGE}:latest

tag_image:
docker tag ${CONTROLLER_IMAGE}:${SHORT_VERSION} ${GCP_CONTROLLER_IMAGE}:${VERSION}
docker tag ${CONTROLLER_IMAGE}:${SHORT_VERSION} ${GCP_CONTROLLER_IMAGE}:${SHORT_VERSION}
docker tag ${CONTROLLER_IMAGE}:${SHORT_VERSION} ${GCP_CONTROLLER_IMAGE}:${CI_COMMIT_REF_SLUG} || true
docker tag ${CONTROLLER_IMAGE}:${SHORT_VERSION} ${GCP_CONTROLLER_IMAGE}:latest

update_image: pull_ci_image tag_image registry_login push_gcp_controller

setup_gke_kube:
gcloud auth activate-service-account --key-file ${SERVICE_ACCOUNT_KEY}
gcloud config set project ${GCP_PROJECT_ID}
gcloud container clusters get-credentials ${CLUSTER_NAME} --zone ${GCP_REGION}

setup_eks_kube:
aws eks --region ${AWS_DEFAULT_REGION} update-kubeconfig --name ${CLUSTER_NAME}

aks_login:
az login --service-principal --username ${AZURE_USERNAME} --password ${AZURE_SERVICE_PRINCIPAL_KEY} --tenant ${AZURE_TENANT}

setup_aks_kube: aks_login
az aks get-credentials --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}

update_gke_controller_service: setup_gke_kube
kubectl set image deployment/uffizzi-controller -n uffizzi-controller controller=${GCP_CONTROLLER_IMAGE}:${SHORT_VERSION}

update_eks_controller_service: setup_eks_kube
kubectl set image deployment/uffizzi-controller -n uffizzi-controller controller=${GCP_CONTROLLER_IMAGE}:${SHORT_VERSION}

update_aks_controller_service: setup_aks_kube
kubectl set image deployment/uffizzi-controller -n uffizzi-controller controller=${GCP_CONTROLLER_IMAGE}:${SHORT_VERSION}

generate_docs:
cmd/swag init -g cmd/controller/main.go --generatedTime=false --markdownFiles docs/markdown
4 changes: 0 additions & 4 deletions docker-compose.ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion internal/http/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ApplyResourceRequest struct {
func (h *Handlers) handleApplyResource(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)

deploymentID, err := strconv.ParseUint(vars["deploymentId"], 10, 64)
deploymentID, err := strconv.ParseUint(vars["deploymentId"], 10, 64) //nolint: gomnd
if err != nil {
handleError(err, w, r)
return
Expand Down

0 comments on commit 4280615

Please sign in to comment.