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

package uri doesnt handle branches names properly #45

Closed
bluebrown opened this issue Apr 14, 2024 · 7 comments · Fixed by #62 or #64
Closed

package uri doesnt handle branches names properly #45

bluebrown opened this issue Apr 14, 2024 · 7 comments · Fixed by #62 or #64
Labels
bug Something isn't working

Comments

@bluebrown
Copy link
Owner

The current implementation fo the git package uri is pretty buggy. It was a bad idea to go for this custom format after all.

The root of all evil is, of course, regex:

var pattern = regexp.MustCompile(`^(?P<repo>.*)@(?P<ref>\w+)(?P<pkg>\/.+)?$`)

This only works for single word branches like main or trunk. Something like my-branch or my/branch will not work.

The reason why the custom parser has been created is because the url package from the stdlib doesnt understand the ssh url for git. For example https://github.com/hashicorp/go-getter/tree/main/helper/url.

Kustomize can also fetch packages from remote: https://github.com/kubernetes-sigs/kustomize/blob/82ee768212df792aec76636c07c487b40500ce46/cmd/gorepomod/internal/utils/utils.go#L53-L54

@github-actions github-actions bot added the triage requires review label Apr 14, 2024
@bluebrown bluebrown added bug Something isn't working and removed triage requires review labels Apr 14, 2024
@tsmalls93
Copy link
Contributor

I ran into this today with hyphenated branches. Should the regex be modified, or do you have another idea on how to fix it?

@bluebrown
Copy link
Owner Author

Im not really sure. I think it requires a breaking change no matter what.

Perhaps using a double slash to seperate the path.
Or maybe split up the params and not use a single url.
Or use a url but use url parameters properly.

I could never decide so I left it. What do you think?

@tsmalls93
Copy link
Contributor

I like the idea of using URL parameters. Maybe something like git@github.com:some-org/some-repo.git?ref=some-ref&pkg=some-pkg?

@bluebrown
Copy link
Owner Author

That would be ok with me.

Do you want to try and do that?

Idieally this would also solve the situation with the .git suffix, which is kind of strange at the moment. But it doesnt have to, I guess. https://github.com/bluebrown/kobold/blob/main/git/pkguri.go

@bluebrown
Copy link
Owner Author

I did some experiments with https://github.com/hashicorp/go-getter, regarding this. It kind of looks promising but then it doesnt exaclty work out, as far as I can see. It would be nice though.

@bluebrown
Copy link
Owner Author

bluebrown commented Aug 21, 2024

thanks @tsmalls93, I have build the image here: docker.io/bluebrown/kobold:e6ad83e. You could deploy it for good and do some smoketests.

@bluebrown
Copy link
Owner Author

@tsmalls93 , I have released your change now https://github.com/bluebrown/kobold/releases. Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants