-
Notifications
You must be signed in to change notification settings - Fork 190
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
Use go-git
functionalities for common git operations
#108
Conversation
Needs |
ecc9b22
to
6371c7b
Compare
) | ||
|
||
// LoadRepository loads a repository from the local file system. | ||
// TODO(a-hilaly): load repository into a memory filesystem (needs go1.16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How large would this be in memory? I know the aws-sdk-go
has a large commit history and many, many tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
du -sh ~/.cache/aws-controllers-k8s/src/aws-sdk-go
352M /Users/hilalymh/.cache/aws-controllers-k8s/src/aws-sdk-go
I guess it's gonna be ~350M - I will do some profile on ack-generate
binary before implementing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RedbackThomson Is it a bad a idea to load such a big repository in memory?
command using `os/exec` This patch updates all the helper functions to use `go-git` library instead of having to call `os/exec.Command`/`os/exec.CombinedOutput` in order to clone repository, fetch tags... These changes brings more dependencies to our `go.mod` but in exchange it simplifies the way we interact with git repositories and improves errors handling and readability. Future changes will also benefit from this patch, especially conversation webhook generator that will need to checkout multiple version tags.
/unhold |
/approve I am sure you tested this locally for some controller. Good to add the output in PR since there are no new unit tests. |
Adding unit tests |
Looks like it's very complex to unit test these util functions, and it's almost equivalent of testing the go-git library. @vijtrip2 and I agreed on leaving the PR as is and just run some local tests. On my local machine # First run (no local aws-sdk-go cache)
time ACK_GENERATE_CACHE_DIR=/tmp/gitest AWS_SDK_GO_VERSION=v1.38.60 make build-ack-generate build-controller SERVICE=ecr
building ack-generate ... ok.
Copying common custom resource definitions into ecr
Building Kubernetes API objects for ecr
Generating deepcopy code for ecr
Generating custom resource definitions for ecr
Building service controller for ecr
Generating RBAC manifests for ecr
Running gofmt against generated code for ecr
ACK_GENERATE_CACHE_DIR=/tmp/gitest AWS_SDK_GO_VERSION=v1.38.60 make 54,08s user 3,20s system 50% cpu 1:53,98 total
# Second run
time ACK_GENERATE_CACHE_DIR=/tmp/gitest AWS_SDK_GO_VERSION=v1.38.60 make build-ack-generate build-controller SERVICE=ecr
building ack-generate ... ok.
Copying common custom resource definitions into ecr
Building Kubernetes API objects for ecr
Generating deepcopy code for ecr
Generating custom resource definitions for ecr
Building service controller for ecr
Generating RBAC manifests for ecr
Running gofmt against generated code for ecr
ACK_GENERATE_CACHE_DIR=/tmp/gitest AWS_SDK_GO_VERSION=v1.38.60 make 8,04s user 1,27s system 176% cpu 5,264 total /unhold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and clean, @a-hilaly. Good job! :)
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: A-Hilaly, jaypipes, vijtrip2 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
# This is the 1st commit message: add new field to pkg/generate/config.go so user can implement custom requiredFieldMissingFromReadOneInput # This is the commit message aws-controllers-k8s#2: Use `go-git` functionalities for common git operations (aws-controllers-k8s#108) Part of aws-controllers-k8s/community#835 This patch updates all the helper functions to use `go-git` library instead of having to call `os/exec.Command`/`os/exec.CombinedOutput` in order to clone repository, fetch tags... These changes brings more dependencies to our `go.mod` but in exchange it simplifies the way we interact with git repositories and improves errors handling and readability. Future changes will also benefit from this patch, especially conversation webhook generator that will need to checkout multiple version tags. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
…rs-k8s#108) Part of aws-controllers-k8s/community#835 This patch updates all the helper functions to use `go-git` library instead of having to call `os/exec.Command`/`os/exec.CombinedOutput` in order to clone repository, fetch tags... These changes brings more dependencies to our `go.mod` but in exchange it simplifies the way we interact with git repositories and improves errors handling and readability. Future changes will also benefit from this patch, especially conversation webhook generator that will need to checkout multiple version tags. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Part of aws-controllers-k8s/community#835
This patch updates all the helper functions to use
go-git
libraryinstead of having to call
os/exec.Command
/os/exec.CombinedOutput
inorder to clone repository, fetch tags... These changes brings more
dependencies to our
go.mod
but in exchange it simplifies the way weinteract with git repositories and improves errors handling and
readability.
Future changes will also benefit from this patch, especially
conversation webhook generator that will need to checkout multiple
version tags.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.