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

Deprecate v1 projects #1137

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/init_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func (o *projectOptions) initializeProject() {
log.Fatal(err)
}

if o.project.Version == project.Version1 {
printV1DeprecationWarning()
}

if err := o.scaffolder.Scaffold(); err != nil {
log.Fatalf("error scaffolding project: %v", err)
}
Expand Down
13 changes: 12 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (

"sigs.k8s.io/kubebuilder/cmd/version"
"sigs.k8s.io/kubebuilder/pkg/scaffold"
"sigs.k8s.io/kubebuilder/pkg/scaffold/project"
)

const (
NoticeColor = "\033[1;36m%s\033[0m"
)

// module and goMod arg just enough of the output of `go mod edit -json` for our purposes
Expand Down Expand Up @@ -112,7 +117,9 @@ func main() {
)

foundProject, version := getProjectVersion()
if foundProject && version == "1" {
if foundProject && version == project.Version1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Cobra command library does provide mechanism to mark commands as deprecated but I think the implemented approach will work better for our case.

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you suggest to do this change from another PR (#1143) into this?

Copy link
Member

Choose a reason for hiding this comment

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

Hi @Adirio,

Because this PR is doing/replacing if foundProject && version == "1" { for if foundProject && version == project.Version1 {.

So, as part of its review, I am suggesting if foundProject && version == "1" { for if hasProjectFile && projectVersion == project.Version1 { instead of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that @camilamacedo86 suggested naming is more suitable. But I also agree that we can lay it on #1143, as the narrow scope of my change was only to replace the string "1" with the constant project.Version1, and not to change other things.

If you still think we should introduce this change here, let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

@hypnoglow The change she is suggesting is not just a more suitable name, it has to do with the package with the same alias (version). The context is missing as this is a change I suggested in #1143 and she suggested a name change. Suggesting to change this here makes no sense as this PR is about a completely different topic.

Copy link
Member

Choose a reason for hiding this comment

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

It is not a big deal so I am OK with.

printV1DeprecationWarning()

rootCmd.AddCommand(
newAlphaCommand(),
newVendorUpdateCmd(),
Expand Down Expand Up @@ -188,3 +195,7 @@ func getProjectVersion() (bool, string) {
}
return true, projectInfo.Version
}

func printV1DeprecationWarning() {
fmt.Printf(NoticeColor, "[Deprecation Notice] The v1 projects are deprecated and will not be supported beyond Feb 1, 2020.\nSee how to upgrade your project to v2: https://book.kubebuilder.io/migration/guide.html\n")
}