cli

package
v0.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationKey string = "application"
	WorkspacesKey  string = "workspaces"
)

EnvironmentKey is the key used for the environment section

View Source
const (
	ResourceTypeFlag = "resource-type"
)

Variables

This section is empty.

Functions

func DidSpecifyEnvironmentName added in v0.26.0

func DidSpecifyEnvironmentName(cmd *cobra.Command, args []string) bool

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

func GetConfigFilePath(v *viper.Viper) (string, error)

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

func GetResourceType(cmd *cobra.Command) (string, error)

GetResourceType retrieves the resource type flag from the given command and returns it, or an error if the flag is not set.

func GetWorkspace

func GetWorkspace(v *viper.Viper, name string) (*workspaces.Workspace, error)

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

func HasWorkspace(v *viper.Viper, name string) (bool, error)

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

func LoadConfig(configFilePath string) (*viper.Viper, error)

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

func LoadConfigNoLock(configFilePath string) (*viper.Viper, error)

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

func ReadApplicationName(cmd *cobra.Command, workspace workspaces.Workspace) (string, error)

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

func ReadApplicationNameArgs(cmd *cobra.Command, args []string) (string, error)

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

func ReadEnvironmentNameArgs(cmd *cobra.Command, args []string) (string, error)

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

func ReadResourceGroupNameArgs(cmd *cobra.Command, args []string) (string, error)

ReadResourceGroupNameArgs reads a resource group name from either a command flag or an argument, and returns an error if

both are specified.

func ReadWorkspaceNameArgs

func ReadWorkspaceNameArgs(cmd *cobra.Command, args []string) (string, error)

ReadWorkspaceNameArgs reads a workspace name from either a command flag or an argument, and returns an error if both are

specified.

func ReadWorkspaceNameSecondArg

func ReadWorkspaceNameSecondArg(cmd *cobra.Command, args []string) (string, error)

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

func RequireApplication(cmd *cobra.Command, workspace workspaces.Workspace) (string, error)

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

func RequireAzureSubscriptionId(cmd *cobra.Command) (string, error)

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 RequireKubeContext

func RequireKubeContext(cmd *cobra.Command, currentContext string) (string, error)

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 RequireOutput

func RequireOutput(cmd *cobra.Command) (string, error)

func RequireRadYAML

func RequireRadYAML(cmd *cobra.Command) (string, error)

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

func RequireRecipeNameArgs(cmd *cobra.Command, args []string) (string, error)

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 RequireResourceType

func RequireResourceType(args []string) (string, error)

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.

func RequireResourceTypeAndName

func RequireResourceTypeAndName(args []string) (string, string, error)

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

func RequireScope(cmd *cobra.Command, workspace workspaces.Workspace) (string, error)

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

func RequireUCPResourceGroup(cmd *cobra.Command, args []string) (string, error)

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

func SaveConfig(v *viper.Viper) error

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.
cmd
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.
run
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.
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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL