Improved makefile. Running from git bash
This commit is contained in:
parent
71d8934d46
commit
d1e49c7bba
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -1,3 +1,6 @@
|
|||||||
{
|
{
|
||||||
"terminal.explorerKind": "integrated"
|
"terminal.explorerKind": "integrated",
|
||||||
|
"makefile.makePath": "C:\\MinGW\\msys\\1.0\\bin\\make.exe",
|
||||||
|
"makefile.makefilePath": "./Makefile",
|
||||||
|
"makefile.buildLog": "./makefile.log"
|
||||||
}
|
}
|
||||||
@ -29,13 +29,12 @@ RUN apk add --no-cache ca-certificates
|
|||||||
RUN apk add --no-cache zsh bash bind-tools coreutils krb5 tcpdump
|
RUN apk add --no-cache zsh bash bind-tools coreutils krb5 tcpdump
|
||||||
COPY ./config/zsh.sh /root/.zshrc
|
COPY ./config/zsh.sh /root/.zshrc
|
||||||
COPY ./config/bash.sh /root/.bashrc
|
COPY ./config/bash.sh /root/.bashrc
|
||||||
#COPY ./config/krb5.conf /etc
|
|
||||||
RUN chown -R root:root /root/.zshrc && \
|
RUN chown -R root:root /root/.zshrc && \
|
||||||
chown -R root:root /root/.bashrc && \
|
chown -R root:root /root/.bashrc && \
|
||||||
/bin/zsh /root/.zshrc
|
/bin/zsh /root/.zshrc
|
||||||
RUN apk add --no-cache alpine-conf && \
|
RUN apk add --no-cache alpine-conf && \
|
||||||
setup-timezone -z Africa/Johannesburg
|
setup-timezone -z Africa/Johannesburg
|
||||||
# chmod 0644 /etc/krb5.conf
|
|
||||||
|
|
||||||
ENV RUNNING_IN_DOCKER true
|
ENV RUNNING_IN_DOCKER true
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|||||||
31
Makefile
31
Makefile
@ -1,10 +1,16 @@
|
|||||||
GO ?= $(shell which go)
|
GO ?= "$(shell which go)"
|
||||||
OS ?= $(shell $(GO) env GOOS)
|
OS ?= $(shell $(GO) env GOOS)
|
||||||
ARCH ?= $(shell $(GO) env GOARCH)
|
ARCH ?= $(shell $(GO) env GOARCH)
|
||||||
|
|
||||||
IMAGE_NAME := cert-manager-webhook-sthome
|
IMAGE_NAME := cert-manager-webhook-sthome
|
||||||
|
IMAGE_SHORTNAME := sthome-webhook
|
||||||
|
IMAGE_NAMESPACE := ix-$(IMAGE_SHORTNAME)2
|
||||||
|
DEPLOY_DIR := deploy/$(IMAGE_SHORTNAME)
|
||||||
IMAGE_TAG = "0.0.3"
|
IMAGE_TAG = "0.0.3"
|
||||||
|
|
||||||
|
SHARED_DIR := //truenas/Shared_data/Chris/clusterissuer/charts
|
||||||
|
CHART_FILE := $(SHARED_DIR)/$(IMAGE_NAME)-
|
||||||
|
|
||||||
TMP = \Temp\gotemp
|
TMP = \Temp\gotemp
|
||||||
export TMP
|
export TMP
|
||||||
|
|
||||||
@ -12,7 +18,7 @@ OUT := $(shell pwd)/_out
|
|||||||
|
|
||||||
KUBEBUILDER_VERSION=1.28.0
|
KUBEBUILDER_VERSION=1.28.0
|
||||||
|
|
||||||
HELM_FILES := $(shell find "deploy/sthome-webhook")
|
HELM_FILES := $(shell find "$(DEPLOY_DIR)")
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
go mod tidy
|
go mod tidy
|
||||||
@ -23,11 +29,6 @@ bin/buildversion.exe: cmd/buildversion.go
|
|||||||
go build -o bin/buildversion.exe cmd/buildversion.go
|
go build -o bin/buildversion.exe cmd/buildversion.go
|
||||||
set TMP="C:\Users\Chris\AppData\Local\Temp"
|
set TMP="C:\Users\Chris\AppData\Local\Temp"
|
||||||
|
|
||||||
#bin/cert-manager-webhook-sthome.exe: dependencies version.txt
|
|
||||||
# set TMP="C:\Temp\gotemp"
|
|
||||||
# go build -o bin/cert-manager-webhook-sthome.exe
|
|
||||||
# set TMP="C:\Users\Chris\AppData\Local\Temp"
|
|
||||||
|
|
||||||
version.txt: bin/buildversion.exe dependencies
|
version.txt: bin/buildversion.exe dependencies
|
||||||
bin/buildversion.exe
|
bin/buildversion.exe
|
||||||
|
|
||||||
@ -48,21 +49,23 @@ clean:
|
|||||||
rm -r _test $(OUT)
|
rm -r _test $(OUT)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: rendered-manifest.yaml dependencies bin/buildversion.exe version.txt
|
build: dependencies bin/buildversion.exe version.txt
|
||||||
docker build --pull --rm -f "Dockerfile" -t "stuurmcp/$(IMAGE_NAME):latest" -t "stuurmcp/$(IMAGE_NAME):$(shell head -n 1 version.txt)" "."
|
docker build --pull --rm -f "Dockerfile" -t "stuurmcp/$(IMAGE_NAME):latest" -t "stuurmcp/$(IMAGE_NAME):$(shell head -n 1 version.txt)" "."
|
||||||
docker image push "docker.io/stuurmcp/$(IMAGE_NAME):$(shell head -n 1 version.txt)"
|
docker image push "docker.io/stuurmcp/$(IMAGE_NAME):$(shell head -n 1 version.txt)"
|
||||||
|
helm package -n $(IMAGE_NAMESPACE) --version $(shell head -n 1 version.txt) $(DEPLOY_DIR) -d $(SHARED_DIR)/
|
||||||
docker image push "docker.io/stuurmcp/$(IMAGE_NAME):latest"
|
docker image push "docker.io/stuurmcp/$(IMAGE_NAME):latest"
|
||||||
helm package -n ix-sthome-webhook2 --version $(shell head -n 1 version.txt) deploy/sthome-webhook -d //truenas/Shared_data/Chris/clusterissuer/charts/
|
|
||||||
|
.PHONY: chart
|
||||||
|
chart: $(CHART_FILE).tgz
|
||||||
|
|
||||||
|
$(CHART_FILE).tgz: $(HELM_FILES)
|
||||||
|
helm package -n $(IMAGE_NAMESPACE) --version $(shell head -n 1 version.txt) $(DEPLOY_DIR) -d $(SHARED_DIR)/
|
||||||
|
|
||||||
.PHONY: rendered-manifest.yaml
|
.PHONY: rendered-manifest.yaml
|
||||||
rendered-manifest.yaml: $(OUT)/rendered-manifest.yaml
|
rendered-manifest.yaml: $(OUT)/rendered-manifest.yaml
|
||||||
|
|
||||||
$(OUT)/rendered-manifest.yaml: $(HELM_FILES) | $(OUT)
|
$(OUT)/rendered-manifest.yaml: $(HELM_FILES) | $(OUT)
|
||||||
helm template \
|
helm template $(IMAGE_SHORTNAME) -n $(IMAGE_NAMESPACE) --set image.repository=$(IMAGE_NAME) --set image.tag=$(shell head -n 1 version.txt) $(DEPLOY_DIR) > $@
|
||||||
sthome-webhook -n ix-sthome-webhook2\
|
|
||||||
--set image.repository=$(IMAGE_NAME) \
|
|
||||||
--set image.tag=$(shell head -n 1 version.txt) \
|
|
||||||
deploy/sthome-webhook > $@
|
|
||||||
|
|
||||||
_test $(OUT) _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH):
|
_test $(OUT) _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
appVersion: v0.0.5-alpha.77
|
appVersion: v0.0.5-alpha.90
|
||||||
description: Cert-Manager webhook for sthome
|
description: Cert-Manager webhook for sthome
|
||||||
name: sthome-webhook
|
name: sthome-webhook
|
||||||
version: 0.0.5-alpha.77
|
version: 0.0.5-alpha.90
|
||||||
|
|||||||
@ -31,7 +31,7 @@ clusterIssuer:
|
|||||||
image:
|
image:
|
||||||
repository: stuurmcp/cert-manager-webhook-sthome
|
repository: stuurmcp/cert-manager-webhook-sthome
|
||||||
#repository: wstat.sthome.net:5000/cert-manager-webhook-sthome
|
#repository: wstat.sthome.net:5000/cert-manager-webhook-sthome
|
||||||
tag: 0.0.5-alpha.77
|
tag: 0.0.5-alpha.90
|
||||||
#pullPolicy should be IfNotPresent. Set to Always for testing purposes
|
#pullPolicy should be IfNotPresent. Set to Always for testing purposes
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package dns
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -33,3 +35,22 @@ func Execute(shell string, arg ...string) (bool, error) {
|
|||||||
klog.Infof("Script returned success\n")
|
klog.Infof("Script returned success\n")
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html
|
||||||
|
func Execute2(shell string, arg ...string) (bool, error) {
|
||||||
|
var stdoutBuf, stderrBuf bytes.Buffer
|
||||||
|
cmd := exec.Command(shell, arg...)
|
||||||
|
cmd.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
|
||||||
|
cmd.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
|
||||||
|
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
klog.Errorf("Script returned error:\nerr:\n")
|
||||||
|
klog.Errorf("%s\n============\n", err)
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
outStr, errStr := string(stdoutBuf.String()), string(stderrBuf.String())
|
||||||
|
fmt.Printf("\nout:\n%s\nerr:\n%s\n", outStr, errStr)
|
||||||
|
klog.Infof("Script returned success\n")
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error
|
|||||||
}
|
}
|
||||||
// TODO: convert shell script to golang
|
// TODO: convert shell script to golang
|
||||||
//localip := GetOutboundIP(Dnsserver_net)
|
//localip := GetOutboundIP(Dnsserver_net)
|
||||||
success, err := Execute(
|
success, err := Execute2(
|
||||||
Shell,
|
Shell,
|
||||||
// "-c",
|
// "-c",
|
||||||
AcmeAuthCmd,
|
AcmeAuthCmd,
|
||||||
@ -81,7 +81,7 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error
|
|||||||
func (loc *LocalDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
|
func (loc *LocalDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
|
||||||
//domainName := extractDomainName(ch.ResolvedZone)
|
//domainName := extractDomainName(ch.ResolvedZone)
|
||||||
//localip := GetOutboundIP(Dnsserver_net)
|
//localip := GetOutboundIP(Dnsserver_net)
|
||||||
success, err := Execute(
|
success, err := Execute2(
|
||||||
Shell,
|
Shell,
|
||||||
// "-c",
|
// "-c",
|
||||||
AcmeAuthCmd,
|
AcmeAuthCmd,
|
||||||
|
|||||||
@ -151,7 +151,7 @@ func checkAuthoritativeNss(fqdn, value string, nameservers []string) (bool, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
klog.Infof("%q: must be %s", fqdn, value)
|
klog.Infof("%q: must be %s", fqdn, value)
|
||||||
klog.Infof("r.Answer: %s", r.Answer)
|
//klog.Infof("r.Answer: %s", r.Answer)
|
||||||
var found bool
|
var found bool
|
||||||
var i = 0
|
var i = 0
|
||||||
for _, rr := range r.Answer {
|
for _, rr := range r.Answer {
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
0.0.5-alpha.77
|
0.0.5-alpha.90
|
||||||
20240414-1206
|
20240416-2039
|
||||||
77
|
90
|
||||||
Loading…
Reference in New Issue
Block a user