diff --git a/.gitignore b/.gitignore index d94d697..4f1f4eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,28 @@ -# ---> Go -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# Allowlisting gitignore template for GO projects prevents us +# from adding various unwanted local files, such as generated +# files, developer configurations or IDE-specific files etc. # -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib +# Recommended: Go.AllowList.gitignore -# Test binary, built with `go test -c` -*.test +# Ignore everything +* -# Output of the go coverage tool, specifically when used with LiteIDE -*.out +# But not these files... +!/.gitignore -# Dependency directories (remove the comment below to include it) -# vendor/ +!*.go +!go.sum +!go.mod -# Go workspace file -go.work +!examples/* -bin/ +!*.md +!LICENSE -examples/testing/ +!Makefile -*.yaml -!examples/*.yaml +# Woodpecker CI +!.woodpecker/* -test/ +# ...even if they are in subdirectories +!*/ diff --git a/.vscode/launch.json b/.vscode/launch.json index d4a07bf..053205a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "go", "request": "launch", "mode": "auto", - "program": "${workspaceFolder}", + "program": "${workspaceFolder}/cmd/certwarden-deploy/main.go", "args": ["--config", "${workspaceFolder}/config.yaml", "--dry-run"] }, { @@ -17,7 +17,7 @@ "type": "go", "request": "launch", "mode": "auto", - "program": "${workspaceFolder}", + "program": "${workspaceFolder}/cmd/certwarden-deploy/main.go", "args": ["--config", "${workspaceFolder}/config.yaml", "--verbose"] } ] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9cd8f31 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +# Set the default Go build flags +GOFLAGS = -ldflags='-w -s -X constants.Version=$(VERSION)' + +# Build the application +build: + go build $(GOFLAGS) -o bin/certwarden-deploy cmd/certwarden-deploy/main.go + +# Clean the build artifacts +clean: + rm -rf bin + +# Set a version for the build +VERSION := $(shell git describe --tags --always) diff --git a/cmd/certwarden-deploy/root.go b/cmd/certwarden-deploy/main.go similarity index 86% rename from cmd/certwarden-deploy/root.go rename to cmd/certwarden-deploy/main.go index 6bbbceb..bce2d8d 100644 --- a/cmd/certwarden-deploy/root.go +++ b/cmd/certwarden-deploy/main.go @@ -2,7 +2,7 @@ Copyright © 2024 Laura Kalb The code of this project is available under the MIT license. See the LICENSE file for more info. */ -package cmd +package main import ( "os" @@ -11,9 +11,7 @@ import ( "code.lila.network/adoralaura/certwarden-deploy/internal/configuration" ) -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() { +func main() { err := cli.RootCmd.Execute() if err != nil { os.Exit(1) diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 75f2492..a427830 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -1,7 +1,9 @@ package constants -const Version = "0.2.1" +var Version string + +var UserAgent = "certwarden-deploy/" + Version + " +https://code.lila.network/adoralaura/certwarden-deploy" + const CertificateApiPath = "/certwarden/api/v1/download/certificates/" const KeyApiPath = "/certwarden/api/v1/download/privatekeys/" const ApiKeyHeaderName = "X-API-Key" -const UserAgent = "certwarden-deploy/" + Version + " +https://code.lila.network/adoralaura/certwarden-deploy" diff --git a/main.go b/main.go deleted file mode 100644 index 588fd19..0000000 --- a/main.go +++ /dev/null @@ -1,11 +0,0 @@ -/* -Copyright © 2024 Laura Kalb -The code of this project is available under the MIT license. See the LICENSE file for more info. -*/ -package main - -import cmd "code.lila.network/adoralaura/certwarden-deploy/cmd/certwarden-deploy" - -func main() { - cmd.Execute() -}