Skip to content

Commit

Permalink
refactor: get the skaffold yaml version at compile time as failover
Browse files Browse the repository at this point in the history
Signed-off-by: kaanyagci <kaan.yagci@makepad.fr>
  • Loading branch information
kaanyagci committed Aug 11, 2024
1 parent baa7cac commit 72d3b90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
4 changes: 3 additions & 1 deletion internal/skaffold/skaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 72d3b90

Please sign in to comment.