Initial commit of templates

main
Tom Peltonen 2024-01-01 23:35:13 +11:00
commit afa32b961c
10 changed files with 1363 additions and 0 deletions

View File

@ -0,0 +1,2 @@
# Nothing to see here

View File

View File

@ -0,0 +1,64 @@
steps:
# Builds your Go application
build:
# Set your preferred Go version:
image: golang:1.17
environment:
# Needed if you want to cross-compile and package the binary in a container.
- CGO_ENABLED=0
# Select your target OS:
- GOOS=linux
# Select your target architecture:
- GOARCH=amd64
commands:
- go get
- go build
# Runs a dryrun to build the docker container
dryrun-docker:
image: plugins/kaniko
settings:
repo: DOCKERUSERNAME/DOCKERHUBREPO
tags: test
dockerfile: Dockerfile
# Just builds the container without a push to DockerHub.
no_push: true
when:
event: pull_request
# Builds and publishes a docker container to DockerHub from the main-branch
publish-docker-latest:
image: plugins/kaniko
settings:
repo: DOCKERUSERNAME/DOCKERHUBREPO
tags: latest
dockerfile: Dockerfile
username:
# Secret 'docker_username' needs to be set in the CI settings
from_secret: docker_username
password:
# Secret 'docker_password' needs to be set in the CI settings
from_secret: docker_password
when:
# Push new version of tag latest if new push on main-branch
event: push
branch: main
# Builds and publishes a docker container of a tag
publish-docker-tag:
image: plugins/kaniko
settings:
repo: DOCKERUSERNAME/DOCKERHUBREPO
# Uses the tag from git for the container tag
tags: ${CI_COMMIT_TAG}
dockerfile: Dockerfile
username:
# Secret 'docker_username' needs to be set in the CI settings
from_secret: docker_username
password:
# Secret 'docker_password' needs to be set in the CI settings
from_secret: docker_password
when:
# Push new version when version tag is created
event: tag
ref: refs/tags/v*

View File

@ -0,0 +1,13 @@
# Woodpecker CI definition for CI# {{.Redi.Asset.Id}} (from RediOps)
# Name: {{.Redi.Name}}
# Organisation: {{.Redi.Organisation}}
# Git repository: {{.Redi.Repository.Source.Url}}
steps:
build:
image: golang:1.17
commands:
- go download
- go get
- go build -o {{.AssetName}} .\...
# Optional: Run go tests
- go test .\...

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
# Condition entry
#Before:{{if .ServiceName}}
Conditioned text{{end}}
#After
# Loop through entries{{range .Redi.Apis}}
API: {{.Format}}{{end}}
#------

View File

@ -0,0 +1,26 @@
version: "3.3"
name: {{.AssetId}}_traefik
services:
{{.AssetName}}:
hostname: {{.AssetId}}
image: ${QASKX_DOCKER_REPO}/{{.AssetId}}:latest
container_name: {{.UniqueId}}
restart: ${QASKX_RESTART_POLICY}
networks:
- gateway
ports:
- 8075
volumes:
- ${QASKX__STORAGE}/{{.AssetName}}/config:/home/config
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{.AssetName}}.rule=Host(`{{.Fqdn}}`)&&PathPrefix(`{{.ServicePoint}}`)"
- "traefik.http.routers.{{.AssetName}}.entrypoints=websecure"
- "traefik.http.routers.{{.AssetName}}.tls.certresolver=traefik_resolver"

View File

@ -0,0 +1,52 @@
# Sequence diagram
This represents the sequence diagram for
service **{{.ServiceName}}**
```mermaid
sequenceDiagram
participant consumer as Consumer
participant gateway as Gateway
participant microservice as {{.ServiceName}}
participant feature as Svc Feature
participant authz as Authorisation
participant log as Logger
{{ range .Apis}}participant {{ .Name }} as Svc{{ .Name }}
{{ end }}
consumer->>+gateway: {{.ServicePoint}}
activate consumer
note right of gateway: Authentication check at GW
gateway->>+microservice: {{.ServicePoint}}
microservice->>+authz: Validate requestor
note right of authz: Authorise to function
authz-->>-microservice: 200 or 401/403 status
microservice->>+feature: Check feature switch
feature-->>-microservice: 200 or 401/403 status
microservice-)log: log request/response
{{ range .Apis}}
microservice-->>+{{ .Name }}: link {{ .Url }}
note right of {{ .Name }}: Explanation of what happens
{{ .Name }}-->>-microservice: 200 OK response
{{ end }}
alt 200 OK
microservice-->>gateway: 200 OK response
gateway-->>consumer: 200 OK response
else not OK, error
microservice-->>-gateway: !200 ERR response
gateway-->>-consumer: !200 ERR response
end
deactivate consumer
```
***Note***: Adjust the default sequence diagram above
Copyright {{.QaskxDot.ServiceOwner}}
Contact {{.QaskxDot.ServiceOwnerEmail}}

View File

@ -0,0 +1,39 @@
%% Service name {{.ServicePoint}}
{{ range .Apis}}
%% Sequence diagram for {{ .ServiceId }} as Svc {{ .Name }}
sequenceDiagram
participant consumer as Consumer
participant gateway as Gateway
participant microservice as {{$.ServiceName}}
{{ range $.Depends}}
participant {{ .ServiceId }} as Svc {{ .Name }}{{ end }}
consumer->>+gateway: {{$.ServicePoint}}
note right of gateway: Authentication check at GW
gateway->>+microservice: {{$.ServicePoint}}
microservice->>+authz: Validate requestor
note right of authz: Authorise to function
authz-->>-microservice: 200 or 401/403 status
microservice->>+feature: Check feature switch
feature-->>-microservice: 200 or 401/403 status
microservice->>log: log request/response
microservice-->>+{{ .ServiceId }}: link {{ .Url }}
note right of {{ .ServiceId }}: Explanation of what happens
{{ .ServiceId }}-->>-microservice: 200 OK response
alt 200 OK
microservice-->>gateway: 200 OK response
gateway-->>-consumer: 200 OK response
else not OK, error
microservice-->>-gateway: !200 ERR response
gateway-->>-consumer: !200 ERR response
end
{{ end }}

View File

@ -0,0 +1,52 @@
%% {{.ServiceName}} service sequence
sequenceDiagram
participant consumer as Consumer
participant gateway as Gateway
{{ range .Apis}}participant {{ .ServiceId }} as {{.Name}}
{{ end }}
{{ range .Depends}}participant {{ .ServiceId }} as Svc {{ .Name }}
{{ end }}
{{ range .Apis}}
rect rgb(191, 223, 255)
consumer->>+gateway: {{$.ServicePoint}}
note right of gateway: Authentication check at GW
gateway->>+authz: Validate requestor
authz-->>-gateway: 200 or 401/403 status
gateway->>+{{ .ServiceId }}: start
{{ .ServiceId }}->>+authz: Fine grained authz
note right of authz: Authorise to function, data
authz-->>-{{ .ServiceId }}: 200 or 401/403 status
{{ .ServiceId }}->>+featureflag: Check feature switch
featureflag-->>-{{ .ServiceId }}: 200 or 401/403 status
{{ .ServiceId }}->>logger: log request/response
{{ .ServiceId }}->>{{ .ServiceId }}: business logic
note right of {{ .ServiceId }}: Explanation of what happens
{{with $microservice := .ServiceId }}
{{ range $.Depends }}{{ $microservice }}->>+{{ .ServiceId }}: function call
{{ .ServiceId }}-->>- {{ $microservice }}: result, 200 or 4xx status
{{ end }}
{{ end }}
{{ .ServiceId }}->>{{ .ServiceId }}: business logic
note right of {{ .ServiceId }}: Explanation of what happens
alt 200 OK
{{ .ServiceId }}-->>-gateway: 200 OK response
gateway-->>-consumer: 200 OK response
else not OK, error
{{ .ServiceId }}-->>-gateway: !200 ERR response
gateway-->>-consumer: !200 ERR response
end
end
{{ end }}