Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions console/v1/0000_10_consoleyamlsample.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ spec:
description: description of the YAML sample.
type: string
pattern: ^(.|\s)*\S(.|\s)*$
snippet:
description: snippet indicates that the YAML sample is not the full
YAML resource definition, but a fragment that can be inserted into
the existing YAML document at the user's cursor.
type: boolean
targetResource:
description: targetResource contains apiVersion and kind of the resource
YAML sample is representating.
Expand Down
5 changes: 5 additions & 0 deletions console/v1/types_console_yaml_sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ type ConsoleYAMLSampleSpec struct {
Description ConsoleYAMLSampleDescription `json:"description"`
// yaml is the YAML sample to display.
YAML ConsoleYAMLSampleYAML `json:"yaml"`
// snippet indicates that the YAML sample is not the full YAML resource
Copy link
Contributor

Choose a reason for hiding this comment

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

So this implies its a snippet that can be injected into whatever bit of yaml is already loaded into the window? I assume if there is no yaml loaded it can't be injected? would it overwrite existing bits of yaml if there is a collision?

Choose a reason for hiding this comment

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

The snippets currently are coded to be a YAML insert rather than a YAML replace. So if you have "no content" (a blank YAML) the snippet would just insert the lines as the first set of content.

It does no validation when being inserted.

Choose a reason for hiding this comment

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

I should note, it will replace any highlighted text as well. So if you select all your YAML and do an insert of a snippet - it'll effectively replace the content. Which likely is not the desire, since a snippet is unlikely to have the necessary top-level properties to work (but nothing stops it from doing so).

It's an open ended addition to the way Samples work. They exist as another tab in the UI so one can pick from samples or snippets independently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Sounds like could be a bit gnarly usability at first, but fine once you get the hang of it.

// definition, but a fragment that can be inserted into the existing
// YAML document at the user's cursor.
// +optional
Snippet bool `json:"snippet"`
}

// ConsoleYAMLSampleTitle of the YAML sample.
Expand Down
1 change: 1 addition & 0 deletions console/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.