Documentation ¶
Index ¶
- Constants
- func DidSpecifyEnvironmentName(cmd *cobra.Command, args []string) bool
- func EditWorkspaces(ctx context.Context, config *viper.Viper, ...) error
- func GetConfigFilePath(v *viper.Viper) (string, error)
- func GetResourceType(cmd *cobra.Command) (string, error)
- func GetWorkspace(v *viper.Viper, name string) (*workspaces.Workspace, error)
- func HasWorkspace(v *viper.Viper, name string) (bool, error)
- func LoadConfig(configFilePath string) (*viper.Viper, error)
- func LoadConfigNoLock(configFilePath string) (*viper.Viper, error)
- func ReadApplicationName(cmd *cobra.Command, workspace workspaces.Workspace) (string, error)
- func ReadApplicationNameArgs(cmd *cobra.Command, args []string) (string, error)
- func ReadEnvironmentNameArgs(cmd *cobra.Command, args []string) (string, error)
- func ReadResourceGroupNameArgs(cmd *cobra.Command, args []string) (string, error)
- func ReadWorkspaceNameArgs(cmd *cobra.Command, args []string) (string, error)
- func ReadWorkspaceNameSecondArg(cmd *cobra.Command, args []string) (string, error)
- func RequireApplication(cmd *cobra.Command, workspace workspaces.Workspace) (string, error)
- func RequireApplicationArgs(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
- func RequireAzureSubscriptionId(cmd *cobra.Command) (string, error)
- func RequireEnvironmentName(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
- func RequireEnvironmentNameArgs(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
- func RequireEnvironmentNameOrID(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
- func RequireKubeContext(cmd *cobra.Command, currentContext string) (string, error)
- func RequireOutput(cmd *cobra.Command) (string, error)
- func RequireRadYAML(cmd *cobra.Command) (string, error)
- func RequireRecipeNameArgs(cmd *cobra.Command, args []string) (string, error)
- func RequireResource(cmd *cobra.Command, args []string) (resourceType string, resourceName string, err error)
- func RequireResourceGroupNameArgs(cmd *cobra.Command, args []string, workspace *workspaces.Workspace) (string, error)
- func RequireResourceType(args []string) (string, error)
- func RequireResourceTypeAndName(args []string) (string, string, error)
- func RequireScope(cmd *cobra.Command, workspace workspaces.Workspace) (string, error)
- func RequireUCPResourceGroup(cmd *cobra.Command, args []string) (string, error)
- func RequireWorkspace(cmd *cobra.Command, config *viper.Viper, dc *config.DirectoryConfig) (*workspaces.Workspace, error)
- func RequireWorkspaceArgs(cmd *cobra.Command, config *viper.Viper, args []string) (*workspaces.Workspace, error)
- func SaveConfig(v *viper.Viper) error
- func SaveConfigOnLock(ctx context.Context, config *viper.Viper, ...) error
- func UpdateWorkspaceSection(v *viper.Viper, section WorkspaceSection)
- type AzureResource
- type WorkspaceSection
Constants ¶
const ( ApplicationKey string = "application" WorkspacesKey string = "workspaces" )
EnvironmentKey is the key used for the environment section
const (
ResourceTypeFlag = "resource-type"
)
Variables ¶
This section is empty.
Functions ¶
func DidSpecifyEnvironmentName ¶ added in v0.26.0
DidSpecifyEnvironmentName checks if an environment name is provided as a flag
func EditWorkspaces ¶
func EditWorkspaces(ctx context.Context, config *viper.Viper, editor func(section *WorkspaceSection) error) error
EditWorkspaces is a function that allows users to edit the workspaces in a config file. It takes in a context, config and an editor function as parameters. It reads the workspace section from the config, passes it to the editor function and then updates the workspace section in the config. It also checks for case-invariance to prevent duplicates. If an error occurs, it is returned to the caller.
func GetConfigFilePath ¶
GetConfigFilePath attempts to find the user's config file path, first by checking if one has already been set, and if not, by using the user's home directory. If the home directory cannot be found, an error is returned.
func GetResourceType ¶
GetResourceType retrieves the resource type flag from the given command and returns it, or an error if the flag is not set.
func GetWorkspace ¶
GetWorkspace reads the workspace section from the viper configuration and returns the workspace with the given name, or an error if the workspace does not exist or there was an issue reading the configuration.
func HasWorkspace ¶
HasWorkspace reads the workspace section from the given Viper instance and checks if it contains a workspace with the given name. If an error occurs while reading the workspace section, it is returned to the caller.
func LoadConfig ¶
LoadConfig() attempts to read a configuration file from the given path and acquire a shared lock on it. If the file does
not exist, it will be created. If the lock cannot be acquired, an error will be returned.
func LoadConfigNoLock ¶
LoadConfigNoLock reads in a configuration file from the given path and creates it if it doesn't exist. It handles errors
if the file is not found or if there is an issue reading it.
func ReadApplicationName ¶
ReadApplicationName reads the application name from the command line flag and, if not provided, from the workspace configuration. It returns an error if the flag is not set correctly.
func ReadApplicationNameArgs ¶
ReadApplicationNameArgs reads the application name from either the command line arguments or the "-a" flag, and returns an error if both are specified.
func ReadEnvironmentNameArgs ¶
ReadEnvironmentNameArgs reads the environment name from either the command line arguments or the "-e" flag, and returns an error if both are specified.
func ReadResourceGroupNameArgs ¶
ReadResourceGroupNameArgs reads a resource group name from either a command flag or an argument, and returns an error if
both are specified.
func ReadWorkspaceNameArgs ¶
ReadWorkspaceNameArgs reads a workspace name from either a command flag or an argument, and returns an error if both are
specified.
func ReadWorkspaceNameSecondArg ¶
ReadWorkspaceNameSecondArg checks if a workspace name is provided via a flag or as the second argument in the command, and returns an error if both are specified.
func RequireApplication ¶
RequireApplication requires the user to provide an application name as an argument and returns it as a string. If the user does not provide an application name, an error is returned.
func RequireApplicationArgs ¶
func RequireApplicationArgs(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
RequireApplicationArgs checks if an application name is provided as an argument, and if not, checks if a default application is set in the workspace. If no application name is provided, it returns an error.
func RequireAzureSubscriptionId ¶
RequireAzureSubscriptionId is used by commands that require specifying an Azure subscriptionId using a flag
func RequireEnvironmentName ¶
func RequireEnvironmentName(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
RequireEnvironmentName checks if an environment name is provided as a flag or as a default environment in the workspace, and returns an error if neither is present. It also handles any errors that occur while parsing the resource.
func RequireEnvironmentNameArgs ¶
func RequireEnvironmentNameArgs(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
RequireEnvironmentNameArgs checks if an environment name is provided as an argument or if a default environment is set in the workspace, and returns an error if neither is the case. It also handles any errors that may occur while parsing the environment resource.
func RequireEnvironmentNameOrID ¶ added in v0.38.0
func RequireEnvironmentNameOrID(cmd *cobra.Command, args []string, workspace workspaces.Workspace) (string, error)
RequireEnvironmentNameOrID checks if an environment name or ID is provided as a flag or as a default environment in the workspace, and returns an error if neither is present. It also handles any errors that occur while parsing the resource.
func RequireKubeContext ¶
RequireKubeContext checks if a kubecontext is provided as a flag, and if not, uses the current context. If neither is provided, it returns an error.
func RequireRadYAML ¶
RequireRadYAML checks if a radfile flag is provided and if not, returns the default rad.yaml file in the current directory. If an error occurs, it is returned to the caller.
func RequireRecipeNameArgs ¶
RequireRecipeNameArgs checks if the provided arguments contain at least one string, and if not, returns an error. If the
arguments contain a string, it is returned.
func RequireResource ¶
func RequireResource(cmd *cobra.Command, args []string) (resourceType string, resourceName string, err error)
RequireResource parses the given command and arguments to extract two required values, a resource type and a resource name, and returns them. If either of the values is missing, an error is returned.
func RequireResourceGroupNameArgs ¶ added in v0.38.0
func RequireResourceGroupNameArgs(cmd *cobra.Command, args []string, workspace *workspaces.Workspace) (string, error)
RequireResourceGroupNameArgs is used by commands that require a resource group name to be specified. If no group is passed then the default workspace group is used.
func RequireResourceType ¶
RequireResourceType checks if the first argument provided is a valid resource type and returns it if it is. If the argument is not valid, an error is returned with a list of valid resource types.
Example of resource Type: Applications.Datastores/redisCaches
func RequireResourceTypeAndName ¶
RequireResourceTypeAndName checks if the provided arguments contain a resource type and name, and returns them if they are present. If either is missing, an error is returned.
func RequireScope ¶
RequireScope checks if a resource group is passed in as a flag and returns the scope of the resource group if it is, otherwise it returns the scope of the workspace if it is set, otherwise it returns an error.
func RequireUCPResourceGroup ¶
RequireUCPResourceGroup reads the resource group name from the command line arguments and returns an error if the name is not provided or is empty. It also handles any errors that may occur while reading the resource group name.
func RequireWorkspace ¶
func RequireWorkspace(cmd *cobra.Command, config *viper.Viper, dc *config.DirectoryConfig) (*workspaces.Workspace, error)
RequireWorkspace reads the workspace name from the command flags, retrieves the workspace from the configuration, and returns it, or a fallback workspace if none is found. It also handles any errors that may occur during the process.
func RequireWorkspaceArgs ¶
func RequireWorkspaceArgs(cmd *cobra.Command, config *viper.Viper, args []string) (*workspaces.Workspace, error)
RequireWorkspaceArgs reads the workspace name from the command line arguments, retrieves the workspace from the configuration, and returns it. If the workspace is not found, it returns a fallback workspace. If any errors occur, it returns an error.
func SaveConfig ¶
SaveConfig saves the configuration to the file path specified in the viper instance. It returns an error if the file path is not found or if the configuration could not be written.
func SaveConfigOnLock ¶
func SaveConfigOnLock(ctx context.Context, config *viper.Viper, updateConfig func(*viper.Viper) error) error
SaveConfigOnLock acquires an exclusive lock on the config file and updates it with the given config, retrying every second for 5 times if another goroutine is holding the lock. It returns an error if it fails to acquire the lock or if the updateConfig function fails.
func UpdateWorkspaceSection ¶
func UpdateWorkspaceSection(v *viper.Viper, section WorkspaceSection)
UpdateWorkspaceSection updates the WorkspacesKey in the given viper instance with the given WorkspaceSection.
Types ¶
type AzureResource ¶
type AzureResource struct { Name string ResourceType string ResourceGroup string SubscriptionID string }
func RequireAzureResource ¶
func RequireAzureResource(cmd *cobra.Command, args []string) (azureResource AzureResource, err error)
"RequireAzureResource" takes in a command and a slice of strings and returns an AzureResource object and an error. It uses the "requiredMultiple" function to get the values of the required parameters and then creates an AzureResource object with those values. If any of the required parameters are missing, it returns an error.
type WorkspaceSection ¶
type WorkspaceSection struct { Default string `json:"default" mapstructure:"default" yaml:"default"` Items map[string]workspaces.Workspace `json:"items" mapstructure:"items" yaml:"items" validate:"dive"` }
func ReadWorkspaceSection ¶
func ReadWorkspaceSection(v *viper.Viper) (WorkspaceSection, error)
ReadWorkspaceSection reads the WorkspaceSection from the given viper instance, validates it and returns it. If the WorkspaceSection is not present, an empty one is returned. If any errors occur during validation, an error is returned.
func (WorkspaceSection) GetWorkspace ¶
func (ws WorkspaceSection) GetWorkspace(name string) (*workspaces.Workspace, error)
GetWorkspace checks if the given workspace name is empty and if so, checks if a default workspace is set. If a workspace name is provided, it looks up the workspace in the Items map and returns it. If the workspace does not exist, it returns an error.
func (WorkspaceSection) HasWorkspace ¶
func (ws WorkspaceSection) HasWorkspace(name string) bool
HasWorkspace returns true if the specified workspace already exists. This function ignores the default workspace.
Directories ¶
Path | Synopsis |
---|---|
Package azure is a generated GoMock package.
|
Package azure is a generated GoMock package. |
bicep contains functionality for working with the Bicep compiler as well as ARM-JSON templates.
|
bicep contains functionality for working with the Bicep compiler as well as ARM-JSON templates. |
Package clients is a generated GoMock package.
|
Package clients is a generated GoMock package. |
clients_new
|
|
clierrors defines error types that are useful in the CLI for customizing the experience when a failure occurs.
|
clierrors defines error types that are useful in the CLI for customizing the experience when a failure occurs. |
env/namespace
Package namespace is a generated GoMock package.
|
Package namespace is a generated GoMock package. |
radinit
Package radinit is a generated GoMock package.
|
Package radinit is a generated GoMock package. |
config contains functionality for reading Radius' configuration and interacting with it.
|
config contains functionality for reading Radius' configuration and interacting with it. |
connections contains functionality for using the workspace.Connection concept of the CLI to connect and interact with the remote endpoints that are described by the workspace concept (Radius control plane, environment, et al).
|
connections contains functionality for using the workspace.Connection concept of the CLI to connect and interact with the remote endpoints that are described by the workspace concept (Radius control plane, environment, et al). |
Package credential is a generated GoMock package.
|
Package credential is a generated GoMock package. |
deploy contains reusable infrastructure for Bicep deployments.
|
deploy contains reusable infrastructure for Bicep deployments. |
Package framework is a generated GoMock package.
|
Package framework is a generated GoMock package. |
Package helm is a generated GoMock package.
|
Package helm is a generated GoMock package. |
Package kubernetes is a generated GoMock package.
|
Package kubernetes is a generated GoMock package. |
logstream
logstream contains functionality for streaming logs for an entire application from Kubernetes.
|
logstream contains functionality for streaming logs for an entire application from Kubernetes. |
portforward
portforward contains functionality for port-forwarding an entire application from Kubernetes.
|
portforward contains functionality for port-forwarding an entire application from Kubernetes. |
manifest contains the parsing and validation logic for a resource provider manifest.
|
manifest contains the parsing and validation logic for a resource provider manifest. |
Package output is a generated GoMock package.
|
Package output is a generated GoMock package. |
Package prompt is a generated GoMock package.
|
Package prompt is a generated GoMock package. |
package setup contains support functions for programmatically installing and uninstalling Radius.
|
package setup contains support functions for programmatically installing and uninstalling Radius. |
workspaces contains functionality for using the workspace concept of the CLI to store data related to the remote endpoints that are described by the workspace concept (Radius control plane, environment, et al).
|
workspaces contains functionality for using the workspace concept of the CLI to store data related to the remote endpoints that are described by the workspace concept (Radius control plane, environment, et al). |