Skip to content

Commit

Permalink
Add version and build time
Browse files Browse the repository at this point in the history
  • Loading branch information
pearj committed Dec 10, 2021
1 parent c0d275b commit 574474c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: |
export GOBIN=$(pwd)/bin
export PATH=$PATH:$GOBIN
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager-$VERSION-linux-amd64 main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-X 'main.version=$(git describe --tags)' -X 'main.buildTime=$(date)'" -a -o manager-$VERSION-linux-amd64 main.go
echo manager-$VERSION
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ teste2e:

# Build manager binary
manager: generate fmt vet
go build -o bin/manager main.go
go build -ldflags="-X 'main.version=$(shell git describe --tags)' -X 'main.buildTime=$(shell date)'" -o bin/manager main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
Expand Down
6 changes: 4 additions & 2 deletions adcs/ntlm_certsrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ func (s *NtlmCertsrv) RequestCertificate(csr string, template string) (AdcsRespo
log := log.Log.WithName("RequestCertificate").WithValues("template", template)
var certStatus AdcsResponseStatus = Unknown

log.V(1).Info("Starting certificate request")

url := fmt.Sprintf("%s/%s", s.url, certfnsh)
params := neturl.Values{
"Mode": {"newreq"},
Expand All @@ -209,7 +211,7 @@ func (s *NtlmCertsrv) RequestCertificate(csr string, template string) (AdcsRespo
req.Header.Set("User-agent", "Mozilla")
req.Header.Set("Content-type", ct_urlenc)

log.V(1).Info("Sending request", "request", req)
log.V(2).Info("Sending request", "request", req)

res, err := s.httpClient.Do(req)
if err != nil {
Expand All @@ -228,7 +230,7 @@ func (s *NtlmCertsrv) RequestCertificate(csr string, template string) (AdcsRespo

bodyString := string(body)

log.V(1).Info("Body", "body", bodyString)
log.V(2).Info("Body", "body", bodyString)

exp := regexp.MustCompile(`certnew.cer\?ReqID=([0-9]+)&`)
found := exp.FindStringSubmatch(bodyString)
Expand Down
8 changes: 4 additions & 4 deletions controllers/adcsrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ func (r *AdcsRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
// your logic here
log.Info("Processing request")

if log.V(3).Enabled() {
log.V(3).Info("Running request", "template", r.IssuerFactory.AdcsTemplateName)
}

// Fetch the AdcsRequest resource being reconciled
ar := new(api.AdcsRequest)
if err := r.Client.Get(ctx, req.NamespacedName, ar); err != nil {
Expand All @@ -71,6 +67,10 @@ func (r *AdcsRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, err
}

if log.V(3).Enabled() {
log.V(3).Info("Running request", "template", issuer.AdcsTemplateName)
}

cert, caCert, err := issuer.Issue(ctx, ar)
if err != nil {
// This is a local error.
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ const (
)

var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
version = "development"
buildTime = "unknown"
)

func init() {
Expand Down Expand Up @@ -83,6 +85,8 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

setupLog.Info("Starting ADCS Issuer", "version", version, "build time", buildTime)

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Expand Down

0 comments on commit 574474c

Please sign in to comment.