-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 "dep" to import dependencies for generated project #136
Conversation
func RunVendorInstall(cmd *cobra.Command, args []string) { | ||
if Update { | ||
backupFilename := fmt.Sprintf("%s.bkp", depManifestFile) | ||
if err := copyFile(depManifestFile, backupFilename); err != nil { |
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.
Maybe you can use os.Rename
here. Base on the code change, it is OK to not keep the original file.
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.
Done. Thanks for the suggestion.
func updateDepConfig() error { | ||
var depConstraint string | ||
// template for dep's manifest file (Gopkg.toml). This is generated using | ||
// scripts/generate_dep_manifest.sh scripts. |
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.
Just want to make things clear. If we update the dependency of kubebuilder itself, do we need to rerun the script generate_dep_manifest.sh
to regenerate this template? So that the dep in generated projects is in sync with kubebuilder itself.
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.
Good question. Maybe we need a script to wrap dep ensure?
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.
@Liujingfang1 yes, we should re-run the generate_dep_manifest.sh
whenever we are updating kubebuilder dependencies. In some instances, our tests will catch that (it did for the docs change that Phil pushed and I updated it).
So for now, I have made it very simple to do it and added the documentation in the script itself.
# | ||
|
||
required=[ | ||
"sigs.k8s.io/testing_frameworks/integration", |
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.
Lets do these as naked imports so users can manage their own required
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.
Done.
// scripts/generate_dep_manifest.sh scripts. | ||
const depManifestTmpl = ` | ||
# | ||
# Note: Stanzas below are generated by Kubebuilder. |
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.
# Users add deps lines here
# Note: Stanzas below are generated by Kubebuilder and may be rewritten when upgrading kubebuilder versions.
# DO NOT MODIFY BELOW THIS LINE.
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.
Done.
[[constraint]] | ||
version = "%s" | ||
name = "github.com/kubernetes-sigs/kubebuilder" |
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.
get rid of this
version="1.1.3" | ||
|
||
[[override]] | ||
name="github.com/kubernetes-sigs/kubebuilder" |
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.
Don't hard code this revision, make it the version or branch
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.
Done.
@@ -126,19 +125,6 @@ function build_kb { | |||
go build -o $tmp_root/kubebuilder/bin/kubebuilder-gen ./cmd/kubebuilder-gen | |||
} | |||
|
|||
function prepare_vendor_deps { |
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.
Where will get get deps from once this is merged?
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.
Nm, they are copied.
name = "github.com/kubernetes-sigs/kubebuilder" | ||
`, kbVersion) | ||
} | ||
{{ if eq .Version "unknown" -}} |
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.
This should just be an override.
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.
Done.
|
||
[prune] | ||
go-tests = true | ||
#unused-packages = true |
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.
Lets put this above the generated stanza to allow users to control 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.
Done.
var depConstraint string | ||
// template for dep's manifest file (Gopkg.toml). This is generated using | ||
// scripts/generate_dep_manifest.sh scripts. | ||
const depManifestTmpl = ` |
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.
Maybe this should go in its own file so it is easier to generate and update from script.
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.
Moved it to separate file.
fr, err := os.Open(f) | ||
if err != nil { | ||
log.Fatalf("failed to read vendor tar file %s %v", f, err) | ||
func RunVendorInstall(cmd *cobra.Command, args []string) { |
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.
We should check that dep
is installed and give an error message if it is not.
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.
Done.
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.
Thanks for the review @Liujingfang1 @pwittrock . Addressed the review comment. PTAL.
func updateDepConfig() error { | ||
var depConstraint string | ||
// template for dep's manifest file (Gopkg.toml). This is generated using | ||
// scripts/generate_dep_manifest.sh scripts. |
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.
@Liujingfang1 yes, we should re-run the generate_dep_manifest.sh
whenever we are updating kubebuilder dependencies. In some instances, our tests will catch that (it did for the docs change that Phil pushed and I updated it).
So for now, I have made it very simple to do it and added the documentation in the script itself.
var depConstraint string | ||
// template for dep's manifest file (Gopkg.toml). This is generated using | ||
// scripts/generate_dep_manifest.sh scripts. | ||
const depManifestTmpl = ` |
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.
Moved it to separate file.
// scripts/generate_dep_manifest.sh scripts. | ||
const depManifestTmpl = ` | ||
# | ||
# Note: Stanzas below are generated by Kubebuilder. |
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.
Done.
# | ||
|
||
required=[ | ||
"sigs.k8s.io/testing_frameworks/integration", |
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.
Done.
name = "github.com/kubernetes-sigs/kubebuilder" | ||
`, kbVersion) | ||
} | ||
{{ if eq .Version "unknown" -}} |
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.
Done.
version="1.1.3" | ||
|
||
[[override]] | ||
name="github.com/kubernetes-sigs/kubebuilder" |
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.
Done.
|
||
[prune] | ||
go-tests = true | ||
#unused-packages = true |
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.
Done.
fr, err := os.Open(f) | ||
if err != nil { | ||
log.Fatalf("failed to read vendor tar file %s %v", f, err) | ||
func RunVendorInstall(cmd *cobra.Command, args []string) { |
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.
Done.
func RunVendorInstall(cmd *cobra.Command, args []string) { | ||
if Update { | ||
backupFilename := fmt.Sprintf("%s.bkp", depManifestFile) | ||
if err := copyFile(depManifestFile, backupFilename); err != nil { |
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.
Done. Thanks for the suggestion.
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.
Overall looks good to me.
@@ -0,0 +1,198 @@ | |||
/* | |||
Copyright 2017 The Kubernetes Authors. |
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.
Do you need to change 2017
to 2018
?
zh-translation: docs/book/src/cronjob-tutorial/main-revisited.md
Fixes #134