utils

package
v0.7.20 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorURL = baseConfigURL + "manifests/default.yaml"
	BrokerURL   = baseConfigURL + "samples/meshery_v1alpha1_broker.yaml"
	MeshsyncURL = baseConfigURL + "samples/meshery_v1alpha1_meshsync.yaml"

	// Meshery Server Location
	EndpointProtocol = "http"
)
View Source
const (
	HelmChartURL          = "https://meshery.io/charts/"
	HelmChartName         = "meshery"
	HelmChartOperatorName = "meshery-operator"
)

Variables

View Source
var (
	ErrFailRequestCode        = "1163"
	ErrInvalidTokenCode       = "1164"
	ErrFailReqStatusCode      = "1165"
	ErrAttachAuthTokenCode    = "1166"
	ErrUnmarshalCode          = "1167"
	ErrFileReadCode           = "1168"
	ErrCreatingRequestCode    = "1169"
	ErrMarshalCode            = "1170"
	ErrReadResponseBodyCode   = "1171"
	ErrParsingUrlCode         = "1172"
	ErrNotFoundCode           = "1173"
	ErrUnauthenticatedCode    = "1174"
	ErrInvalidFileCode        = "1175"
	ErrInvalidNameOrIDCode    = "1176"
	ErrInvalidAPIResponseCode = "1177"
	ErrReadConfigFileCode     = "1178"
	ErrMarshalIndentCode      = "1179"
	ErrLoadConfigCode         = "1180"
	ErrResponseStatusBodyCode = "1181"
	ErrResponseStatusCode     = "1182"
	ErrJSONToYAMLCode         = "1183"
	ErrOutFormatFlagCode      = "1184"
	ErrParseGithubFileCode    = "1185"
	ErrReadTokenCode          = "1186"
	ErrRequestResponseCode    = "1187"
)

Please reference the following before contributing an error code: https://docs.meshery.io/project/contributing/contributing-error https://github.com/meshery/meshkit/blob/master/errors/errors.go

View Source
var (
	// ResetFlag indicates if a reset is required
	ResetFlag bool
	// SkipResetFlag indicates if fetching the updated manifest files is required
	SkipResetFlag bool
	// MesheryDefaultHost is the default host on which Meshery is exposed
	MesheryDefaultHost = "localhost"
	// MesheryDefaultPort is the default port on which Meshery is exposed
	MesheryDefaultPort = 9081
	// MesheryEndpoint is the default URL in which Meshery is exposed
	MesheryEndpoint = fmt.Sprintf("http://%s:%v", MesheryDefaultHost, MesheryDefaultPort)
	// MesheryFolder is the default relative location of the meshery config
	// related configuration files.
	MesheryFolder = ".meshery"
	// DockerComposeFile is the default location within the MesheryFolder
	// where the docker compose file is located.
	DockerComposeFile = "meshery.yaml"
	// AuthConfigFile is the location of the auth file for performing perf testing
	AuthConfigFile = "auth.json"
	// DefaultConfigPath is the detail path to mesheryctl config
	DefaultConfigPath = "config.yaml"
	// MesheryNamespace is the namespace to which Meshery is deployed in the Kubernetes cluster
	MesheryNamespace = "meshery"
	// MesheryDeployment is the name of a Kubernetes manifest file required to setup Meshery
	// check https://github.com/layer5io/meshery/tree/master/install/deployment_yamls/k8s
	MesheryDeployment = "meshery-deployment.yaml"
	// MesheryService is the name of a Kubernetes manifest file required to setup Meshery
	// check https://github.com/layer5io/meshery/tree/master/install/deployment_yamls/k8s
	MesheryService = "meshery-service.yaml"
	//MesheryOperator is the file for default Meshery operator
	//check https://github.com/layer5io/meshery-operator/blob/master/config/manifests/default.yaml
	MesheryOperator = "default.yaml"
	//MesheryOperatorBroker is the file for the Meshery broker
	//check https://github.com/layer5io/meshery-operator/blob/master/config/samples/meshery_v1alpha1_broker.yaml
	MesheryOperatorBroker = "meshery_v1alpha1_broker.yaml"
	//MesheryOperatorMeshsync is the file for the Meshery Meshsync Operator
	//check https://github.com/layer5io/meshery-operator/blob/master/config/samples/meshery_v1alpha1_meshsync.yaml
	MesheryOperatorMeshsync = "meshery_v1alpha1_meshsync.yaml"
	// ServiceAccount is the name of a Kubernetes manifest file required to setup Meshery
	// check https://github.com/layer5io/meshery/tree/master/install/deployment_yamls/k8s
	ServiceAccount = "service-account.yaml"
	// To upload with param name
	ParamName = "k8sfile"
	// kubeconfig file name
	KubeConfigYaml = "kubeconfig.yaml"
	// ViperCompose is an instance of viper for docker-compose
	ViperCompose = viper.New()
	// ViperMeshconfig is an instance of viper for the meshconfig file
	ViperMeshconfig = viper.New()
	// SilentFlag skips waiting for user input and proceeds with default options
	SilentFlag bool
	// PlatformFlag sets the platform for the initial config file
	PlatformFlag string
	// Paths to kubeconfig files
	ConfigPath string
	KubeConfig string
	// KeepNamespace indicates if the namespace should be kept when Meshery is uninstalled
	KeepNamespace bool
	// TokenFlag sets token location passed by user with --token
	TokenFlag = "Not Set"
	// global logger variable
	Log logger.Handler
)
View Source
var (
	// ManifestsFolder is where the Kubernetes manifests are stored
	ManifestsFolder = "manifests"
	ReleaseTag      string
)
View Source
var CfgFile string
View Source
var ListOfComponents = []string{}

ListOfComponents returns the list of components available

View Source
var Services = map[string]Service{
	"meshery": {
		Image:  "layer5/meshery:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Environment: []string{
			"PROVIDER_BASE_URLS=https://meshery.layer5.io",
			"ADAPTER_URLS=meshery-istio:10000 meshery-linkerd:10001 meshery-consul:10002 meshery-nsm:10004 meshery-app-mesh:10005 meshery-kuma:10007 meshery-osm:10009 meshery-traefik-mesh:10006 meshery-nginx-sm:10010 meshery-cilium:10012",
			"EVENT=mesheryLocal",
			"PORT=9081",
		},
		Volumes: []string{"$HOME/.kube:/home/appuser/.kube:ro", "$HOME/.minikube:$HOME/.minikube:ro"},
		Ports:   []string{"9081:9081"},
	},
	"meshery-istio": {
		Image:  "layer5/meshery-istio:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10000:10000"},
	},
	"meshery-linkerd": {
		Image:  "layer5/meshery-linkerd:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10001:10001"},
	},
	"meshery-consul": {
		Image:  "layer5/meshery-consul:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10002:10002"},
	},
	"meshery-nsm": {
		Image:  "layer5/meshery-nsm:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10004:10004"},
	},
	"meshery-app-mesh": {
		Image:  "layer5/meshery-app-mesh:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10005:10005"},
	},
	"meshery-traefik-mesh": {
		Image:  "layer5/meshery-traefik-mesh:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10006:10006"},
	},
	"meshery-kuma": {
		Image:  "layer5/meshery-kuma:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10007:10007"},
	},
	"meshery-osm": {
		Image:  "layer5/meshery-osm:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10009:10009"},
	},
	"meshery-nginx-sm": {
		Image:  "layer5/meshery-nginx-sm:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10010:10010"},
	},
	"meshery-cilium": {
		Image:  "layer5/meshery-cilium:stable-latest",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
		Ports:  []string{"10012:10012"},
	},
	"watchtower": {
		Image:  "containrrr/watchtower",
		Labels: []string{"com.centurylinklabs.watchtower.enable=true"},
	},
}
View Source
var TemplateContext = config.Context{
	Endpoint:   EndpointProtocol + "://localhost:9081",
	Token:      "default",
	Platform:   "kubernetes",
	Components: ListOfComponents,
	Channel:    "stable",
	Version:    "latest",
	Provider:   "Meshery",
}

TemplateContext is the template context provided when creating a config file

View Source
var TemplateToken = config.Token{
	Name:     "default",
	Location: AuthConfigFile,
}

TemplateToken is the template token provided when creating a config file

Functions

func AddAuthDetails

func AddAuthDetails(req *http.Request, filepath string) error

AddAuthDetails Adds authentication cookies to the request

func AppError added in v0.6.7

func AppError(msg string) string

AppError returns a formatted error message with a link to 'app' command usage page in addition to the error message

func AppViewError added in v0.6.137

func AppViewError(msg string) string

AppError returns a formatted error message with a link to 'app view' command usage page in addition to the error message

func ApplyManifest added in v0.5.2

func ApplyManifest(manifest []byte, client *meshkitkube.Client, update bool, delete bool) error

ApplyManifest is a wrapper function for client.ApplyManifest

func ApplyManifestFiles added in v0.5.2

func ApplyManifestFiles(manifestArr []Manifest, requestedAdapters []string, client *meshkitkube.Client, update bool, delete bool) error

ApplyManifestFiles applies/updates/deletes all the required manifests into the Kubernetes cluster

func ApplyOperatorManifest added in v0.5.12

func ApplyOperatorManifest(client *meshkitkube.Client, update bool, delete bool) error

ApplyOperatorManifest applies/updates/deletes the operator manifest

func AreAllPodsRunning added in v0.5.33

func AreAllPodsRunning() (bool, error)

AreAllPodsRunning checks if all the deployment pods under kubernetes are running

func AreMesheryComponentsRunning added in v0.6.2

func AreMesheryComponentsRunning(currPlatform string) (bool, error)

AreMesheryComponentsRunning checks if the meshery containers are up and running

func AskForConfirmation added in v0.5.1

func AskForConfirmation(s string) bool

AskForConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user.

func AskForInput added in v0.5.15

func AskForInput(prompt string, allowed []string) string

AskForInput asks the user for an input and checks if it is in the available values

func BackupConfigFile added in v0.5.32

func BackupConfigFile(cfgFile string)

func CanUseCachedManifests added in v0.5.50

func CanUseCachedManifests(currCtx *(config.Context)) error

CanUseCachedManifests returns an error if it is not possible to use cached manifests

func CanUseCachedOperatorManifests added in v0.5.50

func CanUseCachedOperatorManifests(_ *config.Context) error

CanUseCachedOperatorManifests returns an error if it is not possible to use cached operator manifests

func ChangeManifestVersion added in v0.5.3

func ChangeManifestVersion(channel, version, filePath string) error

ChangeManifestVersion changes the tag of the images in the manifest according to the pinned version

func CheckFileExists added in v0.6.2

func CheckFileExists(name string) (bool, error)

CheckFileExists checks if the given file exists in system or not

func CheckK8sVersion added in v0.5.3

func CheckK8sVersion(versionInfo *version.Info) error

func CheckKubectlVersion added in v0.5.3

func CheckKubectlVersion() error

CheckKubectlVersion validates whether the installed kubectl version is running a minimum kubectl version.

func CheckMesheryNsDelete added in v0.6.2

func CheckMesheryNsDelete() (bool, error)

CheckMesheryNsDelete waits for Meshery namespace to be deleted, returns (done, error)

func ClearLine added in v0.7.13

func ClearLine()

ClearLine clears the last line from output

func Contains added in v0.7.18

func Contains(key string, col []string) int

func ContainsStringPrefix added in v0.5.46

func ContainsStringPrefix(arr []string, str string) bool

ContainsStringPrefix takes a string slice and a string and returns true if it is present

func ContentTypeIsHTML added in v0.3.18

func ContentTypeIsHTML(resp *http.Response) bool

ContentTypeIsHTML Checks if the response is an HTML resposnse

func ConvertMapInterfaceMapString added in v0.5.39

func ConvertMapInterfaceMapString(v interface{}) interface{}

ConvertMapInterfaceMapString converts map[interface{}]interface{} => map[string]interface{}

It will also convert []interface{} => []string

func ConvertRespToSSE added in v0.5.46

func ConvertRespToSSE(resp *http.Response) (chan Event, error)

ConvertRespToSSE converts a connection to a stream of server sent events

func CreateComponentsMetadataAndCreateSVGsForMDStyle added in v0.7.14

func CreateComponentsMetadataAndCreateSVGsForMDStyle(components []ComponentCSV, path, svgDir string) (string, error)

func CreateComponentsMetadataAndCreateSVGsForMDXStyle added in v0.7.14

func CreateComponentsMetadataAndCreateSVGsForMDXStyle(components []ComponentCSV, path, svgDir string) (string, error)

func CreateConfigFile added in v0.5.1

func CreateConfigFile() error

CreateConfigFile creates config file in Meshery Folder

func CreateDefaultSpinner added in v0.5.24

func CreateDefaultSpinner(suffix string, finalMsg string) *spinner.Spinner

Indicate an ongoing Process at a given time on CLI

func CreateManifestsFolder added in v0.5.13

func CreateManifestsFolder() error

CreateManifestsFolder creates a new folder (.meshery/manifests)

func CreateTempAuthServer added in v0.5.32

func CreateTempAuthServer(fn func(http.ResponseWriter, *http.Request)) (*http.Server, int, error)

CreateTempAuthServer creates a temporary http server

It implements a custom mux and has a catch all route, the function passed as the parameter is binded to the catch all route

func DeleteConfiguration added in v0.6.31

func DeleteConfiguration(mesheryServerUrl, id, configuration string) error

Delete configuration from meshery server endpoint /api/{configurations}/{id}

func DownloadDockerComposeFile added in v0.5.1

func DownloadDockerComposeFile(ctx *config.Context, force bool) error

DownloadDockerComposeFile fetches docker-compose.yaml based on passed context if it does not exists. Use force to override download anyway

func DownloadManifests added in v0.5.1

func DownloadManifests(manifestArr []Manifest, rawManifestsURL string) error

DownloadManifests downloads all the Kubernetes manifest files

func DownloadOperatorManifest added in v0.5.13

func DownloadOperatorManifest() error

DownloadOperatorManifest downloads the operator manifest files

func Equals added in v0.5.26

func Equals(tb testing.TB, exp, act interface{})

equals fails the test if exp is not equal to act.

func ErrAttachAuthToken added in v0.6.2

func ErrAttachAuthToken(err error) error

func ErrCreatingRequest added in v0.6.132

func ErrCreatingRequest(err error) error

func ErrFailReqStatus added in v0.6.2

func ErrFailReqStatus(statusCode int) error

func ErrFailRequest added in v0.6.2

func ErrFailRequest(err error) error

func ErrFileRead added in v0.6.132

func ErrFileRead(err error) error

func ErrInvalidAPIResponse added in v0.6.132

func ErrInvalidAPIResponse(err error) error

func ErrInvalidFile added in v0.6.132

func ErrInvalidFile(err error) error

func ErrInvalidNameOrID added in v0.6.132

func ErrInvalidNameOrID(err error) error

func ErrInvalidToken added in v0.6.132

func ErrInvalidToken() error

func ErrJSONToYAML added in v0.6.137

func ErrJSONToYAML(err error) error

func ErrLoadConfig added in v0.6.137

func ErrLoadConfig(err error) error

func ErrMarshal added in v0.6.137

func ErrMarshal(err error) error

func ErrMarshalIndent added in v0.6.137

func ErrMarshalIndent(err error) error

func ErrNotFound added in v0.6.132

func ErrNotFound(err error) error

func ErrOutFormatFlag added in v0.6.137

func ErrOutFormatFlag() error

func ErrParseGithubFile added in v0.6.137

func ErrParseGithubFile(err error, URL string) error

func ErrParsingUrl added in v0.6.132

func ErrParsingUrl(err error) error

func ErrReadConfigFile added in v0.6.137

func ErrReadConfigFile(err error) error

func ErrReadResponseBody added in v0.6.132

func ErrReadResponseBody(err error) error

func ErrReadToken added in v0.6.137

func ErrReadToken(err error) error

func ErrRequestResponse added in v0.6.137

func ErrRequestResponse(err error) error

func ErrResponseStatus added in v0.6.137

func ErrResponseStatus(statusCode int) error

func ErrResponseStatusBody added in v0.6.137

func ErrResponseStatusBody(statusCode int, body string) error

func ErrUnauthenticated added in v0.6.2

func ErrUnauthenticated() error

func ErrUnmarshal added in v0.6.132

func ErrUnmarshal(err error) error

func ExpError added in v0.6.7

func ExpError(msg string) string

ExpError returns a formatted error message with a link to 'exp' command usage page in addition to the error message

func FilterDeleteError added in v0.6.107

func FilterDeleteError(msg string) string

FilterDeleteError returns a formatted error message with a link to 'filter delete' command usage page in addition to the error message

func FilterError added in v0.6.7

func FilterError(msg string) string

FilterError returns a formatted error message with a link to 'filter' command usage page in addition to the error message

func FilterImportError added in v0.6.107

func FilterImportError(msg string) string

FilterImportError returns a formatted error message with a link to 'filter import' command usage page in addition to the error message

func FilterListError added in v0.6.107

func FilterListError(msg string) string

FilterListError returns a formatted error message with a link to 'filter list' command usage page in addition to the error message

func FilterViewError added in v0.6.107

func FilterViewError(msg string) string

FilterViewError returns a formatted error message with a link to 'filter view' command usage page in addition to the error message

func FindClosestArg added in v0.6.64

func FindClosestArg(argPassed string, validArgs []string) string

func ForceCleanupCluster added in v0.6.2

func ForceCleanupCluster() error

func GenerateConfigGKE

func GenerateConfigGKE(configPath, SAName, namespc string) error

TODO@Aisuko this function is so hard to read and maintain, please refactor it

func GenerateJSStyleDocs added in v0.7.14

func GenerateJSStyleDocs(model ModelCSV, docsJSON, imgPath string) (string, error)

func GenerateMDStyleDocs added in v0.7.14

func GenerateMDStyleDocs(model ModelCSV, components []ComponentCSV, modelPath, imgPath string) error

func GenerateMDXStyleDocs added in v0.7.14

func GenerateMDXStyleDocs(model ModelCSV, components []ComponentCSV, modelPath, imgPath string) error

func GetBasePath added in v0.5.26

func GetBasePath(t *testing.T) string

Path to the current file

func GetChannelAndVersion added in v0.5.46

func GetChannelAndVersion(currCtx *(config.Context)) (string, string, error)

returns the Channel and Version given a context

func GetCleanPodName added in v0.6.2

func GetCleanPodName(name string) string

GetCleanPodName cleans the pod names in the MesheryNamespace to make it more readable

func GetCurrentAuthToken added in v0.6.2

func GetCurrentAuthToken() (string, error)

GetCurrentAuthToken returns location of current context token

func GetDeploymentVersion added in v0.5.50

func GetDeploymentVersion(filePath string) (string, error)

func GetEphemeralPort added in v0.6.2

func GetEphemeralPort() (int, error)

GetEphemeralPort selects a port for the port-forwarding. It binds to a free ephemeral port and returns the port number.

func GetID added in v0.6.31

func GetID(mesheryServerUrl, configuration string) ([]string, error)

GetID returns a array of IDs from meshery server endpoint /api/{configurations}

func GetIndexForRegisterCol added in v0.7.14

func GetIndexForRegisterCol(cols []string, shouldRegister string) int

func GetK8sVersionInfo added in v0.5.3

func GetK8sVersionInfo() (*version.Info, error)

GetK8sVersionInfo returns version.Info for the Kubernetes cluster.

func GetManifestTreeURL added in v0.5.2

func GetManifestTreeURL(version string) (string, error)

GetManifestTreeURL returns the manifest tree url based on version

func GetManifestURL added in v0.5.1

func GetManifestURL(manifest Manifest, rawManifestsURL string) string

GetManifestURL returns the URLs for the manifest files

func GetName added in v0.6.107

func GetName(mesheryServerUrl, configuration string) (map[string]string, error)

GetName returns a of name:id from meshery server endpoint /api/{configurations}

func GetPodList added in v0.6.2

func GetPodList(client *meshkitkube.Client, namespace string) (*v1core.PodList, error)

GetPods lists all the available pods in the MesheryNamespace

func GetProviderInfo added in v0.5.32

func GetProviderInfo(mctCfg *config.MesheryCtlConfig) (map[string]Provider, error)

GetProviderInfo queries meshery API for the provider info

func GetRequiredPods added in v0.5.13

func GetRequiredPods(specifiedPods []string, availablePods []v1core.Pod) (map[string]string, error)

GetRequiredPodsMap checks if the pods specified by the user is valid returns a map of the required pods

func GetSessionData added in v0.5.38

func GetSessionData(mctlCfg *config.MesheryCtlConfig) (*models.Preference, error)

Get Meshery Session Data/Details (Adapters)

func GetTokenLocation added in v0.6.2

func GetTokenLocation(token config.Token) (string, error)

Function checks the location of token and returns appropriate location of the token

func InitiateLogin added in v0.5.32

func InitiateLogin(mctlCfg *config.MesheryCtlConfig, option string) ([]byte, error)

InitiateLogin initates the login process

func InstallprereqDocker added in v0.5.12

func InstallprereqDocker() error

func IsAdapterValid added in v0.5.1

func IsAdapterValid(manifestArr []Manifest, componentManifest string) bool

IsAdapterValid checks if the component mentioned by the user is a valid component

func IsMesheryRunning

func IsMesheryRunning(currPlatform string) (bool, error)

IsMesheryRunning checks if the meshery server containers are up and running

func IsServerRunning added in v0.6.181

func IsServerRunning(serverAddr string) error

func IsValidSubcommand

func IsValidSubcommand(available []*cobra.Command, sub string) bool

IsValidSubcommand checks if the passed subcommand is supported by the parent command

func MakeRequest added in v0.6.2

func MakeRequest(req *http.Request) (*http.Response, error)

Function returns a new http response given a http request Function will test the response and return any errors associated with it

func MapGet added in v0.5.39

func MapGet(mp map[string]interface{}, key ...string) (interface{}, bool)

MapGet takes in the map keys - each key goes one level deeper in the map

func MapSet added in v0.5.39

func MapSet(mp map[string]interface{}, value interface{}, key ...string)

MapSet takes in the map that needs to be manipulated, the value that needs to be assgined to be assigned and the key - each key goes one level deeper in the map

func MeshError added in v0.6.7

func MeshError(msg string) string

MeshError returns a formatted error message with a link to 'mesh' command usage page in addition to the error message

func NavigateToBrowser(endpoint string) error

NavigateToBroswer naviagtes to the endpoint displaying Meshery UI in the broswer.

func NewRequest added in v0.6.2

func NewRequest(method string, url string, body io.Reader) (*http.Request, error)

NewRequest creates *http.Request and handles adding authentication for Meshery itself Function returns a http response generated by the new request

func ParseURLGithub added in v0.5.38

func ParseURLGithub(URL string) (string, string, error)

ParseURLGithub checks URL and returns raw repo, path, error

func PatternError added in v0.6.7

func PatternError(msg string) string

PatternError returns a formatted error message with a link to 'pattern' command usage page in addition to the error message

func PatternViewError added in v0.6.137

func PatternViewError(msg string) string

PatternViewError returns a formatted error message with a link to the 'pattern view' commad usage page in addition to the error message

func PerfError

func PerfError(msg string) string

PerfError returns a formatted error message with a link to 'perf' command usage page at in addition to the error message

func Populate added in v0.5.46

func Populate(src, dst string) error

func PrintToTable added in v0.5.2

func PrintToTable(header []string, data [][]string)

PrintToTable prints the given data into a table format

func PrintToTableInStringFormat added in v0.5.26

func PrintToTableInStringFormat(header []string, data [][]string) string

PrintToTableInStringFormat prints the given data into a table format but return as a string

func PrintToTableWithFooter added in v0.5.11

func PrintToTableWithFooter(header []string, data [][]string, footer []string)

PrintToTableWithFooter prints the given data into a table format but with a footer

func ReadToken added in v0.5.11

func ReadToken(filepath string) (map[string]string, error)

ReadToken returns a map of the token passed in

func RecursiveCastMapStringInterfaceToMapStringInterface added in v0.5.39

func RecursiveCastMapStringInterfaceToMapStringInterface(in map[string]interface{}) map[string]interface{}

RecursiveCastMapStringInterfaceToMapStringInterface will convert a map[string]interface{} recursively => map[string]interface{}

func RegistryError added in v0.7.14

func RegistryError(msg string, cmd string) string

func RootError

func RootError(msg string) string

RootError returns a formatted error message with a link to 'root' command usage page at in addition to the error message

func SafeClose

func SafeClose(co io.Closer)

SafeClose is a helper function help to close the io

func SetFileLocation

func SetFileLocation() error

SetFileLocation to set absolute path

func SetFileLocationTesting added in v0.5.37

func SetFileLocationTesting(dir string)

Set file location for testing stuff

func SetKubeConfig added in v0.5.61

func SetKubeConfig()

Sets the path to user's kubeconfig file into global variables

func SetOverrideValues added in v0.5.67

func SetOverrideValues(ctx *config.Context, mesheryImageVersion string) map[string]interface{}

SetOverrideValues returns the value overrides based on current context to install/upgrade helm chart

func SetupContextEnv added in v0.5.26

func SetupContextEnv(t *testing.T)

use default context /pkg/utils/TestConfig.yaml

func SetupCustomContextEnv added in v0.5.37

func SetupCustomContextEnv(t *testing.T, pathToContext string)

setup custom context with SetupCustomContextEnv

func SetupLogrusFormatter added in v0.5.26

func SetupLogrusFormatter()

Call this function to setup logrus

func SetupLogrusGrabTesting added in v0.5.46

func SetupLogrusGrabTesting(_ *testing.T, _ bool) *bytes.Buffer

setup logrus formatter and return the buffer in which commands output is to be set.

func SetupMeshkitLogger added in v0.6.2

func SetupMeshkitLogger(debugLevel bool, output io.Writer)

Initialize Meshkit Logger instance

func SetupMeshkitLoggerTesting added in v0.6.2

func SetupMeshkitLoggerTesting(_ *testing.T, verbose bool) *bytes.Buffer

setup meshkit logger for testing and return the buffer in which commands output is to be set.

func StartMockMesheryServer added in v0.7.1

func StartMockMesheryServer(t *testing.T) error

func StartMockery added in v0.5.26

func StartMockery(t *testing.T)

Start mock HTTP client to mock requests

func Startdockerdaemon added in v0.5.12

func Startdockerdaemon(subcommand string) error

func StopMockery added in v0.5.26

func StopMockery(_ *testing.T)

stop HTTP mock client

func StringContainedInSlice added in v0.5.13

func StringContainedInSlice(str string, slice []string) int

StringContainedInSlice returns the index in which a string is a substring in a list of strings

func StringInSlice added in v0.5.15

func StringInSlice(str string, slice []string) bool

StringInSlice checks if a string is present in a slice

func StringWithCharset

func StringWithCharset(length int) string

StringWithCharset generates a random string with a given length

func SystemChannelSubError added in v0.6.7

func SystemChannelSubError(msg string, cmd string) string

SystemChannelSubError returns a formatted error message with a link to `channel` command usage page in addition to the error message

func SystemContextSubError added in v0.6.7

func SystemContextSubError(msg string, cmd string) string

SystemContextSubError returns a formatted error message with a link to `context` command usage page in addition to the error message

func SystemError

func SystemError(msg string) string

SystemError returns a formatted error message with a link to 'system' command usage page in addition to the error message

func SystemLifeCycleError added in v0.6.30

func SystemLifeCycleError(msg string, cmd string) string

func SystemModelSubError added in v0.6.181

func SystemModelSubError(msg string, cmd string) string

SystemProviderSubError returns a formatted error message with a link to `provider` command usage page in addition to the error message

func SystemProviderSubError added in v0.6.46

func SystemProviderSubError(msg string, cmd string) string

SystemProviderSubError returns a formatted error message with a link to `provider` command usage page in addition to the error message

func SystemTokenError added in v0.6.48

func SystemTokenError(msg string) string

SystemTokenError returns a formatted error message with a link to 'token' command usage page in addition to the error message

func TransformYAML added in v0.5.39

func TransformYAML(yamlByt []byte, transform func(interface{}) (interface{}, error), keys ...string) ([]byte, error)

TransformYAML takes in:

yamlByt - YAML Byte slice that needs to be modified
transform - function that will be executed on that value, the returned value will replace the current value
keys - takes in a series of keys which are supposed to be nested, numbers can also be passed to access an array

func TruncateID added in v0.5.11

func TruncateID(id string) string

TruncateID shortens an id to 8 characters

func UpdateAuthDetails

func UpdateAuthDetails(filepath string) error

UpdateAuthDetails checks gets the token (old/refreshed) from meshery server and writes it back to the config file

func UpdateMesheryContainers added in v0.5.1

func UpdateMesheryContainers() error

UpdateMesheryContainers runs the update command for meshery client

func UploadFileWithParams

func UploadFileWithParams(uri string, params map[string]string, paramName, path string) (*http.Request, error)

UploadFileWithParams returns a request configured to upload files with other values

func ValidId added in v0.6.107

func ValidId(mesheryServerUrl, args string, configuration string) (string, bool, error)

ValidId - Check if args is a valid ID or a valid ID prefix and returns the full ID

func ValidName added in v0.6.107

func ValidName(mesheryServerUrl, args string, configuration string) (string, string, bool, error)

ValidId - Check if args is a valid name or a valid name prefix and returns the full name and ID

func ValidateURL added in v0.5.1

func ValidateURL(URL string) error

ValidateURL validates url provided for meshery backend to mesheryctl context

func WaitForNamespaceDeleted added in v0.6.2

func WaitForNamespaceDeleted(c *meshkitkube.Client, namespace string, timeout int) error

Wait up to timeout seconds for `namespace` to be deleted.

func WaitForPodRunning added in v0.6.2

func WaitForPodRunning(c *meshkitkube.Client, desiredPod, namespace string, timeout int) error

Wait up to timeout seconds for pod in 'namespace' to enter running state. Returns an error if no pods are found or not all discovered pods enter running state.

Types

type CmdTestInput added in v0.5.26

type CmdTestInput struct {
	Name                 string
	Args                 []string
	ExpectedResponse     string
	ExpectedResponseYaml string
	ExpectError          bool
	ErrorStringContains  []string
}

type ComponentCSV added in v0.7.14

type ComponentCSV struct {
	Registrant         string `json:"registrant"`
	Model              string `json:"model"`
	Component          string `json:"component"`
	Shape              string `json:"shape"`
	PrimaryColor       string `json:"primaryColor"`
	SecondaryColor     string `json:"secondaryColor"`
	SVGColor           string `json:"svgColor"`
	SVGWhite           string `json:"svgWhite"`
	SVGComplete        string `json:"svgComplete"`
	HasSchema          string `json:"hasSchema"`
	Description        string `json:"description"`
	Docs               string `json:"docs"`
	StyleOverrides     string `json:"styleOverrides"`
	Styles             string `json:"styles"`
	ShapePolygonPoints string `json:"shapePolygonPoints"`
	DefaultData        string `json:"defaultData"`
	Capabilities       string `json:"capabilities"`
	LogoURL            string `json:"logoURL"`
	Genealogy          string `json:"genealogy"`
	IsAnnotation       string `json:"isAnnotation"`

	ModelDisplayName string `json:"modelDisplayName"`
	Category         string `json:"category"`
	SubCategory      string `json:"subCategory"`
}

func (*ComponentCSV) CreateComponentDefinition added in v0.7.18

func (c *ComponentCSV) CreateComponentDefinition(isModelPublished bool) (v1alpha1.ComponentDefinition, error)

The Component Definition generated assumes or is only for components which have registrant as "meshery"

func (*ComponentCSV) UpdateCompDefinition added in v0.7.18

func (c *ComponentCSV) UpdateCompDefinition(compDef *v1alpha1.ComponentDefinition) error

type ComponentCSVHelper added in v0.7.14

type ComponentCSVHelper struct {
	SpreadsheetID  int64
	SpreadsheetURL string
	Title          string
	CSVPath        string
	Components     map[string]map[string][]ComponentCSV
}

func NewComponentCSVHelper added in v0.7.14

func NewComponentCSVHelper(sheetURL, spreadsheetName string, spreadsheetID int64) (*ComponentCSVHelper, error)

func (ComponentCSVHelper) Cleanup added in v0.7.14

func (m ComponentCSVHelper) Cleanup() error

func (*ComponentCSVHelper) GetColumns added in v0.7.18

func (mch *ComponentCSVHelper) GetColumns() ([]string, error)

func (*ComponentCSVHelper) ParseComponentsSheet added in v0.7.14

func (mch *ComponentCSVHelper) ParseComponentsSheet() error

type Containers added in v0.5.3

type Containers struct {
	Env             interface{}      `yaml:"env,omitempty"`
	Image           string           `yaml:"image,omitempty"`
	ImagePullPolicy string           `yaml:"imagePullPolicy"`
	Name            string           `yaml:"name,omitempty"`
	Ports           []map[string]int `yaml:"ports,omitempty"`
	Resources       interface{}      `yaml:"resources,omitempty"`
}

type DockerCompose added in v0.5.1

type DockerCompose struct {
	Version  string             `yaml:"version,omitempty"`
	Services map[string]Service `yaml:"services,omitempty"`
	Volumes  Volumes            `yaml:"volumes,omitempty"`
}

type Event added in v0.5.46

type Event struct {
	Name string
	ID   string
	Data EventData
}

Event represents a Server-Sent Event

type EventData added in v0.5.46

type EventData struct {
	Details     string `json:"details"`
	OperationID string `json:"operation_id"`
	Summary     string `json:"summary"`
}

type GoldenFile added in v0.5.26

type GoldenFile struct {
	// contains filtered or unexported fields
}

func NewGoldenFile added in v0.5.26

func NewGoldenFile(t *testing.T, name string, directory string) *GoldenFile

func (*GoldenFile) Load added in v0.5.26

func (tf *GoldenFile) Load() string

Load a Golden file

func (*GoldenFile) LoadByte added in v0.5.26

func (tf *GoldenFile) LoadByte() []byte

Load a Golden file

func (*GoldenFile) Write added in v0.5.26

func (tf *GoldenFile) Write(content string)

write a Golden file

func (*GoldenFile) WriteInByte added in v0.5.26

func (tf *GoldenFile) WriteInByte(content []byte)

write a Golden file

type K8sCompose added in v0.5.3

type K8sCompose struct {
	APIVersion interface{} `yaml:"apiVersion,omitempty"`
	Kind       string      `yaml:"kind,omitempty"`
	Metadata   interface{} `yaml:"metadata,omitempty"`
	Spec       Spec        `yaml:"spec,omitempty"`
	Status     interface{} `yaml:"status,omitempty"`
}

type Manifest added in v0.5.1

type Manifest struct {
	Path string      `json:"path,omitempty"`
	Mode string      `json:"mode,omitempty"`
	Typ  string      `json:"type,omitempty"`
	SHA  string      `json:"sha,omitempty"`
	Size json.Number `json:"size,omitempty"`
	URL  string      `json:"url,omitempty"`
}

func FetchManifests added in v0.5.2

func FetchManifests(currCtx *(config.Context)) ([]Manifest, error)

FetchManifests is a wrapper function that identifies the required manifest files as downloads them

func ListManifests added in v0.5.1

func ListManifests(url string) ([]Manifest, error)

ListManifests lists the manifest files stored in GitHub

type ManifestList added in v0.5.1

type ManifestList struct {
	SHA       string     `json:"sha,omitempty"`
	URL       string     `json:"url,omitempty"`
	Tree      []Manifest `json:"tree,omitempty"`
	Truncated bool       `json:"truncated,omitempty"`
}

type MockURL added in v0.5.32

type MockURL struct {
	// method such as GET or POST
	Method string
	// url to mock the request
	URL string
	// response for the request
	Response string
	// response code
	ResponseCode int
}

type ModelCSV added in v0.7.14

type ModelCSV struct {
	ModelDisplayName   string `json:"modelDisplayName"`
	Model              string `json:"model"`
	Registrant         string `json:"registrant"`
	Category           string `json:"category"`
	SubCategory        string `json:"subCategory"`
	Description        string `json:"description"`
	SourceURL          string `json:"sourceURL"`
	Website            string `json:"website"`
	Docs               string `json:"docs"`
	Shape              string `json:"shape"`
	PrimaryColor       string `json:"primaryColor"`
	SecondaryColor     string `json:"secondaryColor"`
	StyleOverrides     string `json:"styleOverrides"`
	Styles             string `json:"styles"`
	ShapePolygonPoints string `json:"shapePolygonPoints"`
	DefaultData        string `json:"defaultData"`
	Capabilities       string `json:"capabilities"`
	LogoURL            string `json:"logoURL"`
	SVGColor           string `json:"svgColor"`
	SVGWhite           string `json:"svgWhite"`
	SVGComplete        string `json:"svgComplete"`
	PublishToRegistry  string `json:"publishToRegistry"`
	IsAnnotation       string `json:"isAnnotation"`
	AboutProject       string `json:"aboutProject"`
	PageSubtTitle      string `json:"pageSubtitle"`
	DocsURL            string `json:"docsURL"`
	StandardBlurb      string `json:"standardBlurb"`
	Feature1           string `json:"feature1"`
	Feature2           string `json:"feature2"`
	Feature3           string `json:"feature3"`
	HowItWorks         string `json:"howItWorks"`
	HowItWorksDetails  string `json:"howItWorksDetails"`
	Screenshots        string `json:"screenshots"`
	FullPage           string `json:"fullPage"`
	PublishToSites     string `json:"publishToSites"`
}

func (ModelCSV) CreateJSONItem added in v0.7.14

func (m ModelCSV) CreateJSONItem(iconDir string) string

Creates JSON formatted meshmodel attribute item for JSON Style docs

func (ModelCSV) CreateMarkDownForMDStyle added in v0.7.14

func (m ModelCSV) CreateMarkDownForMDStyle(componentsMetadata string) string

func (ModelCSV) CreateMarkDownForMDXStyle added in v0.7.14

func (m ModelCSV) CreateMarkDownForMDXStyle(componentsMetadata string) string

template := `--- title: <model-display-name> subtitle: <Page Subtitle> integrationIcon: ../../../assets/images/service-mesh-icons/aws-app-mesh.svg darkModeIntegrationIcon: ../../../assets/images/service-mesh-icons/aws-app-mesh_white.svg docURL: <Docs URL> category: <Category> subcategory: <Sub-Category> featureList: [<Feature 1>,<Feature 2>,<Feature 3>] workingSlides: [

../_images/meshmap-visualizer.png,
../_images/meshmap-designer.png]

howItWorks: <howItWorks> howItWorksDetails: howItWorksDetails published: <Publish> --- <p>

<About Project>

</p> <p>

<Standard Blurb>

</p>`

func (*ModelCSV) CreateModelDefinition added in v0.7.18

func (mcv *ModelCSV) CreateModelDefinition(version string) v1alpha1.Model

type ModelCSVHelper added in v0.7.14

type ModelCSVHelper struct {
	SpreadsheetID  int64
	SpreadsheetURL string
	Title          string
	CSVPath        string
	Models         []ModelCSV
}

func NewModelCSVHelper added in v0.7.14

func NewModelCSVHelper(sheetURL, spreadsheetName string, spreadsheetID int64) (*ModelCSVHelper, error)

func (ModelCSVHelper) Cleanup added in v0.7.14

func (m ModelCSVHelper) Cleanup() error

func (*ModelCSVHelper) ParseModelsSheet added in v0.7.14

func (mch *ModelCSVHelper) ParseModelsSheet(parseForDocs bool) error

type PortForward added in v0.6.2

type PortForward struct {
	// contains filtered or unexported fields
}

PortForward provides a port-forward connection into a Kubernetes cluster.

func NewPortForward added in v0.6.2

func NewPortForward(
	ctx context.Context,
	client *meshkitkube.Client,
	namespace, deployName string,
	host string, localPort, remotePort int,
	emitLogs bool,
) (*PortForward, error)

NewPortForward returns an instance of the PortForward struct that can be used to establish a port-forward connection to a pod in the deployment that's specified by namespace and deployName. If localPort is 0, it will use a random ephemeral port. Note that the connection remains open for the life of the process, as this function is typically called by the CLI.

func (*PortForward) AddressAndPort added in v0.6.2

func (pf *PortForward) AddressAndPort() string

AddressAndPort returns the address and port for the port-forward connection.

func (*PortForward) GetStop added in v0.6.2

func (pf *PortForward) GetStop() <-chan struct{}

GetStop returns the stopCh. Receiving on stopCh will block until the port forwarding stops.

func (*PortForward) Init added in v0.6.2

func (pf *PortForward) Init() error

Init creates and runs a port-forward connection. This function blocks until the connection is established, in which case it returns nil. It's the caller's responsibility to call Stop() to finish the connection.

func (*PortForward) Stop added in v0.6.2

func (pf *PortForward) Stop()

Stop terminates the port-forward connection. It is the caller's responsibility to call Stop even in case of errors

func (*PortForward) URLFor added in v0.6.2

func (pf *PortForward) URLFor(path string) string

URLFor returns the URL for the port-forward connection.

type Provider added in v0.5.32

type Provider struct {
	ProviderURL  string `json:"provider_url,omitempty"`
	ProviderName string `json:"provider_name,omitempty"`
}

type Service added in v0.5.1

type Service struct {
	Image       string   `yaml:"image,omitempty"`
	Labels      []string `yaml:"labels,omitempty"`
	Environment []string `yaml:"environment,omitempty"`
	Volumes     []string `yaml:"volumes,omitempty"`
	Ports       []string `yaml:"ports,omitempty"`
}

type Spec added in v0.5.3

type Spec struct {
	Replicas int         `yaml:"replicas,omitempty"`
	Selector interface{} `yaml:"selector,omitempty"`
	Strategy interface{} `yaml:"strategy,omitempty"`
	Template Template    `yaml:"template,omitempty"`
}

type SystemType added in v0.7.14

type SystemType int
const (
	Meshery SystemType = iota
	Docs
	RemoteProvider
)

func (SystemType) String added in v0.7.14

func (dt SystemType) String() string

type Template added in v0.5.3

type Template struct {
	Metadata interface{}  `yaml:"metadata,omitempty"`
	Spec     TemplateSpec `yaml:"spec,omitempty"`
}

type TemplateSpec added in v0.5.3

type TemplateSpec struct {
	ServiceAccount     string       `yaml:"serviceAccount,omitempty"`
	ServiceAccountName string       `yaml:"serviceAccountName,omitempty"`
	Containers         []Containers `yaml:"containers,omitempty"`
	RestartPolicy      string       `yaml:"restartPolicy,omitempty"`
}

type TerminalFormatter added in v0.5.26

type TerminalFormatter struct{}

TerminalFormatter is exported

func (*TerminalFormatter) Format added in v0.5.26

func (f *TerminalFormatter) Format(entry *log.Entry) ([]byte, error)

Format defined the format of output for Logrus logs Format is exported

type TestHelper added in v0.5.26

type TestHelper struct {
	Version string
	BaseURL string
}

func NewTestHelper added in v0.5.26

func NewTestHelper(_ *testing.T) *TestHelper

type Volumes added in v0.5.1

type Volumes struct {
	MesheryConfig interface{} `yaml:"meshery-config,omitempty"`
}

Jump to

Keyboard shortcuts

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