Skip to content

Commit

Permalink
chore: Project Setup (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsalles authored Nov 22, 2021
1 parent f3c6372 commit c3826b0
Show file tree
Hide file tree
Showing 11 changed files with 895 additions and 126 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/merge-master.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: Merge master

# FIX: remove the following line and uncomment the others to continue
on: {}
# on:
# push:
# branches:
# - master
on:
push:
branches:
- master


jobs:
prepare:
name: Calculate Version and build number
name: Calculate Version and Build Number
runs-on: ubuntu-20.04

outputs:
Expand Down Expand Up @@ -51,7 +49,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16'
go-version: '1.17'

- name: Cache Go modules
uses: actions/cache@v2
Expand All @@ -63,7 +61,7 @@ jobs:
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Build for test
- name: Build for Test
run: make build


Expand Down
63 changes: 14 additions & 49 deletions .github/workflows/prereleased.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
name: Prereleased

# FIX: remove the following line and uncomment the others to continue
on: {}
# on:
# release:
# types:
# - prereleased
on:
release:
types:
- prereleased


env:
COMPONENT: laboratory-controller
COMPONENT_PATH: apps/laboratory-controller
COMPONENT: authentication-service
COMPONENT_PATH: apps/authentication-service

API_CONTAINER: api_container_image
API_DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/laboratory-controller/api

MANAGER_CONTAINER: manager_container_image
MANAGER_DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/laboratory-controller/manager
CONTAINER: container_image
DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/authentication-service


jobs:
Expand Down Expand Up @@ -48,36 +43,8 @@ jobs:
run: echo ::set-output name=value::${GITHUB_REF#refs/*/}


build-api:
name: Build API
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- uses: actions/checkout@v2

- uses: docker/login-action@v1
with:
registry: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- uses: docker/setup-buildx-action@v1

- uses: docker/build-push-action@v2
id: docker_build
with:
file: api.Dockerfile
push: true
tags: ${{ env.API_DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GHCR_TOKEN }}
build-manager:
name: Build Manager
build:
name: Build
runs-on: ubuntu-20.04

needs:
Expand All @@ -97,9 +64,9 @@ jobs:
- uses: docker/build-push-action@v2
id: docker_build
with:
file: manager.Dockerfile
file: Dockerfile
push: true
tags: ${{ env.MANAGER_DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
tags: ${{ env.DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GHCR_TOKEN }}
Expand All @@ -110,8 +77,7 @@ jobs:

needs:
- prepare
- build-api
- build-manager
- build

steps:
- name: Checkout Manifests repo
Expand All @@ -129,8 +95,7 @@ jobs:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
cd ${COMPONENT_PATH}
kustomize edit set image ${API_CONTAINER}=${API_DOCKER_IMAGE_URL}:${VERSION}
kustomize edit set image ${MANAGER_CONTAINER}=${MANAGER_DOCKER_IMAGE_URL}:${VERSION}
kustomize edit set image ${CONTAINER}=${DOCKER_IMAGE_URL}:${VERSION}
- name: Commit and push image update into manifests repo
env:
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Pull request

# FIX: remove the following line and uncomment the others to continue
on: {}
# on:
# pull_request:
# branches:
# - master
on:
pull_request:
branches:
- master

jobs:
build:
Expand All @@ -18,7 +16,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16'
go-version: '1.17'

- name: Cache Go modules
uses: actions/cache@v2
Expand All @@ -32,3 +30,9 @@ jobs:
- name: Run vet
run: make vet

- name: Run build
run: make build

- name: Run tests
run: make test
62 changes: 16 additions & 46 deletions .github/workflows/released.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
name: Released

# FIX: remove the following line and uncomment the others to continue
on: {}
# on:
# release:
# types:
# - released
on:
release:
types:
- released


env:
COMPONENT: laboratory-controller
COMPONENT_PATH: apps/laboratory-controller
COMPONENT: authentication-service
COMPONENT_PATH: apps/authentication-service

API_CONTAINER: api_container_image
API_DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/laboratory-controller/api

MANAGER_CONTAINER: manager_container_image
MANAGER_DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/laboratory-controller/manager
CONTAINER: container_image
DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/authentication-service


jobs:
Expand All @@ -40,48 +35,25 @@ jobs:
run: echo "::set-output name=value::$(git rev-parse --short HEAD)"


docker-tag-api:
name: Docker Tag and Push API
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- uses: docker/login-action@v1
with:
registry: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Docker tag and push
env:
SOURCE: ${{ env.API_DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.build_number }}
DESTINATION: ${{ env.API_DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
run: |
docker pull $SOURCE
docker tag $SOURCE $DESTINATION
docker push $DESTINATION
docker-tag-manager:
name: Docker Tag and Push Manager
docker-tag:
name: Docker Tag and Push
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- uses: docker/login-action@v1
- name: Login to GitHub docker
uses: docker/login-action@v1
with:
registry: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Docker tag and push
env:
SOURCE: ${{ env.MANAGER_DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.build_number }}
DESTINATION: ${{ env.MANAGER_DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
SOURCE: ${{ env.DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.build_number }}
DESTINATION: ${{ env.DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
run: |
docker pull $SOURCE
docker tag $SOURCE $DESTINATION
Expand All @@ -94,8 +66,7 @@ jobs:

needs:
- prepare
- docker-tag-api
- docker-tag-manager
- docker-tag

steps:
- name: Checkout Manifests repo
Expand All @@ -113,8 +84,7 @@ jobs:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
cd ${COMPONENT_PATH}
kustomize edit set image ${API_CONTAINER}=${API_DOCKER_IMAGE_URL}:${VERSION}
kustomize edit set image ${MANAGER_CONTAINER}=${MANAGER_DOCKER_IMAGE_URL}:${VERSION}
kustomize edit set image ${CONTAINER}=${DOCKER_IMAGE_URL}:${VERSION}
- name: Commit and push image update into manifests repo
env:
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ FROM gcr.io/distroless/base:latest-amd64

WORKDIR /

# FIX: this must be changed to the correct name
LABEL org.opencontainers.image.source https://github.com/ydataai/go-template
LABEL org.opencontainers.image.source https://github.com/ydataai/authentication-service

COPY --from=builder /workspace/main .

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export $(shell sed 's/=.*//' .env)

GOPATH=$(shell go env GOPATH)

.PHONY: help build fmt vet
.PHONY: help build fmt vet test

help: # The following lines will print the available commands when entering just 'make'. ⚠️ This needs to be the first target, ever
ifeq ($(UNAME), Linux)
Expand All @@ -24,4 +24,4 @@ vet: ### Run go vet against code
go vet ./...

test: ### Runs application's tests in verbose mode
go test -v ./pkg/...
go test -v ./...
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# Go Application Template Repository
# Authentication Service

This is a rewrite of the [arrikto/oidc-authservice](https://github.com/arrikto/oidc-authservice) project to be as simple as possible.

An Authentication Service is an HTTP Server that an API Gateway (eg Ambassador, Envoy) asks if an incoming request is authorized.

* * *
## OpenID Connect

[OpenID Connect (OIDC)](http://openid.net/connect/) is an authentication layer on top of the OAuth 2.0 protocol. As OAuth 2.0 is fully supported by OpenID Connect, existing OAuth 2.0 implementations work with it out of the box.

Currently it only supports OIDC's [Authorization Code Flow](http://openid.net/specs/openid-connect-basic-1_0.html#CodeFlow), similar to OAuth 2.0 Authorization Code Grant.

* * *
## About 👯‍♂️

With ❤️ from [YData](https://ydata.ai) | [Development Team](mailto://[email protected])
11 changes: 10 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
module go-template
module github.com/ydataai/authentication-service

go 1.17

require github.com/ydataai/go-core v0.1.1

require (
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 // indirect
)
Loading

0 comments on commit c3826b0

Please sign in to comment.