diff --git a/Makefile b/Makefile index 24c819a..baf30a0 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ create-out-directory: build: create-out-directory @echo "Building the binary..." - go build -o $(BINARY_PATH) main.go + go build -ldflags="-X 'skaffold.latestSkaffoldVersion=$(SKAFFOLD_YAML_VERSION)'" -o $(BINARY_PATH) main.go clean: @echo "Cleaning up..." diff --git a/internal/skaffold/skaffold.go b/internal/skaffold/skaffold.go index 9d0c745..7c24412 100644 --- a/internal/skaffold/skaffold.go +++ b/internal/skaffold/skaffold.go @@ -59,6 +59,8 @@ type GitHubFileContent struct { Encoding string `json:"encoding"` } +var latestSkaffoldVersion string + func getLatestSkaffoldYamlVersion() (string, error) { // GitHub API URL for the specific file url := "https://api.github.com/repos/GoogleContainerTools/skaffold/contents/docs-v2/content/en/docs/references/cli/_index.md" @@ -104,7 +106,7 @@ func InitializeSkaffold(skaffoldPath string) error { skaffoldYamlVersion, err := getLatestSkaffoldYamlVersion() if err != nil { log.Printf("Error while getting latest version from GitHub: %v", err) - return err + skaffoldYamlVersion = latestSkaffoldVersion } initialContent := SkaffoldConfig{ APIVersion: fmt.Sprintf("skaffold/%s", skaffoldYamlVersion),