Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support globs for image and helm bundles #183

Merged
merged 1 commit into from
Sep 12, 2022
Merged

Conversation

dkoshkin
Copy link
Contributor

Handles file globs for --image-bundle and --helm-bundle.
This also will fail fast if the file does not exist.

➜  mindthegap git:(dkoshkin/globs) ✗ dist/mindthegap_darwin_amd64_v1/mindthegap push image-bundle --image-bundle="glob-test/*.tar" --image-bundle=glob-test-2/dkoshkin-images1.tar --to-registry=127.0.0.1:5000 --to-registry-insecure-skip-tls-verify=true
 ✓ Creating temporary directory
 ✓ Unarchiving image bundle "glob-test-2/dkoshkin-images1.tar"
 ✓ Parsing image bundle config
 ✓ Unarchiving image bundle "glob-test/dkoshkin-images1.tar"
 ✓ Parsing image bundle config
 ✓ Unarchiving image bundle "glob-test/dkoshkin-images2.tar"
 ✓ Parsing image bundle config
 ✓ Starting temporary Docker registry
 ✓ Copying docker.io/library/busybox:latest (from bundle) to 127.0.0.1:5000/library/busybox:latest
 ✓ Copying docker.io/library/nginx:1.21.5 (from bundle) to 127.0.0.1:5000/library/nginx:1.21.5
 ✓ Copying docker.io/library/registry:2 (from bundle) to 127.0.0.1:5000/library/registry:2
➜  mindthegap git:(dkoshkin/globs) ✗ dist/mindthegap_darwin_amd64_v1/mindthegap push image-bundle --image-bundle="glob-test/*.tar" --image-bundle=glob-test-2/dkoshkin-images2.tar --to-registry=127.0.0.1:5000 --to-registry-insecure-skip-tls-verify=true
 ✓ Creating temporary directory
did find any matching files for "glob-test-2/dkoshkin-images2.tar"

@dkoshkin dkoshkin requested a review from jimmidyson September 12, 2022 14:40
@dkoshkin dkoshkin self-assigned this Sep 12, 2022
@dkoshkin dkoshkin force-pushed the dkoshkin/globs branch 2 times, most recently from 64279a5 to e032e47 Compare September 12, 2022 14:48
Copy link
Contributor

@jimmidyson jimmidyson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you so much for this! Need to fix up the linter errors (run make lint locally should do a lot of these) and then we can merge! This is great as I'm getting ready for v1.0 btw 🎉

@dkoshkin
Copy link
Contributor Author

I'm having a hard time running the linter locally

➜  mindthegap git:(dkoshkin/globs) ✗ make lint
▶ installing golang
golang 1.18 is already installed
▶ installing golangci-lint
golangci-lint 1.49.0 is already installed
▶ installing go tool golines
▶ linting root module
archive/archive.go:25:11: undeclared name: `archiver` (typecheck)
	if err = archiver.Archive(filesToArchive, tempTarArchive); err != nil {
	         ^
archive/unarchive.go:13:30: undeclared name: `archiver` (typecheck)
	archiverByExtension, err := archiver.ByExtension(archive)
	                            ^
archive/archive.go:11:2: "github.com/mholt/archiver/v3" imported but not used (typecheck)
	"github.com/mholt/archiver/v3"
	^
archive/unarchive.go:9:2: "github.com/mholt/archiver/v3" imported but not used (typecheck)
	"github.com/mholt/archiver/v3"
	^
helm/client.go:134:29: undeclared name: `getter` (typecheck)
	getters := make(map[string]getter.Getter, len(getter.Getters))
	                           ^
helm/client.go:135:30: undeclared name: `getter` (typecheck)
	for scheme, getter := range getter.Getters {
	                            ^
helm/client.go:138:24: undeclared name: `getter` (typecheck)
	copyFileGetter := new(getter.FileGetter)
	                      ^
helm/client.go:176:68: undeclared name: `klog` (typecheck)
	registryClient, err := registry.NewClient(registry.ClientOptDebug(klog.V(4).Enabled()))
	                                                                  ^
helm/client.go:12:2: "github.com/hashicorp/go-getter" imported but not used (typecheck)
	"github.com/hashicorp/go-getter"
	^
helm/client.go:19:2: "k8s.io/klog/v2" imported but not used (typecheck)
	"k8s.io/klog/v2"
	^
skopeo/skopeo.go:218:16: undeclared name: `distribution` (typecheck)
			Descriptor: distribution.Descriptor{
			            ^
skopeo/skopeo.go:275:5: undeclared name: `klog` (typecheck)
	if klog.V(4).Enabled() {
	   ^
skopeo/skopeo.go:279:2: undeclared name: `klog` (typecheck)
	klog.V(4).Info("Running skopeo", append([]string{r.unpackedSkopeoPath}, skopeoArgs...))
	^
skopeo/skopeo.go:20:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
	"github.com/distribution/distribution/v3"
	^
skopeo/skopeo.go:25:2: "k8s.io/klog/v2" imported but not used (typecheck)
	"k8s.io/klog/v2"
	^
config/helm_charts_config.go:144:12: undeclared name: `yaml` (typecheck)
		dec    = yaml.NewDecoder(f)
		         ^
config/images_config.go:144:12: undeclared name: `yaml` (typecheck)
		dec    = yaml.NewDecoder(f)
		         ^
config/images_config.go:203:9: undeclared name: `yaml` (typecheck)
	enc := yaml.NewEncoder(f)
	       ^
config/helm_charts_config.go:11:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
	"gopkg.in/yaml.v3"
	^
config/images_config.go:16:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
	"gopkg.in/yaml.v3"
	^
make: *** [lint.root] Error 1

@jimmidyson
Copy link
Contributor

@dkoshkin What does golangci-lint version return in that directory? Wondering if you have asdf set up correctly? If not, then make sure that golangci-lint 1.49.0 is in your PATH.

@jimmidyson jimmidyson enabled auto-merge (squash) September 12, 2022 17:03
@jimmidyson jimmidyson merged commit 2f7bafa into main Sep 12, 2022
@jimmidyson jimmidyson deleted the dkoshkin/globs branch September 12, 2022 17:08
@dkoshkin
Copy link
Contributor Author

For the future, you need to also run echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.zshrc after homebrew install asdf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants