Skip to content

Commit

Permalink
chore: housekeeping
Browse files Browse the repository at this point in the history
Signed-off-by: Devin Buhl <[email protected]>
  • Loading branch information
onedr0p committed Feb 2, 2024
1 parent 7099964 commit ca93ad4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
12 changes: 11 additions & 1 deletion bootstrap/scripts/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@

from typing import Any
from netaddr import IPNetwork
from bcrypt import hashpw, gensalt

import makejinja
import validation

def encrypt(value: str) -> str:
return hashpw(value.encode(), gensalt(rounds=10)).decode("ascii")


def nthhost(value: str, query: int) -> str:
value = IPNetwork(value)
try:
Expand All @@ -20,6 +25,7 @@ def nthhost(value: str, query: int) -> str:
return False
return value


def import_filter(file: Path) -> Callable[[dict[str, Any]], bool]:
module_path = file.relative_to(Path.cwd()).with_suffix("")
module_name = str(module_path).replace("/", ".")
Expand All @@ -31,6 +37,7 @@ def import_filter(file: Path) -> Callable[[dict[str, Any]], bool]:
spec.loader.exec_module(module)
return module.main


class Plugin(makejinja.plugin.Plugin):
def __init__(self, data: dict[str, Any], config: makejinja.config.Config):
self._data = data
Expand All @@ -45,12 +52,15 @@ def __init__(self, data: dict[str, Any], config: makejinja.config.Config):

validation.validate(data)


def filters(self) -> makejinja.plugin.Filters:
return [nthhost]
return [encrypt, nthhost]


def path_filters(self):
return [self._mjfilter_func]


def _mjfilter_func(self, path: Path) -> bool:
return not any(
path.is_relative_to(excluded_dir) for excluded_dir in self._excluded_dirs
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./namespace.yaml
{% if flux.github.webhook.enabled %}
- ./webhooks/ks.yaml
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
main = lambda data: (
data.get("flux", {})
.get("github", {})
.get("webhook", {})
.get("enabled", False) == True
)
18 changes: 9 additions & 9 deletions config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,26 @@ flux:
# > task sops:age-keygen
# 2. Copy the public key and paste it below
sops_age_public_key: ""
# (Required) Options for Github
# (Required) Options for GitHub
github:
# (Required) Github repository URL (for private repos use the ssh:// URL)
# (Required) GitHub repository URL (for private repos use the ssh:// URL)
address: ""
# (Required) Github repository branch
# (Required) GitHub repository branch
branch: main
# (Required) Options for Flux Github webhook
# (Required) Options for Flux GitHub webhook
webhook:
# (Required) Enable to use Github push-based sync
# (Required) Enable to setup GitHub push-based sync after cluster creation
enabled: true
# Token for Github push-based sync
# Token for GitHub push-based sync
# 1. Generate a new token with the following command:
# > openssl rand -hex 16
# 2. Copy the token and paste it below
token: ""
# (Required) Private key for Flux to access the Github repository
# (Required) Private key for Flux to access the GitHub repository
private:
# (Required) Enable to use a private Github repository
# (Required) Enable to use a private GitHub repository
enabled: false
# Private key for Flux to access the Github repository
# Private key for Flux to access the GitHub repository
# 1. Generate a new key with the following command:
# > ssh-keygen -t ecdsa -b 521 -C "github-deploy-key" -f github-deploy.key -q -P ""
# 2. Make sure to paste public key from "github-deploy.key.pub" into
Expand Down

0 comments on commit ca93ad4

Please sign in to comment.