-
Notifications
You must be signed in to change notification settings - Fork 608
Add ConsoleYAMLSample CRD type #465
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package v1 | ||
|
|
||
| import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| // +genclient | ||
| // +genclient:nonNamespaced | ||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
||
| // ConsoleYAMLSample is an extension for customizing OpenShift web console YAML samples. | ||
| type ConsoleYAMLSample struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| // Standard object's metadata. | ||
| metav1.ObjectMeta `json:"metadata"` | ||
| Spec ConsoleYAMLSampleSpec `json:"spec"` | ||
| } | ||
|
|
||
| // ConsoleYAMLSampleSpec is the desired YAML sample configuration. | ||
|
Contributor
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. How does this know what
Member
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. Here is the proposal for target resource in the console PR: https://github.com/openshift/console/pull/2889/files#r331471061
Contributor
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. so is that going to be added to this ConsoleYAMLSample api?
Member
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.
Yes, we'll need that to know the kind of resource. The alternative is to try to parse the YAML sample content for all types to filter based on group/version/kind, but I'm not sure that's practical.
Contributor
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. well, the other option, if you foresee a need to reuse yaml samples for different resources, would be to have two different CRDs:
So you can create a single (1) and then multiple (2)s. but i don't know if that is a valid use case or not. Or even if it's valid, if it would be common enough to be worth the effort over just creating duplicate ConsoleYamlSample objects.
Member
Author
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. Not really sure what would be the use-case for reusing the CR for different resources. type ConsoleYAMLSampleSpec struct {
TargetResource []metav1.TypeMeta `json:",targetResource"`
...Thinking that if it wouldn't make more sense to have a multiple
Member
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. I'm not sure what the use case is for having more than one target resource since the API group / version / kind is also in the YAML. These should almost always match. We do have one edge case in the UI where we show Roles and Cluster Roles in the same sidebar, but I think this pretty rare. There's always the workaround of creating more than one sample. |
||
| // Samples will appear with their descriptions in a samples sidebar | ||
| // when creating a resources in the web console. | ||
| type ConsoleYAMLSampleSpec struct { | ||
|
Member
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. Looks like we're missing a way to specify the target resource apiVersion and kind
Member
Author
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.
Contributor
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. i think that field needs a more obvious name (rather than just inlining it) if that's how you're using it, to make it clear it's defining the resourcetype this sample applies to.
Member
Author
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. Definitely, already added a comment in #465 (comment) |
||
| // targetResource contains apiVersion and kind of the resource | ||
| // YAML sample is representating. | ||
| TargetResource metav1.TypeMeta `json:",targetResource"` | ||
| // title of the YAML sample. | ||
| Title ConsoleYAMLSampleTitle `json:"title"` | ||
| // description of the YAML sample. | ||
| Description ConsoleYAMLSampleDescription `json:"description"` | ||
| // yaml is the YAML sample to display. | ||
| YAML ConsoleYAMLSampleYAML `json:"yaml"` | ||
| } | ||
|
|
||
| // ConsoleYAMLSampleTitle of the YAML sample. | ||
| // +kubebuilder:validation:Pattern=^(.|\s)*\S(.|\s)*$ | ||
| type ConsoleYAMLSampleTitle string | ||
|
|
||
| // ConsoleYAMLSampleDescription of the YAML sample. | ||
| // +kubebuilder:validation:Pattern=^(.|\s)*\S(.|\s)*$ | ||
| type ConsoleYAMLSampleDescription string | ||
|
|
||
| // ConsoleYAMLSampleYAML is the YAML sample to display. | ||
| // +kubebuilder:validation:Pattern=^(.|\s)*\S(.|\s)*$ | ||
| type ConsoleYAMLSampleYAML string | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
||
| type ConsoleYAMLSampleList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| // Standard object's metadata. | ||
| metav1.ListMeta `json:"metadata"` | ||
| Items []ConsoleYAMLSample `json:"items"` | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.