utils

package
v0.5.0-rc-6 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ResetFlag indicates if a reset is required
	ResetFlag bool
	// 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"
	// ManifestsFolder is where the Kubernetes manifests are stored
	ManifestsFolder = "manifests"
	// 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"
	// 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"
	// ViperCompose is an instance of viper for docker-compose
	ViperCompose = viper.New()
	// SilentFlag skips waiting for user input and proceeds with default options
	SilentFlag bool
)
View Source
var ListOfAdapters = []string{"meshery-istio", "meshery-linkerd", "meshery-consul", "meshery-nsm", "meshery-kuma", "meshery-cpx", "meshery-osm", "meshery-traefik-mesh"}

ListOfAdapters returns the list of adapters available

View Source
var TemplateContext = config.Context{
	Endpoint: "http://localhost:9081",
	Token:    "Default",
	Platform: "docker",
	Adapters: ListOfAdapters,
	Channel:  "stable",
	Version:  "latest",
}

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 AddContextToConfig added in v0.5.1

func AddContextToConfig(contextName string, context config.Context, configPath string, set bool) error

AddContextToConfig adds context passed to it to mesheryctl config file

func AddTokenToConfig added in v0.5.2

func AddTokenToConfig(token config.Token, configPath string) error

AddTokenToConfig adds token passed to it to mesheryctl config file

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 ContentTypeIsHTML added in v0.3.18

func ContentTypeIsHTML(resp *http.Response) bool

ContentTypeIsHTML Checks if the response is an HTML resposnse

func CreateConfigFile added in v0.5.1

func CreateConfigFile() error

CreateConfigFile creates config file in Meshery Folder

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 DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile from url and save to configured file location

func DownloadManifests added in v0.5.1

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

DownloadManifests downloads all the Kubernetes manifest files

func GenerateConfigAKS added in v0.5.1

func GenerateConfigAKS(configPath, resourceGroup, clusterName string) error

GenerateConfigAKS generates kube config file in ~/.meshery/kubeconfig.yaml for a AKS cluster

func GenerateConfigEKS added in v0.5.1

func GenerateConfigEKS(configPath, region, cluster string) error

GenerateConfigEKS generates kube config file in .meshery/kubeconfig.yaml for an EKS cluster

func GenerateConfigGKE

func GenerateConfigGKE(configPath, SAName, namespc string) error

GenerateConfigGKE generates kube config file in ~/.meshery/kubeconfig.yaml for a GKE cluster

func GenerateConfigMinikube

func GenerateConfigMinikube(configPath string) error

GenerateConfigMinikube generates kube config file in ~/.meshery/kubeconfig.yaml for a Minikube cluster

func GetLatestStableReleaseTag added in v0.5.1

func GetLatestStableReleaseTag() (string, error)

GetLatestStableReleaseTag fetches and returns the latest release tag from GitHub

func GetManifestURL added in v0.5.1

func GetManifestURL(manifest Manifest, rawManifestsURL string) string

GetManifestURL returns the URLs for the manifest files

func GetMesheryGitHubOrg added in v0.4.11

func GetMesheryGitHubOrg() string

GetMesheryGitHubOrg retrieves the name of the GitHub organization under which the Meshery repository resides.

func GetMesheryGitHubRepo added in v0.4.11

func GetMesheryGitHubRepo() string

GetMesheryGitHubRepo retrieves the name of the Meshery repository

func IsAdapterValid added in v0.5.1

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

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

func IsMesheryRunning

func IsMesheryRunning() bool

IsMesheryRunning checks if the meshery server containers are up and running

func IsValidSubcommand

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

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

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 PreReqCheck

func PreReqCheck(subcommand string, focusedContext string) error

PreReqCheck prerequisites check

func PrintToTable added in v0.5.2

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

PrintToTable prints the given data into a table format

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 StringWithCharset

func StringWithCharset(length int) string

StringWithCharset generates a random string with a given length

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 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 ValidateURL added in v0.5.1

func ValidateURL(URL string) error

ValidateURL validates url provided for meshery backend to mesheryctl context

Types

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 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 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 OnlyStringFormatterForLogrus added in v0.5.1

type OnlyStringFormatterForLogrus struct{}

OnlyStringFormatterForLogrus is a custom logrus formatter that returns only string of message as output

func (OnlyStringFormatterForLogrus) Format added in v0.5.1

func (obj OnlyStringFormatterForLogrus) Format(entry *logrus.Entry) ([]byte, error)

Format defined the format of output for Logrus logs

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 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