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

Use "dep" to import dependencies for generated project #136

Merged
merged 1 commit into from
May 10, 2018

Conversation

droot
Copy link
Contributor

@droot droot commented May 8, 2018

Fixes #134

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 8, 2018
@droot droot requested a review from pwittrock May 8, 2018 20:19
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 8, 2018
func RunVendorInstall(cmd *cobra.Command, args []string) {
if Update {
backupFilename := fmt.Sprintf("%s.bkp", depManifestFile)
if err := copyFile(depManifestFile, backupFilename); err != nil {
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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",
Copy link
Contributor

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

Copy link
Contributor Author

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.
Copy link
Contributor

@pwittrock pwittrock May 8, 2018

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.

Copy link
Contributor Author

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"
Copy link
Contributor

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"
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor

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" -}}
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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 = `
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@droot droot left a 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.
Copy link
Contributor Author

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 = `
Copy link
Contributor Author

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.
Copy link
Contributor Author

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",
Copy link
Contributor Author

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" -}}
Copy link
Contributor Author

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"
Copy link
Contributor Author

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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.

Copy link
Contributor

@Liujingfang1 Liujingfang1 left a 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.
Copy link
Contributor

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?

@pwittrock pwittrock merged commit ddb0309 into kubernetes-sigs:master May 10, 2018
luffyao pushed a commit to luffyao/kubebuilder that referenced this pull request Aug 6, 2020
zh-translation: docs/book/src/cronjob-tutorial/main-revisited.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants