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 git-init flag #3241

Merged
merged 1 commit into from
Jun 17, 2020
Merged

deprecate git-init flag #3241

merged 1 commit into from
Jun 17, 2020

Conversation

camilamacedo86
Copy link
Contributor

Description of the change:
deprecate git-init flag in the new cmd

Motivation for the change:
Has no need for we have a flag for it. Users are able to run git init when they wish.

@@ -389,6 +394,8 @@ func verifyFlags() error {
return nil
}

// Deprecated: the git-init flag was deprecated since has no need to make the command run the git init.

Choose a reason for hiding this comment

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

you could in addition to adding the deprecation move it to another file, so when the time comes you just need to delete the file and make the code build again

Copy link
Contributor Author

@camilamacedo86 camilamacedo86 Jun 16, 2020

Choose a reason for hiding this comment

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

Tks for the suggestion. But in this case, I do not think that it is required/worth to do that.

newCmd.Flags().BoolVar(&gitInit, "git-init", false,
"Initialize the project directory as a git repository (default false)")
_ = newCmd.Flags().MarkDeprecated("git-init", "This flag will be removed soon. "+

Choose a reason for hiding this comment

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

you can also extract that to an external file I think, just pass the newcmd as an argument

@@ -190,7 +195,7 @@ func newFunc(cmd *cobra.Command, args []string) error {
log.Fatal(err)
}
}

//todo: remove before 1.0.0
if gitInit {
if err := initGit(); err != nil {
log.Fatal(err)

Choose a reason for hiding this comment

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

this for sure can be extracted

@georgettica
Copy link

I do not know your convension, but should the commits be squashed to one big commit?

if not I will add a /lgtm on my side

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

Looks good. Just one minor improvement to the deprecation message.

cmd/operator-sdk/new/cmd.go Outdated Show resolved Hide resolved
newCmd.Flags().BoolVar(&gitInit, "git-init", false,
"Initialize the project directory as a git repository (default false)")
_ = newCmd.Flags().MarkDeprecated("git-init", "This flag will be removed soon. "+
Copy link
Member

Choose a reason for hiding this comment

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

Check this error with a panic, since this should never occur.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we really give a panic if the flag was not marked as deprecated?
IMO shows fine in this case just suppress the error.

Copy link
Member

Choose a reason for hiding this comment

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

Right now the flag output is

Flag --git-init has been deprecated, This flag will be removed soon. To continue using git, run `git init` once your project is created.

The following reads better:

Flag --git-init has been deprecated, instead run `git init` once your project is created to use git

So change the help text to:

Suggested change
_ = newCmd.Flags().MarkDeprecated("git-init", "This flag will be removed soon. "+
_ = newCmd.Flags().MarkDeprecated("git-init", "instead run `git init` once your project is created to use git")

Copy link
Member

Choose a reason for hiding this comment

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

@camilamacedo86 MarkDeprecated will only error if the flag name is not found, which it always will be. If it isn't the SDK should panic, like in other commands.

Copy link
Contributor Author

@camilamacedo86 camilamacedo86 Jun 16, 2020

Choose a reason for hiding this comment

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

which it always will be . Exactly, because of this shows not a scenario that really needs to be covered. However, it is fine. The suggestion was applied. Tks for the review.

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 16, 2020
@camilamacedo86
Copy link
Contributor Author

Hi @joelanford,

Are you ok with move with it now?

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 17, 2020
@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 17, 2020
Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2020
@camilamacedo86 camilamacedo86 merged commit 771d171 into operator-framework:master Jun 17, 2020
@camilamacedo86 camilamacedo86 deleted the deprecate-git-nit branch June 17, 2020 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants