refactor: move examples

This commit is contained in:
Kevin Franklin Kim 2023-09-21 10:24:11 +02:00
parent 46b0693fcb
commit 7fdc8c9c50
No known key found for this signature in database
36 changed files with 255 additions and 164 deletions

View File

@ -23,6 +23,6 @@ spec:
- name: {{ .Release.Name }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
-
- name: http
protocol: TCP
containerPort: 80

View File

@ -13,5 +13,5 @@ spec:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/component: {{ .Chart.Name }}
ports:
- name: 80
- name: http
port: 80

View File

@ -0,0 +1,3 @@
image:
repository: nginx
tag: "latest"

View File

@ -23,6 +23,6 @@ spec:
- name: {{ .Release.Name }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
-
- name: http
protocol: TCP
containerPort: 80

View File

@ -13,5 +13,5 @@ spec:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/component: {{ .Chart.Name }}
ports:
- name: 80
- name: http
port: 80

View File

@ -0,0 +1,3 @@
image:
repository: nginx
tag: "latest"

View File

@ -1,4 +1,4 @@
FROM golang:alpine as base
FROM golang:alpine as builder
ENV CGO_ENABLED=0

View File

@ -0,0 +1,59 @@
.DEFAULT_GOAL:=help
export PROJECT_ROOT=$(PWD)
## === Tasks ===
.PHONY: list
## Show config
list:
@go run ../../cmd/main.go list
.PHONY: config
## Show config
config:
@go run ../../cmd/main.go config
.PHONY: build
## Show config
build:
@go run ../../cmd/main.go build
.PHONY: template
## Show config
template:
@go run ../../cmd/main.go template
## === Utils ===
## Show help text
help:
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage"\n"; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)

View File

@ -0,0 +1,3 @@
module github.com/foomo/squadron/exmpale/helloworld
go 1.21

View File

@ -0,0 +1,19 @@
version: "2.0"
squadron:
storefinder:
backend:
chart: <% env "PROJECT_ROOT" %>/../common/charts/backend
builds:
default:
tag: latest
context: <% env "PROJECT_ROOT" %>/app
dockerfile: <% env "PROJECT_ROOT" %>/../common/docker/backend.Dockerfile
image: helloworld/app
values:
image:
tag: <% .Squadron.storefinder.backend.builds.default.tag | quote %>
repository: <% .Squadron.storefinder.backend.builds.default.image %>
service:
ports:
- 80

View File

@ -0,0 +1,61 @@
.DEFAULT_GOAL:=help
export PROJECT_ROOT=$(PWD)
files=$(shell find . -name 'squadron.yaml' | tail -r | xargs echo -n | tr " ", ",")
## === Tasks ===
.PHONY: list
## Show config
list:
@go run ../../cmd/main.go -f ${files} list
.PHONY: config
## Show config
config:
@go run ../../cmd/main.go -f ${files} config
.PHONY: build
## Show config
build:
@go run ../../cmd/main.go -f ${files} build
.PHONY: template
## Show config
template:
@go run ../../cmd/main.go -f ${files} template
## === Utils ===
## Show help text
help:
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage"\n"; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)

View File

@ -0,0 +1,17 @@
# Schema version
version: "2.0"
squadron:
checkout:
backend:
chart: <% env "PROJECT_ROOT" %>/../common/charts/backend
builds:
default:
tag: <% .Global.docker.tag | quote %>
image: <% .Global.docker.registry %>/checkout-backend
context: <% env "PROJECT_ROOT" %>/squadrons/checkout/backend
dockerfile: <% env "PROJECT_ROOT" %>/../common/docker/backend.Dockerfile
values:
image:
tag: <% .Global.docker.tag | quote %>
repository: <% .Squadron.checkout.backend.builds.default.image %>

View File

@ -0,0 +1,17 @@
# Schema version
version: "2.0"
squadron:
checkout:
frontend:
chart: <% env "PROJECT_ROOT" %>/../common/charts/frontend
builds:
default:
tag: "<% .Global.docker.tag %>"
image: <% .Global.docker.registry %>/checkout-frontend
context: <% env "PROJECT_ROOT" %>/squadrons/checkout/frontend
dockerfile: <% env "PROJECT_ROOT" %>/../common/docker/frontend.Dockerfile
values:
image:
tag: "<% .Global.docker.tag %>"
repository: <% .Squadron.checkout.frontend.builds.default.image %>

View File

@ -0,0 +1,6 @@
version: "2.0"
global:
docker:
tag: "230101.0"
registry: monorepo

View File

@ -0,0 +1,3 @@
module github.com/foomo/squadron/exmpale/monorepo/storefinder/backend
go 1.16

View File

@ -0,0 +1,13 @@
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintf(w, "hello")
})
_ = http.ListenAndServe(":80", nil)
}

View File

@ -0,0 +1,17 @@
# Schema version
version: "2.0"
squadron:
storefinder:
backend:
chart: <% env "PROJECT_ROOT" %>/../common/charts/backend
builds:
default:
tag: <% .Global.docker.tag | quote %>
image: <% .Global.docker.registry %>/storefinder-backend
context: <% env "PROJECT_ROOT" %>/squadrons/storefinder/backend
dockerfile: <% env "PROJECT_ROOT" %>/../common/docker/backend.Dockerfile
values:
image:
tag: <% .Global.docker.tag | quote %>
repository: <% .Squadron.storefinder.backend.builds.default.image %>

View File

@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Storefinder</h1>
</body>
</html>

View File

@ -0,0 +1,17 @@
# Schema version
version: "2.0"
squadron:
storefinder:
frontend:
chart: <% env "PROJECT_ROOT" %>/../common/charts/frontend
builds:
default:
tag: "<% .Global.docker.tag %>"
image: <% .Global.docker.registry %>/storefinder-frontend
context: <% env "PROJECT_ROOT" %>/squadrons/storefinder/frontend
dockerfile: <% env "PROJECT_ROOT" %>/../common/docker/frontend.Dockerfile
values:
image:
tag: "<% .Global.docker.tag %>"
repository: <% .Squadron.storefinder.frontend.builds.default.image %>

View File

@ -1,11 +0,0 @@
FROM golang:alpine AS builder
COPY main.go .
RUN go build -o /helloworld .
FROM alpine:latest
COPY --from=builder /helloworld /helloworld
ENTRYPOINT ["/helloworld"]

View File

@ -1,15 +0,0 @@
version: "1.0"
squadron:
app:
chart: ./chart
builds:
default:
tag: latest
context: ./app
image: helloworld/app
values:
image: "{{ .Squadron.app.builds.default.image }}:{{ .Squadron.app.builds.default.tag }}"
service:
ports:
- 80

View File

@ -1,71 +0,0 @@
.DEFAULT_GOAL:=help
export PROJECT_ROOT=$(PWD)
storefinder.%:files=./squadrons/squadron.yaml,./squadrons/storefinder/squadron.yaml,./squadrons/storefinder/frontend/squadron.yaml,./squadrons/storefinder/backend/squadron.yaml
.PHONY: storefinder.frontend.config
## Show config
storefinder.frontend.config:
@squadron -f ${files} config
.PHONY: storefinder.frontend.template
## Show config
storefinder.frontend.template:
@squadron -f ${files} template
.PHONY: storefinder.frontend.generate
## Generate helm chart
storefinder.frontend.generate:
@squadron -f ${files} generate
storefinder.%:files=./squadrons/squadron.yaml,./squadrons/storefinder/squadron.yaml,./squadrons/storefinder/frontend/squadron.yaml,./squadrons/storefinder/backend/squadron.yaml
.PHONY: storefinder.backend.config
## Show config
storefinder.backend.config:
@squadron -f ${files} config
.PHONY: storefinder.backend.template
## Show template
storefinder.backend.template:
@squadron -f ${files} template
.PHONY: storefinder.backend.generate
## Generate helm chart
storefinder.backend.generate:
@squadron -f ${files} generate
## === Utils ===
## Show help text
help:
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage"\n"; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)

View File

@ -1,3 +0,0 @@
image: {}
# tag: null
# repository: null

View File

@ -1,3 +0,0 @@
image: {}
# tag: null
# repository: null

View File

@ -1,20 +0,0 @@
# Schema version
version: "1.0"
name: monorepo
global:
docker:
tag: "211206.0"
registry: monorepo
squadron:
# mongodb:
# chart:
# name: mongodb
# repository: https://charts.bitnami.com/bitnami
# version: 10.11.2
# values:
# fullnameOverride: catalogue-mongodb
# auth:
# enabled: false

View File

@ -1,16 +0,0 @@
# Schema version
version: "1.0"
squadron:
backend:
chart: <% env "PROJECT_ROOT" %>/charts/backend
builds:
default:
tag: <% .Global.docker.tag | quote %>
image: <% .Global.docker.registry %>/storefinder-backend
context: <% env "PROJECT_ROOT" %>/squadrons/storefinder/backend
dockefile: <% env "PROJECT_ROOT" %>/docker/backend.Dockerfile
values:
image:
tag: <% .Global.docker.tag | quote %>
repository: <% .Squadron.backend.builds.default.image %>

View File

@ -1,16 +0,0 @@
# Schema version
version: "1.0"
squadron:
# backend:
# chart: <% env "PROJECT_ROOT" %>/charts/frontend
# builds:
# default:
# tag: "<% .Global.docker.tag %>"
# image: <% .Global.docker.registry %>/storefinder-frontend
# context: <% env "PROJECT_ROOT" %>/squadrons/storefinder/frontend
# dockefile: <% env "PROJECT_ROOT" %>/docker/frontend.Dockerfile
# values:
# image:
# tag: "<% .Global.docker.tag %>"
# repository: <% .Squadron.frontend.builds.default.image %>

View File

@ -1,4 +0,0 @@
# Schema version
version: "1.0"
name: storefinder