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 }}
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 }}

View File

@ -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

View File

@ -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
}

View File

@ -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
}