-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor owner repo, add list of repos, helper funcs, latest tag, lis…
…t tags (#296)
- Loading branch information
1 parent
2583848
commit 5c55294
Showing
12 changed files
with
266 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
BINARIES = gen_release_notes gen_release_report backport semv standup k3s_release rancher_release test_coverage upstream_go_version rke2_release | ||
ARCHS = amd64 arm64 | ||
OSs = linux darwin freebsd | ||
|
||
GO_COMPILE = CGO_ENABLED=1 $(GO) build -tags $(TAGS) -v -ldflags "$(LDFLAGS)" -o $@-$${os}-$${arch} | ||
OS := $(shell uname) | ||
|
||
ifeq ($(OS),Darwin) | ||
GEN_HASH = shasum -a 256 $@-$${os}-$${arch} >> $(BINDIR)/sha256sums-$(BINARY).txt | ||
else | ||
GEN_HASH = sha256sum $@-$${os}-$${arch} >> $(BINDIR)/sha256sums-$(BINARY).txt | ||
endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
"github.com/rancher/ecm-distro-tools/repository" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func componentsCommand() *cli.Command { | ||
return &cli.Command{ | ||
Name: "components", | ||
Usage: "interact with the RKE2 components", | ||
Flags: []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: "github-token", | ||
Aliases: []string{"g"}, | ||
EnvVars: []string{"GITHUB_TOKEN"}, | ||
Required: true, | ||
}, | ||
&cli.StringFlag{ | ||
Name: "list", | ||
Aliases: []string{"l"}, | ||
Required: false, | ||
}, | ||
}, | ||
Action: components, | ||
} | ||
} | ||
|
||
func components(c *cli.Context) error { | ||
token := c.String("github-token") | ||
if token == "" { | ||
return errors.New("env var GITHUB_TOKEN is required") | ||
} | ||
|
||
listContent := c.String("list") | ||
|
||
ctx := context.Background() | ||
ghClient := repository.NewGithub(ctx, token) | ||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 0, ' ', tabwriter.Debug) | ||
|
||
if listContent == "all" { | ||
for _, repo := range repository.RKE2HardenedImages { | ||
owner, repo, err := repository.SplitOwnerRepo(repo) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tag, err := repository.LatestTag(ctx, ghClient, owner, repo) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Fprintf(w, "%s\t%+v\n", repo, *tag.Name) | ||
} | ||
} else { | ||
owner, repo, err := repository.SplitOwnerRepo(listContent) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tag, err := repository.LatestTag(ctx, ghClient, owner, repo) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Fprintf(w, "%s\t%+v\n", repo, *tag.Name) | ||
} | ||
|
||
w.Flush() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.