-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
add already exists check in object creation #2683
add already exists check in object creation #2683
Conversation
@@ -129,7 +130,9 @@ func createFromYAMLFile(cfg BasicAndOLMPluginConfig, yamlPath string) error { | |||
} | |||
} | |||
err = runtimeClient.Create(context.TODO(), obj) | |||
if err != nil { | |||
if errors.IsAlreadyExists(err) { |
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.
Great 👍
Missing just add changelog entry for the fix
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.
thanks, added the changelog entry.
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
/approve
if err != nil { | ||
if errors.IsAlreadyExists(err) { | ||
fmt.Printf("already exists, %s, not creating.", yamlPath) | ||
} else if err != nil { | ||
_, restErr := restMapper.RESTMappings(obj.GetObjectKind().GroupVersionKind().GroupKind()) |
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.
Add a test for the scenario would be great as well. If it is not too much work
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
/approve
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
Description of the change:
this PR fixes a situation where an operator being tested with scorecard, creates CRs in its implementation (seeded), this would cause scorecard to fail since it was trying to create the same CRs already seeded. With this change, if a CR is already created, the scorecard will just print a message to the user to let them know when a CR already exists.
Motivation for the change:
Closes #2677