Skip to content

Commit

Permalink
UI refresh, helm chart, tiltfile (#5)
Browse files Browse the repository at this point in the history
* UI refresh, helm chart, tiltfile

* chore: add helm to tool versions

* fix: code block style

* use latest helm version

* some ui fixes

---------

Co-authored-by: Alessio Pragliola <alessio.pragliola@sighup.io>
  • Loading branch information
alessiodionisi and Alessio Pragliola authored Mar 14, 2024
1 parent 0c04880 commit 6492fe1
Show file tree
Hide file tree
Showing 27 changed files with 1,264 additions and 212 deletions.
3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
golang 1.22.1
make 4.4.1
goreleaser 1.24.0
tilt 0.33.11
ctlptl 0.8.28
helm 3.14.3
9 changes: 6 additions & 3 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ ENV CGO_ENABLED=0

WORKDIR /src

COPY . .
COPY ./cmd /src/cmd
COPY ./internal /src/internal
COPY ./static /src/static
COPY ./templates /src/templates
COPY ./go.mod /src/go.mod
COPY ./go.sum /src/go.sum

RUN go mod download

ENTRYPOINT [ "go", "run", "./cmd/gangplank" ]
16 changes: 2 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ check-variable-%:
.PHONY: license-check
license-check:
@addlicense -c "SIGHUP s.r.l" -y 2017-present -v -l apache \
-ignore "deployments/helm/permission-monitor/templates/**/*" \
-ignore "deployments/helm/templates/**/*" \
-ignore "dist/**/*" \
-ignore "web-client/src/gen/**/*" \
-ignore "web-client/node_modules/**/*" \
-ignore "vendor/**/*" \
-ignore "*.gen.go" \
-ignore ".idea/*" \
-ignore ".vscode/*" \
-ignore ".go/**/*" \
--check .

Expand All @@ -80,14 +74,8 @@ license-check:
.PHONY: license-add
license-add:
@addlicense -c "SIGHUP s.r.l" -y 2017-present -v -l apache \
-ignore "deployments/helm/permission-monitor/templates/**/*" \
-ignore "deployments/helm/templates/**/*" \
-ignore "dist/**/*" \
-ignore "web-client/src/gen/**/*" \
-ignore "web-client/node_modules/**/*" \
-ignore "vendor/**/*" \
-ignore "*.gen.go" \
-ignore ".idea/*" \
-ignore ".vscode/*" \
-ignore ".go/**/*" \
.

Expand Down
78 changes: 78 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
load("ext://helm_resource", "helm_repo", "helm_resource")
load("ext://restart_process", "docker_build_with_restart")
load("ext://namespace", "namespace_create")

# Set default trigger mode to manual
trigger_mode(TRIGGER_MODE_MANUAL)

# Disable analytics
analytics_settings(False)

# Disable secrets scrubbing
secret_settings(disable_scrub=True)

# Allow only gangplank k8s context
allow_k8s_contexts("kind-gangplank")

# Create the namespaces
namespace_create("gangplank")
namespace_create("dex")

k8s_resource(
new_name="namespaces",
objects=["gangplank:namespace","dex:namespace"],
)

helm_repo(
name="dex",
url="https://charts.dexidp.io",
resource_name="dex-repo",
)

helm_resource(
name="dex",
chart="dex/dex",
release_name="dex",
namespace="dex",
flags=["--values", "./configs/helm-values/dex.yaml", "--version=0.16.0"],
deps=["namespaces", "dex-repo"],
)

k8s_resource(
workload="dex",
port_forwards=["5556:5556"],
)

helm_resource(
name="gangplank",
chart="./deployments/helm",
release_name="gangplank",
image_deps=["gangplank"],
image_keys=[
("image.repository", "image.tag"),
],
namespace="gangplank",
deps=["namespaces"],
flags=['--values', "./configs/helm-values/gangplank.yaml"],
)

docker_build_with_restart(
ref="gangplank",
context=".",
dockerfile="Dockerfile-dev",
live_update=[
sync("./cmd", "/src/cmd"),
sync("./internal", "/src/internal"),
sync("./static", "/src/static"),
sync("./templates", "/src/templates"),
sync("./go.mod", "/src/go.mod"),
sync("./go.sum", "/src/go.sum"),
],
entrypoint=["go", "run", "./cmd/gangplank"],
)

k8s_resource(
workload="gangplank",
port_forwards=["8080:8080"],
trigger_mode=TRIGGER_MODE_AUTO
)
2 changes: 2 additions & 0 deletions cmd/gangplank/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/sighupio/gangplank/internal/config"
"github.com/sighupio/gangplank/internal/oidc"
"github.com/sighupio/gangplank/internal/session"
"github.com/sighupio/gangplank/static"
"golang.org/x/oauth2"
)

Expand Down Expand Up @@ -90,6 +91,7 @@ func main() {
loginRequiredHandlers := alice.New(loginRequired)

http.HandleFunc(cfg.GetRootPathPrefix(), httpLogger(homeHandler))
http.HandleFunc(fmt.Sprintf("%s/static/", cfg.HTTPPath), httpLogger(http.StripPrefix(fmt.Sprintf("%s/static/", cfg.HTTPPath), http.FileServerFS(static.FS)).ServeHTTP))
http.HandleFunc(fmt.Sprintf("%s/login", cfg.HTTPPath), httpLogger(loginHandler))
http.HandleFunc(fmt.Sprintf("%s/callback", cfg.HTTPPath), httpLogger(callbackHandler))

Expand Down
23 changes: 23 additions & 0 deletions configs/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2017-present SIGHUP s.r.l
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: ctlptl.dev/v1alpha1
kind: Cluster
product: kind
registry: gangplank-registry
kindV1Alpha4Cluster:
name: gangplank
nodes:
- role: control-plane
image: kindest/node:v1.29.2
33 changes: 33 additions & 0 deletions configs/helm-values/dex.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2017-present SIGHUP s.r.l
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

config:
issuer: http://localhost:5556
storage:
type: memory
enablePasswordDB: true

staticClients:
- id: gangplank
secret: gangplank
name: Gangplank
redirectURIs:
- http://localhost:8080/callback

staticPasswords:
- email: admin@gangplank.test
# bcrypt hash of the string "password": $(echo password | htpasswd -BinC 10 admin | cut -d: -f2)
hash: "$2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W"
username: admin
userID: 08a8684b-db88-4b73-90a9-3cd1661f5466
25 changes: 25 additions & 0 deletions configs/helm-values/gangplank.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017-present SIGHUP s.r.l
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

command:
["go", "run", "./cmd/gangplank", "-config", "/etc/gangplank/config.yaml"]

config:
authorizeURL: http://localhost:5556/auth
tokenURL: http://dex.dex:5556/token
audience: http://dex.dex:5556/userinfo
redirectURL: http://localhost:8080/callback
usernameClaim: email
clientID: gangplank
clientSecret: gangplank
23 changes: 23 additions & 0 deletions deployments/helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
20 changes: 20 additions & 0 deletions deployments/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2017-present SIGHUP s.r.l
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v2
name: gangplank
description: A Helm chart for Gangplank
type: application
version: 0.1.0
appVersion: "0.1.0"
51 changes: 51 additions & 0 deletions deployments/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "gangplank.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "gangplank.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "gangplank.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "gangplank.labels" -}}
helm.sh/chart: {{ include "gangplank.chart" . }}
{{ include "gangplank.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "gangplank.selectorLabels" -}}
app.kubernetes.io/name: {{ include "gangplank.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
9 changes: 9 additions & 0 deletions deployments/helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "gangplank.fullname" . }}
labels:
{{- include "gangplank.labels" . | nindent 4 }}
data:
config.yaml: |
{{- toYaml .Values.config | nindent 4 }}
Loading

0 comments on commit 6492fe1

Please sign in to comment.