* feat: Do not rely on k0s file uploads - instead use curl Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: add bootstrap_advanced_flags to validation Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: only skip tests for non-static config Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: only skip tests for non-static config Signed-off-by: Devin Buhl <devin@buhl.casa> * fix: issues in k0s scripts Signed-off-by: Devin Buhl <devin@buhl.casa> * update: readme Signed-off-by: Devin Buhl <devin@buhl.casa> * update: taskfile Signed-off-by: Devin Buhl <devin@buhl.casa> * update: taskfile Signed-off-by: Devin Buhl <devin@buhl.casa> * update: k0s config and remove ansible hook Signed-off-by: Devin Buhl <devin@buhl.casa> --------- Signed-off-by: Devin Buhl <devin@buhl.casa>
27 lines
652 B
Python
27 lines
652 B
Python
from typing import Any
|
|
import bcrypt
|
|
import makejinja
|
|
import netaddr
|
|
|
|
import validation
|
|
|
|
def nthhost(value: str, query: int) -> str:
|
|
value = netaddr.IPNetwork(value)
|
|
try:
|
|
nth = int(query)
|
|
if value.size > nth:
|
|
return str(value[nth])
|
|
except ValueError:
|
|
return False
|
|
return value
|
|
|
|
def encrypt(value: str) -> str:
|
|
return bcrypt.hashpw(value.encode(), bcrypt.gensalt(rounds=10)).decode("ascii")
|
|
|
|
class Plugin(makejinja.plugin.Plugin):
|
|
def __init__(self, data: dict[str, Any]):
|
|
validation.validate(data)
|
|
|
|
def filters(self) -> makejinja.plugin.Filters:
|
|
return [nthhost, encrypt]
|