-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First sketch of refactored commands (#3)
Signed-off-by: David Festal <dfestal@redhat.com>
- Loading branch information
1 parent
0253a4f
commit 08aef13
Showing
6 changed files
with
530 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,114 @@ | ||
package v1alpha1 | ||
|
||
type Command struct { | ||
Actions []CommandAction `json:"actions,omitempty"` // List of the actions of given command. Now the only one command must be specified in list; but there are plans to implement supporting multiple actions commands. | ||
import runtime "k8s.io/apimachinery/pkg/runtime" | ||
|
||
// CommandType describes the type of command. | ||
// Only one of the following command type may be specified. | ||
// +kubebuilder:validation:Enum=Exec;VscodeTask;VscodeLaunch;Custom | ||
type CommandType string | ||
|
||
const ( | ||
ExecCommandType CommandType = "Exec" | ||
VscodeTaskCommandType CommandType = "VscodeTask" | ||
VscodeLaunchCommandType CommandType = "VscodeLaunch" | ||
CompositeCommandType CommandType = "Composite" | ||
CustomCommandType CommandType = "Custom" | ||
) | ||
|
||
type BaseCommand struct { | ||
Alias string `json:"alias,omitempty"` | ||
Attributes map[string]string `json:"attributes,omitempty"` // Additional command attributes | ||
Name string `json:"name"` // Describes the name of the command. Should be unique per commands set. | ||
} | ||
|
||
type CommandAction struct { | ||
Command *string `json:"command,omitempty"` // The actual action command-line string | ||
Component *string `json:"component,omitempty"` // Describes component to which given action relates | ||
Type string `json:"type"` // Describes action type | ||
Workdir *string `json:"workdir,omitempty"` // Working directory where the command should be executed | ||
Reference *string `json:"reference,omitempty"` // Working directory where the command should be executed | ||
ReferenceContent *string `json:"referenceContent,omitempty"` // Working directory where the command should be executed | ||
type LabeledCommand struct { | ||
BaseCommand `json:",inline"` | ||
Label string `json:"label,omitempty"` | ||
} | ||
|
||
type Command struct { | ||
PolymorphicCommand `json:",inline"` | ||
} | ||
|
||
// +k8s:openapi-gen=true | ||
// +union | ||
type PolymorphicCommand struct { | ||
// Type of workspace command | ||
// +unionDiscriminator | ||
// +optional | ||
Type CommandType `json:"type"` | ||
|
||
// Exec command | ||
// +optional | ||
Exec *ExecCommand `json:"exec,omitempty"` | ||
|
||
// VscodeTask command | ||
// +optional | ||
VscodeTask *VscodeConfigurationCommand `json:"vscodeTask,omitempty"` | ||
|
||
// VscodeLaunch command | ||
// +optional | ||
VscodeLaunch *VscodeConfigurationCommand `json:"vscodeLaunch,omitempty"` | ||
|
||
// Composite command | ||
// +optional | ||
Composite *CompositeCommand `json:"composite,omitempty"` | ||
|
||
// Custom command | ||
// +optional | ||
Custom *CustomCommand `json:"custom,omitempty"` | ||
} | ||
|
||
type ExecCommand struct { | ||
LabeledCommand `json:",inline"` | ||
|
||
// The actual command-line string | ||
CommandLine string `json:"commandLine"` | ||
|
||
// Describes component to which given action relates | ||
Component string `json:"component,omitempty"` | ||
|
||
// Working directory where the command should be executed | ||
Workdir *string `json:"workdir,omitempty"` | ||
} | ||
|
||
type CompositeCommand struct { | ||
LabeledCommand `json:",inline"` | ||
|
||
// The commands that comprise this composite command | ||
Commands []string `json:"commands,omitempty"` | ||
|
||
// +optional | ||
Parallel bool `json:"parallel,omitempty"` | ||
} | ||
|
||
// +k8s:openapi-gen=true | ||
// +union | ||
type VscodeConfigurationCommandLocation struct { | ||
// Type of Vscode configuration command location | ||
// + | ||
// +unionDiscriminator | ||
// +optional | ||
LocationType string `json:"locationType"` | ||
|
||
// Location as an absolute of relative URL | ||
// +optional | ||
Url string `json:"url,omitempty"` | ||
|
||
// Embedded content of the vscode configuration file | ||
// +optional | ||
Inlined string `json:"inlined,omitempty"` | ||
} | ||
|
||
type VscodeConfigurationCommand struct { | ||
BaseCommand `json:",inline"` | ||
Location VscodeConfigurationCommandLocation `json:",inline"` | ||
} | ||
|
||
type CustomCommand struct { | ||
LabeledCommand `json:",inline"` | ||
CommandClass string `json:"commandClass"` | ||
|
||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:EmbeddedResource | ||
EmbeddedResource runtime.RawExtension `json:"embeddedResource"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.