utils

package
v0.6.0-rc.5n Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 48 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"
)

Variables

View Source
var (
	ErrFailRequestCode     = "1044"
	ErrFailReqStatusCode   = "1045"
	ErrAttachAuthTokenCode = "1046"
)
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{"meshery-app-mesh", "meshery-istio", "meshery-linkerd", "meshery-consul", "meshery-nsm", "meshery-kuma", "meshery-cpx", "meshery-osm", "meshery-traefik-mesh", "meshery-nginx-sm", "meshery-cilium"}

ListOfComponents returns the list of components available

View Source
var TemplateContext = config.Context{
	Endpoint:   EndpointProtocol + "://localhost:9081",
	Token:      "Default",
	Platform:   "kubernetes",
	Components: ListOfComponents,
	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 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(currCtx *(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 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 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

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 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 ErrFailReqStatus added in v0.6.2

func ErrFailReqStatus(statusCode int) error

func ErrFailRequest added in v0.6.2

func ErrFailRequest(err error) error

func ErrUnauthenticated added in v0.6.2

func ErrUnauthenticated() error

func ForceCleanupCluster added in v0.6.2

func ForceCleanupCluster() error

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 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 GetK8sVersionInfo added in v0.5.3

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

GetK8sVersionInfo returns version.Info for the Kubernetes cluster.

func GetLatestStableReleaseTag added in v0.5.1

func GetLatestStableReleaseTag() (string, error)

GetLatestStableReleaseTag fetches and returns the latest release tag from GitHub

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 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) ([]string, error)

GetRequiredPods checks if the pods specified by the user is valid returns a list of the required pods

func GetSessionData added in v0.5.38

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

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) ([]byte, error)

InitiateLogin initates the login process

func InstallprereqDocker added in v0.5.12

func InstallprereqDocker() error

func InvalidToken added in v0.6.2

func InvalidToken() 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 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 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 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 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(t *testing.T, verbose 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(t *testing.T, verbose bool) *bytes.Buffer

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

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(t *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 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 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 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 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 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 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(t *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