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

fix: validate plugins : allow many versions of the same plugin #1535

Merged

Conversation

camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented May 29, 2020

closes: #1534

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 29, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 29, 2020
@camilamacedo86
Copy link
Member Author

/assign @estroz

@camilamacedo86
Copy link
Member Author

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 30, 2020
pkg/cli/cli.go Outdated
@@ -351,12 +351,13 @@ func validatePlugins(plugins ...plugin.Base) error {
pluginName, projectVersion, err)
}
}
// Check for duplicate plugin names. Names outside of a version can
// Check if has duplicate plugins. Names outside of a version can
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Check if has duplicate plugins. Names outside of a version can
// Check for duplicate plugin keys.

pkg/cli/cli.go Outdated
@@ -351,12 +351,13 @@ func validatePlugins(plugins ...plugin.Base) error {
pluginName, projectVersion, err)
}
}
// Check for duplicate plugin names. Names outside of a version can
// Check if has duplicate plugins. Names outside of a version can
// conflict because multiple project versions of a plugin may exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// conflict because multiple project versions of a plugin may exist.

pkg/cli/cli.go Outdated
// conflict because multiple project versions of a plugin may exist.
if _, seen := pluginNameSet[pluginName]; seen {
return fmt.Errorf("two plugins have the same name: %q", pluginName)
pluginNameVersion := fmt.Sprintf("%v/%v", p.Name(), p.Version())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pluginNameVersion := fmt.Sprintf("%v/%v", p.Name(), p.Version())
pluginKey := plugin.KeyFor(p)

pkg/cli/cli.go Outdated
if _, seen := pluginNameSet[pluginName]; seen {
return fmt.Errorf("two plugins have the same name: %q", pluginName)
pluginNameVersion := fmt.Sprintf("%v/%v", p.Name(), p.Version())
if _, seen := pluginNameSet[pluginNameVersion]; seen {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if _, seen := pluginNameSet[pluginNameVersion]; seen {
if _, seen := pluginNameSet[pluginKey]; seen {

pkg/cli/cli.go Outdated
}
pluginNameSet[pluginName] = struct{}{}
pluginNameSet[pluginNameVersion] = struct{}{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pluginNameSet[pluginNameVersion] = struct{}{}
pluginNameSet[pluginKey] = struct{}{}

pkg/cli/cli.go Outdated
return fmt.Errorf("two plugins have the same name: %q", pluginName)
pluginNameVersion := fmt.Sprintf("%v/%v", p.Name(), p.Version())
if _, seen := pluginNameSet[pluginNameVersion]; seen {
return fmt.Errorf("two plugins have the same name and version: %q", pluginNameVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("two plugins have the same name and version: %q", pluginNameVersion)
return fmt.Errorf("two plugins have the same key: %q", pluginKey)

"foo.example.com/v3.0.0",
)

err := validatePlugins(plugins[0], plugins[1], plugins[2])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err := validatePlugins(plugins[0], plugins[1], plugins[2])
err := validatePlugins(plugins...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catcher 👍

"foo.example.com/v1.0.0",
)

err := validatePlugins(plugins[0], plugins[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err := validatePlugins(plugins[0], plugins[1])
err := validatePlugins(plugins...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catcher 👍

Copy link
Contributor

@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

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 30, 2020
@k8s-ci-robot k8s-ci-robot merged commit 0ff2828 into kubernetes-sigs:master May 30, 2020
@camilamacedo86 camilamacedo86 deleted the fix-plugin-version branch May 30, 2020 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unable to have the same plugin with different versions
3 participants