Documentation ¶
Overview ¶
Package framework defines the integration and end-to-end test case for cli core
Package framework defines the integration and end-to-end test case for cli core ¶
Package framework defines the integration and end-to-end test case for cli core ¶
Package framework defines the integration and end-to-end test case for cli core
Index ¶
- Constants
- Variables
- func ApplyConfigOnKindCluster(tf *Framework, clusterInfo *ClusterInfo, confFilePaths []string) error
- func CLICoreDescribe(text string, body func()) bool
- func CheckAllPluginsExists(superList, subList []*PluginInfo) bool
- func CleanConfigFiles(tf *Framework) error
- func ContainsAnyString(stdOut *bytes.Buffer, contains []string) error
- func ContainsString(stdOut *bytes.Buffer, contains string) error
- func ContextInfoToMap(ctxs []*ContextListInfo) map[string]*ContextListInfo
- func CreateDir(dir string) error
- func CreateOrTruncateFile(filePath string) error
- func ExecuteCmdAndBuildJSONOutput[...](cmdExe CmdOps, cmd string, opts ...E2EOption) ([]*T, string, string, error)
- func GetAvailableContexts(tf *Framework, contextNames []string) []string
- func GetE2EHomeDir() string
- func GetHTTPCall(url string, v interface{}) error
- func GetHomeDir() string
- func GetMapKeyForPlugin(pluginsList *PluginInfo) string
- func GetMapKeys[K string, V *PluginInfo](m map[K][]V) []*K
- func GetPluginGroupWhichStartsWithGivenPrefix(pgs []*PluginGroup, prefix string) string
- func IsAllPluginGroupsExists(superList, subList []*PluginGroup) bool
- func IsContextExists(tf *Framework, contextName string, opts ...E2EOption) bool
- func IsPluginExists(pluginList []*PluginInfo, plugin *PluginInfo, pluginInstallationStatus string) bool
- func IsPluginSourceExists(list []*PluginSourceInfo, sourceName string) bool
- func LegacyPluginListToMap(pluginsList []*PluginInfo) map[string]*PluginInfo
- func LogConfigFiles() error
- func LogFile(file string) error
- func NotContainsString(stdOut *bytes.Buffer, contains string) error
- func PluginGroupToMap(pluginGroups []*PluginGroup) map[string]*PluginGroup
- func PluginListToMap(pluginsList []*PluginInfo) map[string]*PluginInfo
- func PluginListToSet(pluginsToInstall []*PluginInfo) map[string]struct{}
- func RandomNumber(length int) string
- func RandomString(length int) string
- func SliceToSet(slice []string) map[string]struct{}
- func StartMockServer(tf *Framework, mappingDir, containerName string) error
- func StopContainer(tf *Framework, containerName string) error
- func UpdatePluginDiscoverySource(tf *Framework, repoURL string) error
- func WriteToFileInJSONFormat(input any, filePath string) error
- type Artifact
- type ArtifactList
- type CLIOption
- type CLIOptions
- type CLIPlugin
- type CLIPluginSpec
- type CertAddOptions
- type CertDetails
- type CliOps
- type ClusterInfo
- type ClusterOps
- type CmdOps
- type ConfigCertOps
- type ConfigCmdOps
- type ConfigLifecycleOps
- type ContainerRuntime
- type ContextCmdOps
- type ContextCreateOps
- type ContextInfo
- type ContextListInfo
- type DiscoveryOptions
- type Docker
- type E2EOption
- type E2EOptions
- type Framework
- type GeneratePluginOps
- type ImgpkgOps
- type KindCluster
- type PluginBasicOps
- type PluginCmdOps
- type PluginDescribe
- type PluginDownloadAndUploadOps
- type PluginGroup
- type PluginGroupGet
- type PluginGroupOps
- type PluginHelperOps
- type PluginInfo
- func CreateTemporaryCRsFromPluginInfos(plugins []*PluginInfo) ([]*PluginInfo, []string, error)
- func GetGivenPluginFromTheGivenPluginList(pluginList []*PluginInfo, requiredPlugin *PluginInfo) *PluginInfo
- func GetInstalledPlugins(pluginList []*PluginInfo) []*PluginInfo
- func GetPluginFromFirstListButNotExistsInSecondList(first, second []*PluginInfo) (*PluginInfo, error)
- func GetPluginsList(tf *Framework, installedOnly bool) ([]*PluginInfo, error)
- type PluginMeta
- func (p *PluginMeta) GetName() string
- func (p *PluginMeta) GetRegistryDiscoveryURL() string
- func (p *PluginMeta) SetAliases(alias []string) *PluginMeta
- func (p *PluginMeta) SetArch(arch string) *PluginMeta
- func (p *PluginMeta) SetDescription(description string) *PluginMeta
- func (p *PluginMeta) SetDiscoveryType(discoveryType string) *PluginMeta
- func (p *PluginMeta) SetGroup(group string) *PluginMeta
- func (p *PluginMeta) SetHidden(hidden bool) *PluginMeta
- func (p *PluginMeta) SetName(name string) *PluginMeta
- func (p *PluginMeta) SetOS(osType string) *PluginMeta
- func (p *PluginMeta) SetOptional(optional bool) *PluginMeta
- func (p *PluginMeta) SetSHA(sha string) *PluginMeta
- func (p *PluginMeta) SetTarget(target string) *PluginMeta
- func (p *PluginMeta) SetVersion(version string) *PluginMeta
- type PluginRegistry
- type PluginSearch
- type PluginSourceInfo
- type PluginSourceOps
- type PublishPluginOps
- type Server
- type TMCPlugin
- type TMCPluginsInfo
- type TMCPluginsMockRequestResponseMapping
- type TMCPluginsResponse
Constants ¶
const ( ConfigFileName = "config.yaml" ConfigNGFileName = "config-ng.yaml" ConfigFileDir = ".config/tanzu/" )
const ( CliCore = "[CLI-Core]" TargetList = "kubernetes[k8s]/mission-control[tmc]/global" InitCmd = "%s init" VersionCmd = "%s version" CompletionCmd = "%s completion" CobraCompleteCmd = "%s __complete ''" TanzuPrefix = "tanzu" TzPrefix = "tz" // Config commands ConfigCmd = "%s config" ConfigSet = "%s config set " ConfigGet = "%s config get" ConfigUnset = "%s config unset " ConfigInit = "%s config init" ConfigCertAdd = "%s config cert add --host %s --ca-cert %s --skip-cert-verify %s --insecure %s" ConfigCertDelete = "%s config cert delete %s" ConfigCertList = "%s config cert list -o json" // Plugin commands UpdatePluginSource = "%s plugin source update %s --uri %s" ListPluginSourcesWithJSONOutputFlag = "%s plugin source list -o json" DeletePluginSource = "%s plugin source delete %s" InitPluginDiscoverySource = "%s plugin source init" ListPluginsCmdWithJSONOutputFlag = "%s plugin list -o json" SearchPluginsCmd = "%s plugin search" SearchPluginGroupsCmd = "%s plugin group search" GetPluginGroupCmd = "%s plugin group get %s" InstallPluginCmd = "%s plugin install %s" InstallPluginFromGroupCmd = "%s plugin install %s --group %s" InstallAllPluginsFromGroupCmd = "%s plugin install --group %s" DescribePluginCmd = "%s plugin describe %s" UninstallPLuginCmd = "%s plugin uninstall %s --yes" CleanPluginsCmd = "%s plugin clean" PluginDownloadBundleCmd = "%s plugin download-bundle" PluginUploadBundleCmd = "%s plugin upload-bundle" PluginCmdWithOptions = "%s plugin " JSONOutput = " -o json" TestPluginsPrefix = "test-plugin-" PluginSubCommand = "%s %s" PluginKey = "%s_%s_%s" // Plugins - Name_Target_Versions LegacyPluginKey = "%s_%s" // Plugins - Name_Target_Versions or Name_Version_Status for legacy cli plugins // Central repository TanzuCliE2ETestCentralRepositoryURL = "TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL" TanzuCliE2ETestLocalCentralRepositoryURL = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL" TanzuCliE2ETestLocalCentralRepositoryPluginDiscoveryImageSignaturePublicKeyPath = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH" TanzuCliPluginDiscoveryImageSignaturePublicKeyPath = "TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH" TanzuCliE2ETestLocalCentralRepositoryHost = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_HOST" TanzuCliE2ETestLocalCentralRepositoryCACertPath = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_CA_CERT_PATH" TanzuCliE2ETestAirgappedRepo = "TANZU_CLI_E2E_AIRGAPPED_REPO" TanzuCliE2ETestAirgappedRepoWithAuth = "TANZU_CLI_E2E_AIRGAPPED_REPO_WITH_AUTH" TanzuCliE2ETestAirgappedRepoWithAuthUsername = "TANZU_CLI_E2E_AIRGAPPED_REPO_WITH_AUTH_USERNAME" TanzuCliE2ETestAirgappedRepoWithAuthPassword = "TANZU_CLI_E2E_AIRGAPPED_REPO_WITH_AUTH_PASSWORD" TanzuCliPluginDiscoverySignatureVerificationSkipList = "TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST" // CLI Coexistence CLICoexistenceLegacyTanzuCLIInstallationPath = "TANZU_CLI_COEXISTENCE_LEGACY_TANZU_CLI_DIR" CLICoexistenceNewTanzuCLIInstallationPath = "TANZU_CLI_COEXISTENCE_NEW_TANZU_CLI_DIR" CLICoexistenceLegacyTanzuCLIVersion = "TANZU_CLI_COEXISTENCE_LEGACY_TANZU_CLI_VERSION" CLICoexistenceNewTanzuCLIVersion = "TANZU_CLI_BUILD_VERSION" CLICoexistenceTanzuCEIPParticipation = "TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER" CLIEulaParticipation = "TANZU_CLI_EULA_PROMPT_ANSWER" // This skips hardcoding HTTPS in CLI Core when the E2E tests mock the TMC endpoint CLIE2ETestEnvironment = "TANZU_CLI_E2E_TEST_ENVIRONMENT" // General constants True = "true" Installed = "installed" UpdateAvailable = "update available" NotInstalled = "not installed" JSONOtuput = "-o json" // Context commands CreateContextWithEndPoint = "%s context create --endpoint %s %s" CreateContextWithEndPointStaging = "%s context create --endpoint %s --staging %s" CreateContextWithKubeconfigFile = "%s context create --kubeconfig %s --kubecontext %s %s" CreateContextWithDefaultKubeconfigFile = "%s context create --kubecontext %s %s" UseContext = "%s context use %s" UnsetContext = "%s context unset" GetContext = "%s context get %s" ListContextOutputInJSON = "%s context list -o json" DeleteContext = "%s context delete %s --yes" TanzuAPIToken = "TANZU_API_TOKEN" //nolint:gosec TanzuCliTmcUnstableURL = "TANZU_CLI_TMC_UNSTABLE_URL" // context specific ContextShouldNotExists = "the context %s should not exists" ContextShouldExistsAsCreated = "the context %s should exists as its been created" ContextNotExistsForTarget = "The provided context '%v' does not exist or is not active for the given context type '%v'" NoActiveContextExistsForContextType = "There is no active context for the given context type '%v'" ContextNotActiveOrNotExists = "The provided context '%v' is not active or does not exist" ContextForContextTypeSetInactive = "The context '%v' of type '%v' has been set as inactive" DeactivatingPlugin = "Deactivating plugin '%v:%v' for context '%v'" KindClusterCreate = "kind create cluster --name %s" KindClusterStatus = "kubectl cluster-info --context %s" KindClusterDelete = "kind delete cluster --name %s" KindClusterGet = "kind get clusters " KindClusterInfo = "kubectl cluster-info --context %s" KubectlApply = "kubectl --context %s apply -f %s" // specific plugin custom resource file name cr_<pluginName>_<target>_<versions>.yaml to apply on kind cluster PluginCRFileName = "cr_%s_%s_%s.yaml" KindCreateCluster = "kind create cluster --name " DockerInfo = "docker info" StartDockerUbuntu = "sudo systemctl start docker" StopDockerUbuntu = "sudo systemctl stop docker" TMC = "tmc" TKG = "tkg" SourceType = "oci" GlobalTarget = "global" KubernetesTarget = "kubernetes" MissionControlTarget = "mission-control" TMCPluginGroupPrefix = "vmware-tmc" K8SPluginGroupPrefix = "vmware-tkg" EssentialsPluginGroupPrefix = "vmware-tanzucli" // log info ExecutingCommand = "Executing command: %s" FileContent = "file: %s , content: %s" // Error messages UnableToFindPluginForTarget = "unable to find plugin '%s' matching version '%s'" UnableToFindPluginWithVersionForTarget = "unable to find plugin '%s' matching version '%s' for target '%s'" UnableToFindPlugin = "unable to find plugin '%s'" InvalidTargetSpecified = "invalid target specified. Please specify a correct value for the `--target` flag from '" + TargetList + "'" InvalidTargetGlobal = "invalid target for plugin: global" DiscoverySourceNotFound = "discovery %q does not exist" ErrorLogForCommandWithErrStdErrAndStdOut = "error while executing command:'%s', error:'%s' stdErr:'%s' stdOut: '%s'" FailedToConstructJSONNodeFromOutputAndErrInfo = "failed to construct json node from output:'%s' error:'%s' " FailedToConstructJSONNodeFromOutput = "failed to construct json node from output:'%s'" NoErrorForPluginGroupSearch = "should not get any error for plugin group search" NoErrorForPluginGroupGet = "should not get any error for plugin group get" NoErrorForPluginSearch = "should not get any error for plugin search" PluginSearchOutputShouldBeSortedByName = "plugin search output should be sorted by name" UnableToSync = "unable to automatically sync the plugins from target context. Please run 'tanzu plugin sync' command to sync plugins manually" PluginDescribeShouldNotThrowErr = "should not get any error for plugin describe" PluginDescShouldExist = "there should be one plugin description" PluginNameShouldMatch = "plugin name should be same as input value" CompletionWithoutShell = "shell not specified, choose one of: bash, zsh, fish, powershell" CompletionOutputForBash = "bash completion V2 for tanzu" CompletionOutputForZsh = "zsh completion for tanzu" CompletionOutputForFish = "fish completion for tanzu" CompletionOutputForPowershell = "powershell completion for tanzu" FailedToRunCompletionCmd = "failed to run completion command: %s, stdout: %s" FailedToRunCmd = "failed to run command: %s, stdout: %s" // config related constants FailedToCreateContext = "failed to create context" FailedToCreateContextWithStdout = FailedToCreateContext + ", stdout:%s" ContextCreated = "context %s created successfully" ContextDeleted = "context %s deleted successfully" FailedToDeleteContext = "failed to delete context" ContextPrefixK8s = "plugin-sync-k8s-" ContextPrefixTMC = "plugin-sync-tmc-" // TestDir is the directory under $HOME, created during framework initialization, and the $HOME updated as $HOME/$TestDir, to create all Tanzu CLI specific files // and not to disturb any existing Tanzu CLI files TestDir = ".tanzu-cli-e2e" // TestPluginsDir is the directory under $HOME/$TestDir, to store test plugins for E2E tests TestPluginsDir = ".e2e-test-plugins" // TempDirInTestDirPath is the directory under $HOME/$TestDir, to create temporary files (if any) for E2E test execution TempDirInTestDirPath = "temp" ConfigFolder = ".config" TanzuFolder = "tanzu" TanzuPluginsFolder = "tanzu-plugins" ConfigFile = "config.yaml" ConfigNGFile = "config-ng.yaml" K8SCRDFileName = "cli.tanzu.vmware.com_cliplugins.yaml" Config = "config" TanzuCLIE2ETestBinaryPath = "TANZU_CLI_E2E_TEST_BINARY_PATH" WiredMockHTTPServerStartCmd = "docker run --rm -d -p 8080:8080 -p 8443:8443 --name %s -v %s:/home/wiremock rodolpheche/wiremock:2.25.1" HTTPMockServerStopCmd = "docker container stop %s" HTTPMockServerName = "wiremock" TMCEndpointForPlugins = "/v1alpha1/system/binaries/plugins" TMCMockServerEndpoint = "http://localhost:8080" TMCPluginsMockServerEndpoint = "http://localhost:8080/v1alpha1/system/binaries/plugins" HTTPContentType = "application/json; charset=utf-8" // k8s CRD file K8SCRDFilePath = "../../config_data/cli.tanzu.vmware.com_cliplugins.yaml" )
const ( DefaultCLIPluginBucket = "/tkg/tanzu_core/tanzu-cli-plugins/" DefaultRegistryName = "registry" DefaultRegistryPort = "5001" )
const CRTemplate = `` /* 190-byte string literal not displayed */
const GeneratedValuesTemplate = `#@data/values
#@overlay/match-child-defaults missing_ok=True
---`
const ImagesTemplate = `---
apiVersion: imgpkg.carvel.dev/v1alpha1
images:
kind: ImagesLock`
const ScriptBasedPluginTemplate = `` /* 491-byte string literal not displayed */
Variables ¶
var ( // TestDirPath is the absolute directory path for the E2E test execution uses to create all Tanzu CLI specific files (config, local plugins etc) TestDirPath string TestPluginsDirPath string TestStandalonePluginsPath string // FullPathForTempDir is the absolute path for the temp directory under $TestDir FullPathForTempDir string // OriginalHomeDir is the actual HOME directory of the machine before E2E test overwrites it OriginalHomeDir string // TestHomeDir is the HOME directory during E2E test execution TestHomeDir string // ConfigFilePath represents config.yaml file path which under $HOME/.tanzu-cli-e2e/.config/tanzu ConfigFilePath string // ConfigFilePath represents config-ng.yaml file path which under $HOME/.tanzu-cli-e2e/.config/tanzu ConfigNGFilePath string TanzuFolderPath string TanzuBinary string // Tanzu binary name if available in PATH variable or full path to binary with tanzu name )
Functions ¶
func ApplyConfigOnKindCluster ¶
func ApplyConfigOnKindCluster(tf *Framework, clusterInfo *ClusterInfo, confFilePaths []string) error
ApplyConfigOnKindCluster applies the config files on kind cluster
func CLICoreDescribe ¶
CLICoreDescribe annotates the test with the CLICore label.
func CheckAllPluginsExists ¶
func CheckAllPluginsExists(superList, subList []*PluginInfo) bool
CheckAllPluginsExists checks all PluginInfo's in subList are available in superList superList is the super set, subList is sub set
func CleanConfigFiles ¶
CleanConfigFiles deletes the tanzu CLI config files and initializes the tanzu CLI config
func ContainsAnyString ¶
ContainsAnyString checks that the given buffer contains any of the given set of strings.
func ContainsString ¶
ContainsString checks that the given buffer contains the string.
func ContextInfoToMap ¶
func ContextInfoToMap(ctxs []*ContextListInfo) map[string]*ContextListInfo
ContextInfoToMap takes the contexts list, and returns the map with context name as key and context info as value
func CreateOrTruncateFile ¶
CreateOrTruncateFile creates a given file if not exists
func ExecuteCmdAndBuildJSONOutput ¶
func ExecuteCmdAndBuildJSONOutput[T PluginInfo | PluginSearch | PluginGroup | PluginGroupGet | PluginSourceInfo | types.ClientConfig | Server | ContextListInfo | CertDetails | PluginDescribe](cmdExe CmdOps, cmd string, opts ...E2EOption) ([]*T, string, string, error)
ExecuteCmdAndBuildJSONOutput is generic function to execute given command and build JSON output and return the result, stdOut, stdErr and error
func GetAvailableContexts ¶
GetAvailableContexts takes list of contexts and returns only which are available in both the 'tanzu context list' command output and the input list
func GetE2EHomeDir ¶
func GetE2EHomeDir() string
func GetHTTPCall ¶
GetHTTPCall queries http GET call on given url
func GetHomeDir ¶
func GetHomeDir() string
func GetMapKeyForPlugin ¶
func GetMapKeyForPlugin(pluginsList *PluginInfo) string
GetMapKeyForPlugin takes the plugin and returns the map key for the plugin
func GetMapKeys ¶
func GetMapKeys[K string, V *PluginInfo](m map[K][]V) []*K
GetMapKeys takes map[K]any and returns the slice of all map keys
func GetPluginGroupWhichStartsWithGivenPrefix ¶
func GetPluginGroupWhichStartsWithGivenPrefix(pgs []*PluginGroup, prefix string) string
GetPluginGroupWhichStartsWithGivenPrefix takes plugin groups list and prefix string returns first plugin group which starts with the given prefix
func IsAllPluginGroupsExists ¶
func IsAllPluginGroupsExists(superList, subList []*PluginGroup) bool
IsAllPluginGroupsExists takes the two list of PluginGroups (super list and sub list), check if all sub list PluginGroup are exists in super list PluginGroup
func IsContextExists ¶
IsContextExists checks the given context is exists in the config file by listing the existing contexts in the config file
func IsPluginExists ¶
func IsPluginExists(pluginList []*PluginInfo, plugin *PluginInfo, pluginInstallationStatus string) bool
IsPluginExists validates the given plugin (with plugin status) is exists in the plugins list or not
func IsPluginSourceExists ¶
func IsPluginSourceExists(list []*PluginSourceInfo, sourceName string) bool
IsPluginSourceExists checks the sourceName is exists in the given list of PluginSourceInfo's
func LegacyPluginListToMap ¶
func LegacyPluginListToMap(pluginsList []*PluginInfo) map[string]*PluginInfo
LegacyPluginListToMap converts the given PluginInfo slice to map type, key is combination of plugin's name_target_version and value is PluginInfo
func LogConfigFiles ¶
func LogConfigFiles() error
LogConfigFiles logs info level, contents of files config.yaml and config-ng.yaml
func NotContainsString ¶
NotContainsString checks that the given buffer not contains the string if contains then throws error.
func PluginGroupToMap ¶
func PluginGroupToMap(pluginGroups []*PluginGroup) map[string]*PluginGroup
PluginGroupToMap converts the given slice of PluginGroups to map (PluginGroup name:version is the key) and PluginGroup is the value
func PluginListToMap ¶
func PluginListToMap(pluginsList []*PluginInfo) map[string]*PluginInfo
PluginListToMap converts the given PluginInfo slice to map type, key is combination of plugin's name_target_version and value is PluginInfo
func PluginListToSet ¶
func PluginListToSet(pluginsToInstall []*PluginInfo) map[string]struct{}
PluginListToSet converts the given PluginInfo slice to set type, key is combination of plugin's name_target_version
func RandomNumber ¶
RandomNumber generates random string of given length
func RandomString ¶
RandomString generates random string of given length
func SliceToSet ¶
SliceToSet converts the given slice to set type
func StartMockServer ¶
StartMockServer starts the http mock server (rodolpheche/wiremock)
func StopContainer ¶
StopContainer stops the given docker container
func UpdatePluginDiscoverySource ¶
UpdatePluginDiscoverySource updates the plugin discovery source with given url
func WriteToFileInJSONFormat ¶
WriteToFileInJSONFormat creates (if not exists) and writes the given input type to given file in json format
Types ¶
type Artifact ¶
type Artifact struct { // Image is a fully qualified OCI image for the plugin binary. Image string `json:"image,omitempty"` // AssetURI is a URI of the plugin binary. This can be a fully qualified HTTP path or a local path. URI string `json:"uri,omitempty"` // SHA256 hash of the plugin binary. Digest string `json:"digest,omitempty"` // Type of the binary artifact. Valid values are S3, OCIImage. Type string `json:"type"` // OS of the plugin binary in `GOOS` format. OS string `json:"os"` // Arch is CPU architecture of the plugin binary in `GOARCH` format. Arch string `json:"arch"` }
Artifact points to an individual plugin binary specific to a version and platform.
type ArtifactList ¶
type ArtifactList []Artifact
ArtifactList contains an Artifact object for every supported platform of a version.
type CLIOption ¶
type CLIOption func(*CLIOptions)
type CLIOptions ¶
type CLIOptions struct { FilePath string // file path to tanzu installation; Default values for legacy Tanzu CLI is set using TANZU_CLI_COEXISTENCE_LEGACY_TANZU_CLI_DIR and new Tanzu CLI is set using TANZU_CLI_COEXISTENCE_NEW_TANZU_CLI_DIR Override bool // new tanzu cli overrides the installation of legacy tanzu cli; Default value is false }
CLIOptions used to configure certain options that are used in CLI lifecycle operations FilePath should be set to customize the installation path for legacy Tanzu CLI or new Tanzu CLI Override is set to determine whether the new Tanzu CLI should override or coexist the installation of legacy Tanzu CLI
type CLIPlugin ¶
type CLIPlugin struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` Spec CLIPluginSpec `json:"spec"` }
CLIPlugin denotes a Tanzu cli plugin.
type CLIPluginSpec ¶
type CLIPluginSpec struct { // Description is the plugin's description. Description string `json:"description"` // Recommended version that Tanzu CLI should use if available. // The value should be a valid semantic version as defined in // https://semver.org/. E.g., 2.0.1 RecommendedVersion string `json:"recommendedVersion"` // Artifacts contains an artifact list for every supported version. Artifacts map[string]ArtifactList `json:"artifacts,omitempty"` // Optional specifies whether the plugin is mandatory or optional // If optional, the plugin will not get auto-downloaded as part of // `tanzu login` or `tanzu plugin sync` command // To view the list of plugin, user can use `tanzu plugin list` and // to download a specific plugin run, `tanzu plugin install <plugin-name>` Optional bool `json:"optional,omitempty"` // Target specifies the target of the plugin. Only needed for standalone plugins Target configtypes.Target `json:"target,omitempty"` }
CLIPluginSpec defines the desired state of CLIPlugin.
type CertAddOptions ¶
type CertDetails ¶
type CliOps ¶
type CliOps interface { CLIInit(opts ...E2EOption) error CLIVersion(opts ...E2EOption) (string, error) UninstallTanzuCLI(opts ...E2EOption) error InstallLegacyTanzuCLI(opts ...E2EOption) error RollbackToLegacyTanzuCLI(tf *Framework, opts ...E2EOption) error InstallNewTanzuCLI(opts ...E2EOption) error ReinstallNewTanzuCLI(opts ...E2EOption) error // CompletionCmd executes `tanzu completion` command for given shell as input value, and returns stdout, stderr and error CompletionCmd(shell string, opts ...E2EOption) (string, string, error) }
CliOps performs basic cli operations
type ClusterInfo ¶
type ClusterInfo struct { Name string ClusterKubeContext string EndPoint string KubeConfigPath string APIKey string }
ClusterInfo holds the general cluster details
func CreateKindCluster ¶
func CreateKindCluster(tf *Framework, name string) (*ClusterInfo, error)
CreateKindCluster create the k8s KIND cluster in the local Docker environment
func GetTMCClusterInfo ¶
func GetTMCClusterInfo() *ClusterInfo
GetTMCClusterInfo returns the TMC cluster info by reading environment variables TANZU_CLI_TMC_UNSTABLE_URL and TANZU_API_TOKEN Currently we are setting these env variables in GitHub action for local testing these variables need to be set by the developer on their respective machine
type ClusterOps ¶
type ClusterOps interface { // CreateCluster creates the cluster with given name CreateCluster(clusterName string) (stdOut, stdErr string, err error) // DeleteCluster deletes the cluster with given name DeleteCluster(clusterName string) (stdOut, stdErr string, err error) // ClusterStatus checks the status of the cluster for given cluster name ClusterStatus(clusterName string) (stdOut, stdErr string, err error) // GetClusterEndpoint returns the cluster endpoint for the given cluster name GetClusterEndpoint(clusterName string) (endpoint, stdOut, stdErr string, err error) // GetClusterContext returns the given cluster kubeconfig context GetClusterContext(clusterName string) string // GetKubeconfigPath returns the default kubeconfig path GetKubeconfigPath() string // ApplyConfig applies the given configFilePath on to the given contextName cluster context ApplyConfig(contextName, configFilePath string) (stdOut, stdErr string, err error) }
ClusterOps has helper operations to perform on cluster
type CmdOps ¶
type CmdOps interface { Exec(command string, opts ...E2EOption) (stdOut, stdErr *bytes.Buffer, err error) ExecContainsString(command, contains string, opts ...E2EOption) error ExecContainsAnyString(command string, contains []string, opts ...E2EOption) error ExecContainsErrorString(command, contains string, opts ...E2EOption) error ExecNotContainsStdErrorString(command, contains string, opts ...E2EOption) error ExecNotContainsString(command, contains string, opts ...E2EOption) error TanzuCmdExec(command string, opts ...E2EOption) (stdOut, stdErr *bytes.Buffer, err error) }
CmdOps performs the Command line exec operations
type ConfigCertOps ¶
type ConfigCertOps interface { // ConfigCertAdd adds cert config for a host, and returns stdOut and error info ConfigCertAdd(certAddOpts *CertAddOptions, opts ...E2EOption) (string, error) // ConfigCertDelete deletes cert config for a host, and returns error info ConfigCertDelete(host string, opts ...E2EOption) error // ConfigCertList list cert ConfigCertList(opts ...E2EOption) ([]*CertDetails, error) }
ConfigCertOps performs "tanzu config cert" command operations
type ConfigCmdOps ¶
type ConfigCmdOps interface { ConfigLifecycleOps ConfigCertOps }
func NewConfOps ¶
func NewConfOps() ConfigCmdOps
type ConfigLifecycleOps ¶
type ConfigLifecycleOps interface { // ConfigWithOptions performs config command with given options ConfigWithOptions(opts ...E2EOption) (stdOut, stdErr *bytes.Buffer, err error) // ConfigSetFeatureFlag sets the tanzu config feature flag ConfigSetFeatureFlag(path, value string, opts ...E2EOption) error // ConfigGetFeatureFlag gets the tanzu config feature flag ConfigGetFeatureFlag(path string, opts ...E2EOption) (string, error) // ConfigUnsetFeature un-sets the tanzu config feature flag ConfigUnsetFeature(path string, opts ...E2EOption) error // ConfigInit performs "tanzu config init" ConfigInit(opts ...E2EOption) error // GetConfig gets the tanzu config GetConfig(opts ...E2EOption) (*configapi.ClientConfig, error) // DeleteCLIConfigurationFiles deletes cli configuration files DeleteCLIConfigurationFiles() error // IsCLIConfigurationFilesExists checks the existence of cli configuration files IsCLIConfigurationFilesExists() bool }
ConfigLifecycleOps performs "tanzu config" command operations
type ContainerRuntime ¶
type ContainerRuntime interface { StartContainerRuntime() (stdOut, stdErr string, err error) ContainerRuntimeStatus() (stdOut, stdErr string, err error) StopContainerRuntime() (stdOut, stdErr string, err error) }
ContainerRuntime has operations to perform on container runtime
type ContextCmdOps ¶
type ContextCmdOps interface { // ContextCreateOps helps context create operations ContextCreateOps // UseContext helps to run 'context use' command UseContext(contextName string, opts ...E2EOption) (stdOutStr, stdErrStr string, err error) // GetContext helps to run `context get` command GetContext(contextName string, opts ...E2EOption) (ContextInfo, error) // ListContext helps to run `context list` command ListContext(opts ...E2EOption) (contexts []*ContextListInfo, stdOutStr, stdErrStr string, err error) // DeleteContext helps to run `context delete` command DeleteContext(contextName string, opts ...E2EOption) (stdOutStr, stdErrStr string, err error) // GetActiveContext returns current active context for given context-type GetActiveContext(contextType string, opts ...E2EOption) (string, error) // GetActiveContexts returns all active contexts GetActiveContexts(opts ...E2EOption) ([]*ContextListInfo, error) // UnsetContext unsets the given context with 'tanzu context unset' and returns stdOut, stdErr and error UnsetContext(contextName string, opts ...E2EOption) (stdOutStr, stdErrStr string, err error) }
ContextCmdOps helps to run Context lifecycle operations
func NewContextCmdOps ¶
func NewContextCmdOps() ContextCmdOps
type ContextCreateOps ¶
type ContextCreateOps interface { // CreateContextWithEndPoint creates a context with a given endpoint URL CreateContextWithEndPoint(contextName, endpoint string, opts ...E2EOption) error // CreateContextWithEndPointStaging creates a context with a given endpoint URL for staging, returns stdout, stderr and error CreateContextWithEndPointStaging(contextName, endpoint string, opts ...E2EOption) (stdOut, stdErr string, err error) // CreateContextWithKubeconfig creates a context with the given kubeconfig file path and a context from the kubeconfig file CreateContextWithKubeconfig(contextName, kubeconfigPath, kubeContext string, opts ...E2EOption) (stdOut, stdErr string, err error) // CreateContextWithDefaultKubeconfig creates a context with the default kubeconfig file and a given input context name if it exists in the default kubeconfig file CreateContextWithDefaultKubeconfig(contextName, kubeContext string, opts ...E2EOption) error }
ContextCreateOps helps to run context create command
func NewContextCreateOps ¶
func NewContextCreateOps() ContextCreateOps
type ContextInfo ¶
type ContextListInfo ¶
type DiscoveryOptions ¶
type Docker ¶
type Docker interface { ContainerRuntime }
Docker is the container runtime of type docker
type E2EOption ¶
type E2EOption func(*E2EOptions)
func AddAdditionalFlagAndValue ¶
AddAdditionalFlagAndValue is to add any additional flag with value (if any) to the end of tanzu command
func GetJsonOutputFormatAdditionalFlagFunction ¶
func GetJsonOutputFormatAdditionalFlagFunction() E2EOption
GetJsonOutputFormatAdditionalFlagFunction returns a E2EOption function to add json as output format
func WithFilePath ¶
WithFilePath is the installation file path location
func WithOverride ¶
WithOverride is to provide whether new Tanzu CLI overrides the installation of legacy Tanzu CLI
func WithTanzuBinary ¶
WithTanzuBinary is to set the tanzu binary location; default is tanzu from PATH variable
type E2EOptions ¶
type E2EOptions struct { TanzuBinary string // TanzuBinary should be set to customize the tanzu binary either the binary name if available with PATH variable or full binary path with name ; default is tanzu from PATH variable CLIOptions AdditionalFlags string }
func NewE2EOptions ¶
func NewE2EOptions(options ...E2EOption) *E2EOptions
type Framework ¶
type Framework struct { Exec CmdOps CliOps Config ConfigCmdOps KindCluster ClusterOps PluginCmd PluginCmdOps // performs plugin command operations PluginHelper PluginHelperOps // helper (pre-setup) for plugin cmd operations ContextCmd ContextCmdOps }
Framework has all helper functions to write CLI e2e test cases
func NewFramework ¶
func NewFramework() *Framework
type GeneratePluginOps ¶
type GeneratePluginOps interface { // GeneratePluginBinaries generates plugin binaries for given plugin metadata and return generated plugin binary file paths GeneratePluginBinaries(pluginsMeta []*PluginMeta) ([]string, []error) }
GeneratePluginOps helps to generate script-based plugin binaries, and plugin binaries can be used to perform plugin testing like, add plugin source, list, and install plugins. And call sub-commands such as info and version.
func NewScriptBasedPlugins ¶
func NewScriptBasedPlugins() GeneratePluginOps
type ImgpkgOps ¶
type ImgpkgOps interface { PushBinary(filepath, registryBucketURL string) (registryURL string, err error) PushBundle(filepath, registryBucketURL string) (registryURL string, err error) PullBinary(url string, outputPath string) (stdOut string, err error) PullBundle(url string, outputPath string) (stdOut string, err error) }
func NewImgpkgOps ¶
func NewImgpkgOps() ImgpkgOps
type KindCluster ¶
type KindCluster interface { ClusterOps }
KindCluster performs k8s KIND cluster operations
func NewKindCluster ¶
func NewKindCluster(docker Docker) KindCluster
type PluginBasicOps ¶
type PluginBasicOps interface { // ListPlugins execytes 'tanzu plugin list' command and // returns the output, stdOut, stdErr and error ListPlugins(opts ...E2EOption) ([]*PluginInfo, string, string, error) // ListInstalledPlugins lists all installed plugins ListInstalledPlugins(opts ...E2EOption) ([]*PluginInfo, error) // ListPluginsForGivenContext lists all plugins for a given context and either installed only or all ListPluginsForGivenContext(context string, installedOnly bool, opts ...E2EOption) ([]*PluginInfo, error) // SearchPlugins searches all plugins for given filter (keyword|regex) by running 'tanzu plugin search' command SearchPlugins(filter string, opts ...E2EOption) ([]*PluginInfo, string, string, error) // InstallPlugin installs given plugin and flags InstallPlugin(pluginName, target, versions string, opts ...E2EOption) (stdOut, stdErr string, err error) // Sync performs sync operation and returns stdOut, stdErr and error Sync(opts ...E2EOption) (string, string, error) // DescribePlugin describes given plugin and flags, returns the plugin description as PluginDescribe DescribePlugin(pluginName, target string, opts ...E2EOption) ([]*PluginDescribe, error) // DescribePluginLegacy describes given plugin and flags, returns plugin description in string format DescribePluginLegacy(pluginName, target string, opts ...E2EOption) (string, error) // UninstallPlugin uninstalls/deletes given plugin UninstallPlugin(pluginName, target string, opts ...E2EOption) error // DeletePlugin deletes/uninstalls given plugin DeletePlugin(pluginName, target string, opts ...E2EOption) error // ExecuteSubCommand executes specific plugin sub-command ExecuteSubCommand(pluginWithSubCommand string, opts ...E2EOption) (string, error) // CleanPlugins executes the plugin clean command to delete all existing plugins CleanPlugins(opts ...E2EOption) error // RunPluginCmd runs plugin command with provided options RunPluginCmd(options string, opts ...E2EOption) (string, string, error) }
PluginBasicOps helps to perform the plugin command operations
type PluginCmdOps ¶
type PluginCmdOps interface { PluginBasicOps PluginSourceOps PluginGroupOps PluginDownloadAndUploadOps }
PluginCmdOps helps to perform the plugin and its sub-commands lifecycle operations
func NewPluginLifecycleOps ¶
func NewPluginLifecycleOps() PluginCmdOps
type PluginDescribe ¶
type PluginDescribe struct { Buildsha string `yaml:"buildsha"` Completiontype string `yaml:"completiontype"` Defaultfeatureflags string `yaml:"defaultfeatureflags"` Description string `yaml:"description"` Digest string `yaml:"digest"` Discoveredrecommendedversion string `yaml:"discoveredrecommendedversion"` Discovery string `yaml:"discovery"` Docurl string `yaml:"docurl"` Group string `yaml:"group"` Installationpath string `yaml:"installationpath"` Name string `yaml:"name"` Scope string `yaml:"scope"` Status string `yaml:"status"` Target string `yaml:"target"` Version string `yaml:"version"` }
type PluginDownloadAndUploadOps ¶
type PluginDownloadAndUploadOps interface { // DownloadPluginBundle downloads the plugin inventory and plugin bundles to local tar file DownloadPluginBundle(image string, groups []string, toTar string, opts ...E2EOption) error // UploadPluginBundle performs the uploading plugin bundle to the remote repository // Based on the remote repository status, it setups a new discovery source endpoint // or merges the additional plugins in the bundle to the existing discovery source UploadPluginBundle(toRepo string, tar string, opts ...E2EOption) error }
type PluginGroup ¶
type PluginGroupGet ¶
type PluginGroupOps ¶
type PluginGroupOps interface { // SearchPluginGroups performs plugin group search // input: flagsWithValues - flags and values if any SearchPluginGroups(flagsWithValues string, opts ...E2EOption) ([]*PluginGroup, error) // GetPluginGroup performs plugin group get // input: flagsWithValues - flags and values if any GetPluginGroup(groupName string, flagsWithValues string, opts ...E2EOption) ([]*PluginGroupGet, error) // InstallPluginsFromGroup a plugin or all plugins from the given plugin group InstallPluginsFromGroup(pluginNameORAll, groupName string, opts ...E2EOption) (stdout string, stdErr string, err error) }
type PluginHelperOps ¶
type PluginHelperOps interface { GeneratePluginOps PublishPluginOps }
PluginHelperOps helps to generate and publish plugins
func NewPluginOps ¶
func NewPluginOps(generatePluginOps GeneratePluginOps, publishPluginOps PublishPluginOps) PluginHelperOps
type PluginInfo ¶
type PluginInfo struct { Name string `json:"name"` Description string `json:"description"` Target string `json:"target"` Discovery string `json:"discovery"` Scope string `json:"scope"` Status string `json:"status"` Version string `json:"version"` Context string `json:"context"` }
func CreateTemporaryCRsFromPluginInfos ¶
func CreateTemporaryCRsFromPluginInfos(plugins []*PluginInfo) ([]*PluginInfo, []string, error)
CreateTemporaryCRsFromPluginInfos takes list of Plugins info and generates temporary CR files(under $FullPathForTempDir), and returns plugins list, CR files and error if any while creating the CR files
func GetGivenPluginFromTheGivenPluginList ¶
func GetGivenPluginFromTheGivenPluginList(pluginList []*PluginInfo, requiredPlugin *PluginInfo) *PluginInfo
GetGivenPluginFromTheGivenPluginList takes the plugin list and a plugin checks the given plugin exists in the plugin list, if exists then returns the plugin otherwise returns nil
func GetInstalledPlugins ¶
func GetInstalledPlugins(pluginList []*PluginInfo) []*PluginInfo
GetInstalledPlugins takes list of plugins and returns installed only list of plugins
func GetPluginFromFirstListButNotExistsInSecondList ¶
func GetPluginFromFirstListButNotExistsInSecondList(first, second []*PluginInfo) (*PluginInfo, error)
GetPluginFromFirstListButNotExistsInSecondList returns a plugin which is exists in first plugin list but not in second plugin list
func GetPluginsList ¶
func GetPluginsList(tf *Framework, installedOnly bool) ([]*PluginInfo, error)
GetPluginsList returns a list of plugins, either installed or both installed and uninstalled, based on the value of the installedOnly parameter.
type PluginMeta ¶
type PluginMeta struct {
// contains filtered or unexported fields
}
func NewPluginMeta ¶
func NewPluginMeta() *PluginMeta
func (*PluginMeta) GetName ¶
func (p *PluginMeta) GetName() string
func (*PluginMeta) GetRegistryDiscoveryURL ¶
func (p *PluginMeta) GetRegistryDiscoveryURL() string
func (*PluginMeta) SetAliases ¶
func (p *PluginMeta) SetAliases(alias []string) *PluginMeta
func (*PluginMeta) SetArch ¶
func (p *PluginMeta) SetArch(arch string) *PluginMeta
func (*PluginMeta) SetDescription ¶
func (p *PluginMeta) SetDescription(description string) *PluginMeta
func (*PluginMeta) SetDiscoveryType ¶
func (p *PluginMeta) SetDiscoveryType(discoveryType string) *PluginMeta
func (*PluginMeta) SetGroup ¶
func (p *PluginMeta) SetGroup(group string) *PluginMeta
func (*PluginMeta) SetHidden ¶
func (p *PluginMeta) SetHidden(hidden bool) *PluginMeta
func (*PluginMeta) SetName ¶
func (p *PluginMeta) SetName(name string) *PluginMeta
func (*PluginMeta) SetOS ¶
func (p *PluginMeta) SetOS(osType string) *PluginMeta
func (*PluginMeta) SetOptional ¶
func (p *PluginMeta) SetOptional(optional bool) *PluginMeta
func (*PluginMeta) SetSHA ¶
func (p *PluginMeta) SetSHA(sha string) *PluginMeta
func (*PluginMeta) SetTarget ¶
func (p *PluginMeta) SetTarget(target string) *PluginMeta
func (*PluginMeta) SetVersion ¶
func (p *PluginMeta) SetVersion(version string) *PluginMeta
type PluginRegistry ¶
type PluginRegistry interface { // StartRegistry starts plugin registry StartRegistry() (url string, err error) // StopRegistry stops plugin registry StopRegistry() error // IsRegistryRunning validates plugin registry status IsRegistryRunning() (bool, error) // GetRegistryURLWithDefaultCLIPluginsBucket returns the default registry url with default bucket for CLI plugin's GetRegistryURLWithDefaultCLIPluginsBucket() (url string) }
func NewLocalOCIRegistry ¶
func NewLocalOCIRegistry(registryName, port string) PluginRegistry
type PluginSearch ¶
type PluginSourceInfo ¶
type PluginSourceOps ¶
type PluginSourceOps interface { // UpdatePluginDiscoverySource updates plugin discovery source, and returns stdOut and error info UpdatePluginDiscoverySource(discoveryOpts *DiscoveryOptions, opts ...E2EOption) (string, error) // DeletePluginDiscoverySource removes the plugin discovery source, and returns stdOut and error info DeletePluginDiscoverySource(pluginSourceName string, opts ...E2EOption) (string, error) // ListPluginSources returns all available plugin discovery sources ListPluginSources(opts ...E2EOption) ([]*PluginSourceInfo, error) // InitPluginDiscoverySource initializes the plugin source to its default value, and returns stdOut and error info InitPluginDiscoverySource(opts ...E2EOption) (string, error) }
PluginSourceOps helps 'plugin source' commands
type PublishPluginOps ¶
type PublishPluginOps interface { // PublishPluginBinary publishes the plugin binaries to given registry bucket and returns the plugin distribution urls PublishPluginBinary(pluginsInfo []*PluginMeta) (distributionUrls []string, errs []error) // GeneratePluginBundle generates plugin bundle in local file system for given plugin metadata GeneratePluginBundle(pluginsMeta []*PluginMeta) ([]string, []error) // PublishPluginBundle publishes the plugin bundles to given registry bucket and returns the plugins discovery urls PublishPluginBundle(pluginsInfo []*PluginMeta) (discoveryUrls []string, errs []error) }
PublishPluginOps helps to publish plugin binaries and plugin bundles
func NewLocalOCIPluginOps ¶
func NewLocalOCIPluginOps(registry PluginRegistry) PublishPluginOps
type TMCPluginsInfo ¶
type TMCPluginsInfo struct {
Plugins []TMCPlugin `yaml:"plugins"`
}
type TMCPluginsMockRequestResponseMapping ¶
type TMCPluginsMockRequestResponseMapping struct { Request struct { Method string `json:"method"` URL string `json:"url"` } `json:"request"` Response struct { Status int `json:"status"` Body string `json:"body"` Headers struct { ContentType string `json:"Content-Type"` Accept string `json:"Accept"` } `json:"headers"` } `json:"response"` }
func ConvertPluginsInfoToTMCEndpointMockResponse ¶
func ConvertPluginsInfoToTMCEndpointMockResponse(plugins []*PluginInfo) (*TMCPluginsMockRequestResponseMapping, error)
ConvertPluginsInfoToTMCEndpointMockResponse takes the plugins info and converts to TMC endpoint response to mock http calls
type TMCPluginsResponse ¶
type TMCPluginsResponse struct {
PluginsInfo TMCPluginsInfo `yaml:"pluginsInfo"`
}
TMCPluginsResponse is to mock the tmc endpoint response for plugins info
Source Files ¶
- cli_lifecycle_operations.go
- cluster_container_runtime.go
- cluster_interface.go
- cluster_kind.go
- cmd_exec_operations.go
- config_lifecycle_operations.go
- context_create_operations.go
- context_lifecycle_operations.go
- framework.go
- framework_constants.go
- framework_helper.go
- imgpkg_operations.go
- output_handling.go
- plugin_lifecycle_operations.go
- plugin_meta.go
- plugin_operations.go
- plugin_registry.go
- templates.go