-
Notifications
You must be signed in to change notification settings - Fork 300
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
Cleanup: Use ResourceFlavor.metadata.labels #353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,11 @@ limitations under the License. | |
package v1alpha2 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
|
@@ -68,7 +69,7 @@ var _ = ginkgo.Describe("ResourceFlavor Webhook", func() { | |
resourceFlavor := testing.MakeResourceFlavor("resource-flavor").Label("foo", "@abcd").Obj() | ||
err := k8sClient.Create(ctx, resourceFlavor) | ||
gomega.Expect(err).Should(gomega.HaveOccurred()) | ||
gomega.Expect(errors.IsForbidden(err)).Should(gomega.BeTrue(), "error: %v", err) | ||
gomega.Expect(err.Error()).To(gomega.ContainSubstring(errorInvalidLabelValue("@abcd"))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error returned is not of type forbidden. Hence, added the error substring. Any other way to assert the error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there should be an error type that matches in the package. The substrings could change upstream, so I rather not pay attention to that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably |
||
}) | ||
}) | ||
|
||
|
@@ -92,7 +93,11 @@ var _ = ginkgo.Describe("ResourceFlavor Webhook", func() { | |
ginkgo.By("Updating the resourceFlavor with invalid labels") | ||
err := k8sClient.Update(ctx, &created) | ||
gomega.Expect(err).Should(gomega.HaveOccurred()) | ||
gomega.Expect(errors.IsForbidden(err)).Should(gomega.BeTrue(), "error: %v", err) | ||
gomega.Expect(err.Error()).To(gomega.ContainSubstring(errorInvalidLabelValue("@abcd"))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert |
||
}) | ||
}) | ||
}) | ||
|
||
func errorInvalidLabelValue(labelValue string) string { | ||
return fmt.Sprintf("ResourceFlavor.kueue.x-k8s.io \"resource-flavor\" is invalid: metadata.labels: Invalid value: \"%s\"", labelValue) | ||
} |
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.
Can something similar be added above ObjectMeta? Would that be included in the CRD yaml?
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.
Adding single or multi-line comment does not generate description for ObjectMeta in CRD yaml using
make manifests
command.metav1.ObjectMeta
struct is embedded inside ResourceFlavor struct. It's not a separate field defined. Don't know of any other way to add for.metadata.labels
.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.
I see. That's fine then.