Skip to content

Commit

Permalink
Merge branch 'dev' into yash/devspace-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgorana authored Oct 16, 2023
2 parents c8604f2 + 13384e8 commit 5a37357
Show file tree
Hide file tree
Showing 21 changed files with 199 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.2-beta.36
current_version = 0.8.2-beta.37
tag = False
tag_name = {new_version}
commit = True
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mono Repo Global Version
__version__ = "0.8.2-beta.36"
__version__ = "0.8.2-beta.37"
# elsewhere we can call this file: `python VERSION` and simply take the stdout

# stdlib
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mono Repo Global Version
__version__ = "0.8.2-beta.36"
__version__ = "0.8.2-beta.37"
# elsewhere we can call this file: `python VERSION` and simply take the stdout

# stdlib
Expand Down
4 changes: 2 additions & 2 deletions packages/grid/devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ pipelines:
run: |-
run_dependencies --all
ensure_pull_secrets --all
build_images --all -t $(git rev-parse --short=6 HEAD) -t 0.8.2-beta.36 -t dev-latest
build_images --all -t $(git rev-parse --short=6 HEAD) -t 0.8.2-beta.37 -t dev-latest
create_deployments --all
vars:
DEVSPACE_ENV_FILE: "default.env"
CONTAINER_REGISTRY: "docker.io"
VERSION: "0.8.2-beta.36"
VERSION: "0.8.2-beta.37"

# This is a list of `images` that DevSpace can build for this project
# We recommend to skip image building during development (devspace dev) as much as possible
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pygrid-ui",
"version": "0.8.2-beta.36",
"version": "0.8.2-beta.37",
"private": true,
"scripts": {
"dev": "pnpm i && vite dev --host --port 80",
Expand Down
37 changes: 33 additions & 4 deletions packages/grid/helm/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def replace_variables(d: Any) -> None:
if "kubernetes.io/ingress.class" in d:
d["kubernetes.io/ingress.class"] = "{{ .Values.ingress.ingressClass }}"

if "kind" in d and d["kind"] == "Ingress" and "spec" in d:
d["spec"]["tls"] = [{"hosts": ["{{ .Values.node.settings.hostname }}"]}]
# ONLY FOR TLS
if d.get("kind") == "Ingress" and "tls" in d.get("spec", {}):
d["spec"]["tls"][0]["hosts"][0] = "{{ .Values.node.settings.hostname }}"
d["spec"]["rules"][0]["host"] = "{{ .Values.node.settings.hostname }}"


Expand All @@ -91,14 +92,34 @@ def get_yaml_name(doc: dict) -> Any:
return ""


def apply_patches(yaml: str, resource_name: str) -> str:
def ingress_with_tls() -> str:
script_path = os.path.dirname(os.path.realpath(__file__))
manifest_path = os.path.normpath(
os.path.join(script_path, "..", "k8s", "manifests")
)
ingress_tls = os.path.join(manifest_path, "ingress-tls.yaml")

with open(ingress_tls) as fp:
return fp.read()


def apply_patches(yaml: str, resource_name: str, resource_kind: str) -> str:
# print(resource_kind, resource_name)
# apply resource specific patches
if resource_name.startswith("seaweedfs"):
yaml = (
'{{- if ne .Values.node.settings.nodeType "gateway"}}\n'
+ yaml.rstrip()
+ "\n{{ end }}\n"
)
elif resource_kind == "ingress" and resource_name.endswith("tls"):
yaml = "{{- if .Values.node.settings.tls }}\n" + yaml.rstrip() + "\n{{ end }}\n"
elif resource_kind == "ingress" and not resource_name.endswith("tls"):
yaml = (
"{{- if not .Values.node.settings.tls }}\n"
+ yaml.rstrip()
+ "\n{{ end }}\n"
)

# global patches
yaml = (
Expand Down Expand Up @@ -140,6 +161,14 @@ def main() -> None:

# Load the multi-doc yaml file
try:
# append custom docs
input_data = "\n---\n".join(
[
input_data,
ingress_with_tls(),
]
)

yaml_docs = list(yaml.safe_load_all(input_data))
except Exception as e:
print(f"❌ Error while parsing yaml file: {e}")
Expand Down Expand Up @@ -169,7 +198,7 @@ def main() -> None:
# Create new file with name or append if it already exists
new_file = os.path.join(helm_chart_template_dir, f"{name}-{kind}.yaml")
yaml_dump = yaml.dump(doc)
yaml_dump = apply_patches(yaml_dump, name)
yaml_dump = apply_patches(yaml_dump, name, kind)

with open(new_file, "w") as f:
f.write(yaml_dump) # add document separator
Expand Down
27 changes: 27 additions & 0 deletions packages/grid/helm/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,33 @@ spec:
path: /
pathType: Prefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: ''
name: grid-stack-ingress-tls
spec:
defaultBackend:
service:
name: proxy
port:
number: 80
rules:
- host: ''
http:
paths:
- backend:
service:
name: proxy
port:
number: 80
path: /
pathType: Prefix
tls:
- hosts:
- ''
---
apiVersion: v1
kind: Service
metadata:
Expand Down
Loading

0 comments on commit 5a37357

Please sign in to comment.