-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: validate plugins : allow many versions of the same plugin #1535
Conversation
[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 |
dae83e5
to
c0816df
Compare
/assign @estroz |
/kind bug |
c0816df
to
8256166
Compare
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 |
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.
// 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. |
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.
// 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()) |
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.
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 { |
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.
if _, seen := pluginNameSet[pluginNameVersion]; seen { | |
if _, seen := pluginNameSet[pluginKey]; seen { |
pkg/cli/cli.go
Outdated
} | ||
pluginNameSet[pluginName] = struct{}{} | ||
pluginNameSet[pluginNameVersion] = struct{}{} |
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.
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) |
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.
return fmt.Errorf("two plugins have the same name and version: %q", pluginNameVersion) | |
return fmt.Errorf("two plugins have the same key: %q", pluginKey) |
8256166
to
4d8e7bb
Compare
pkg/cli/cli_test.go
Outdated
"foo.example.com/v3.0.0", | ||
) | ||
|
||
err := validatePlugins(plugins[0], plugins[1], plugins[2]) |
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.
err := validatePlugins(plugins[0], plugins[1], plugins[2]) | |
err := validatePlugins(plugins...) |
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 catcher 👍
pkg/cli/cli_test.go
Outdated
"foo.example.com/v1.0.0", | ||
) | ||
|
||
err := validatePlugins(plugins[0], plugins[1]) |
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.
err := validatePlugins(plugins[0], plugins[1]) | |
err := validatePlugins(plugins...) |
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 catcher 👍
4d8e7bb
to
3d4ae11
Compare
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.
/lgtm
closes: #1534