From 012748845940a7fc72fa3ecd1f7ef537da3b9353 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 28 Mar 2024 18:57:45 +0200 Subject: [PATCH] Add info messgaes --- deploy/sthome-webhook/templates/deployment.yaml | 6 +++--- deploy/sthome-webhook/values.yaml | 2 +- sthome/shell.go | 10 ++++++++-- sthome/solver_local.go | 6 +++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/deploy/sthome-webhook/templates/deployment.yaml b/deploy/sthome-webhook/templates/deployment.yaml index 66668fd..8322f66 100644 --- a/deploy/sthome-webhook/templates/deployment.yaml +++ b/deploy/sthome-webhook/templates/deployment.yaml @@ -5,9 +5,9 @@ metadata: namespace: {{ .Release.Namespace | quote }} labels: app: {{ include "sthome-webhook.name" . }} - # app.kubernetes.io/component: webhook - # app.kubernetes.io/name: webhook - # app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: webhook + app.kubernetes.io/name: webhook + app.kubernetes.io/version: {{ .Chart.AppVersion }} chart: {{ include "sthome-webhook.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} diff --git a/deploy/sthome-webhook/values.yaml b/deploy/sthome-webhook/values.yaml index 3cabc21..0ec7e7f 100644 --- a/deploy/sthome-webhook/values.yaml +++ b/deploy/sthome-webhook/values.yaml @@ -32,7 +32,7 @@ image: repository: stuurmcp/cert-manager-webhook-sthome tag: 0.0.3 #pullPolicy should be IfNotPresent. Set to Always for testing purposes - pullPolicy: IfNotPresent + pullPolicy: Always imageCredentials: name: docker-registry-credentials diff --git a/sthome/shell.go b/sthome/shell.go index 73dc4fd..3f31599 100644 --- a/sthome/shell.go +++ b/sthome/shell.go @@ -1,14 +1,20 @@ package sthome import ( + "log" "os" "os/exec" + "os/user" "k8s.io/klog/v2" ) func Execute(script string, command []string) (bool, error) { - klog.InfoS("CZ: Executing ", "Path", script, "Args", command) + currentUser, err := user.Current() + if err != nil { + log.Fatalf("CZ: Unable to get current user: %s", err) + } + klog.InfoS("CZ: Executing ", "user", currentUser.Name, "script", command) cmd := &exec.Cmd{ Path: script, Args: command, @@ -16,7 +22,7 @@ func Execute(script string, command []string) (bool, error) { Stderr: os.Stderr, } - err := cmd.Start() + err = cmd.Start() if err != nil { return false, err } diff --git a/sthome/solver_local.go b/sthome/solver_local.go index 79d66c4..c509dee 100644 --- a/sthome/solver_local.go +++ b/sthome/solver_local.go @@ -74,7 +74,7 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error // TODO: do something more useful with the decoded configuration fmt.Printf("CZ: Decoded configuration %v", cfg) klog.InfoS("CZ: presenting record for ", ch.DNSName, ch.ResolvedFQDN, "domain", domainName) - // TODO: add code that sets a record in the DNS provider's console + // TODO: convert shell script to golang // shell command command := []string{ @@ -85,8 +85,8 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error "arg4=TXT", fmt.Sprintf("arg5=%s", ch.Key), } - Execute(dnsUpdaterScript, command) - + success, _ := Execute(dnsUpdaterScript, command) + klog.InfoS("CZ: Execute returned", "success", success) return nil }