Add info messgaes

This commit is contained in:
Chris Stuurman 2024-03-28 18:57:45 +02:00
parent 4c764c4da7
commit 0127488459
4 changed files with 15 additions and 9 deletions

View File

@ -5,9 +5,9 @@ metadata:
namespace: {{ .Release.Namespace | quote }} namespace: {{ .Release.Namespace | quote }}
labels: labels:
app: {{ include "sthome-webhook.name" . }} app: {{ include "sthome-webhook.name" . }}
# app.kubernetes.io/component: webhook app.kubernetes.io/component: webhook
# app.kubernetes.io/name: webhook app.kubernetes.io/name: webhook
# app.kubernetes.io/version: {{ .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion }}
chart: {{ include "sthome-webhook.chart" . }} chart: {{ include "sthome-webhook.chart" . }}
release: {{ .Release.Name }} release: {{ .Release.Name }}
heritage: {{ .Release.Service }} heritage: {{ .Release.Service }}

View File

@ -32,7 +32,7 @@ image:
repository: stuurmcp/cert-manager-webhook-sthome repository: stuurmcp/cert-manager-webhook-sthome
tag: 0.0.3 tag: 0.0.3
#pullPolicy should be IfNotPresent. Set to Always for testing purposes #pullPolicy should be IfNotPresent. Set to Always for testing purposes
pullPolicy: IfNotPresent pullPolicy: Always
imageCredentials: imageCredentials:
name: docker-registry-credentials name: docker-registry-credentials

View File

@ -1,14 +1,20 @@
package sthome package sthome
import ( import (
"log"
"os" "os"
"os/exec" "os/exec"
"os/user"
"k8s.io/klog/v2" "k8s.io/klog/v2"
) )
func Execute(script string, command []string) (bool, error) { 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{ cmd := &exec.Cmd{
Path: script, Path: script,
Args: command, Args: command,
@ -16,7 +22,7 @@ func Execute(script string, command []string) (bool, error) {
Stderr: os.Stderr, Stderr: os.Stderr,
} }
err := cmd.Start() err = cmd.Start()
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -74,7 +74,7 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error
// TODO: do something more useful with the decoded configuration // TODO: do something more useful with the decoded configuration
fmt.Printf("CZ: Decoded configuration %v", cfg) fmt.Printf("CZ: Decoded configuration %v", cfg)
klog.InfoS("CZ: presenting record for ", ch.DNSName, ch.ResolvedFQDN, "domain", domainName) 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 // shell command
command := []string{ command := []string{
@ -85,8 +85,8 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error
"arg4=TXT", "arg4=TXT",
fmt.Sprintf("arg5=%s", ch.Key), fmt.Sprintf("arg5=%s", ch.Key),
} }
Execute(dnsUpdaterScript, command) success, _ := Execute(dnsUpdaterScript, command)
klog.InfoS("CZ: Execute returned", "success", success)
return nil return nil
} }