utils

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName = "meshctl-config.yaml"
	ConfigDirName  = ".gloo-mesh"
)
View Source
const (
	Yaml = "yaml"
	Json = "json"
)

Variables

View Source
var (
	DefaultConfigPath = path.Join(homeDir, ConfigDirName, ConfigFileName)
)

Functions

func AddManagementKubeconfigFlags

func AddManagementKubeconfigFlags(kubeconfig, kubecontext *string, flags *pflag.FlagSet)

Set kubeconfig path and context flags for the management cluster.

func AddMeshctlConfigFlags added in v1.1.0

func AddMeshctlConfigFlags(meshctlConfigPath *string, flags *pflag.FlagSet)

Set the meshctl config file path

func AddOutputFlag added in v0.12.7

func AddOutputFlag(cmd *cobra.Command, format *string)

augment the input cobra command with a flag specifying the output format, also add pre-run validation that the format string is valid

func BuildClient

func BuildClient(kubeConfigPath, kubeContext string) (client.Client, error)

func BuildClientConfigAndClientset added in v1.1.0

func BuildClientConfigAndClientset(kubeconfig, kubeContext string) (clientcmd.ClientConfig, *kubernetes.Clientset, error)

BuildClientConfigAndClientset creates a rest.Config and AppsClientset from the given kubeconfig path and Context.

func BuildClientset added in v1.1.0

func BuildClientset(kubeConfigPath, kubeContext string) (*kubernetes.Clientset, error)

func CleanupCompletedPodsInNamespace added in v1.1.0

func CleanupCompletedPodsInNamespace(ctx context.Context, kubeconfig, kubecontext, namespace string) error

func DefaultMeshctlConfigFilePath added in v1.1.0

func DefaultMeshctlConfigFilePath() (string, error)

return the default meshctl config filepath

func EnsureNamespace added in v1.0.0

func EnsureNamespace(ctx context.Context, kubeClient client.Client, namespace string) error

func GetGlooMeshVersion added in v1.0.0

func GetGlooMeshVersion(ctx context.Context, kubeConfigPath, kubeContext, namespace string) (string, error)

func MarshalProtoWithFormat added in v0.12.7

func MarshalProtoWithFormat(msg proto.Message, format string) (string, error)

marshal a proto message with the given format

func PortForwardFromDeployment added in v0.12.7

func PortForwardFromDeployment(
	ctx context.Context,
	kubeConfig string,
	kubeContext string,
	deployName string,
	deployNamespace string,
	localPort string,
	remotePort string,
) (string, error)

Open a port-forward against the specified deployment. Returns the local port. If localPort is unspecified, a free port will be chosen at random. Canceling the context will stop the port-forward.

func PortForwardFromPod added in v0.12.7

func PortForwardFromPod(
	ctx context.Context,
	kubeConfig string,
	kubeContext string,
	podName string,
	podNamespace string,
	localPort string,
	remotePort string,
) (string, error)

Open a port forward against the specified pod. Returns the stop channel and the local port. If localPort is unspecified, a free port will be chosen at random. Close the port forward by closing the returned channel.

func RunShell added in v1.1.0

func RunShell(c string, writer io.Writer)

func UpdateMeshctlConfigWithDeregistrationInfo added in v1.1.0

func UpdateMeshctlConfigWithDeregistrationInfo(mgmtKubeConfigPath, mgmtKubecontext,
	remoteClusterName, remoteKubeConfigPath string) error

update the default meschtl config file with deregistration info

func UpdateMeshctlConfigWithInstallInfo added in v1.1.0

func UpdateMeshctlConfigWithInstallInfo(mgmtKubeConfig, mgmtKubecontext string) error

update the default meschtl config file with install info

func UpdateMeshctlConfigWithRegistrationInfo added in v1.1.0

func UpdateMeshctlConfigWithRegistrationInfo(mgmtKubeConfigPath, mgmtKubecontext,
	remoteClusterName, remoteKubeConfigPath, remoteKubecontext string) error

update the default meschtl config file with registration info

func WaitUntilCRDsEstablished added in v1.1.0

func WaitUntilCRDsEstablished(ctx context.Context, kubeClient client.Client, timeout time.Duration, crdNames []string) error

block until CRD is in the "established" phase to prevent subsequent race conditions when attempting to create CRs

func WriteConfigToFile added in v1.1.0

func WriteConfigToFile(config MeshctlConfig, meshctlConfigPath string) error

func Zip added in v1.1.0

func Zip(fs afero.Fs, dir string, file string) error

Types

type GlobalFlags added in v0.10.6

type GlobalFlags struct {
	Verbose bool
}

func (*GlobalFlags) AddToFlags added in v0.10.6

func (g *GlobalFlags) AddToFlags(flags *pflag.FlagSet)

type KubeConfig added in v1.1.0

type KubeConfig struct {
	ApiVersion string              `json:"apiVersion"`
	Clusters   []KubeConfigCluster `yaml:"clusters"`
}

type KubeConfigCluster added in v1.1.0

type KubeConfigCluster struct {
	Name string `yaml:"name"`
}

type MeshctlCluster added in v1.1.0

type MeshctlCluster struct {
	KubeConfig  string `json:"kubeConfig"`
	KubeContext string `json:"kubeContext"`
	Namespace   string `json:"namespace"`
}

type MeshctlConfig added in v1.1.0

type MeshctlConfig struct {
	ApiVersion string                    `json:"apiVersion"`
	Clusters   map[string]MeshctlCluster `json:"clusters"`
	// contains filtered or unexported fields
}

func NewMeshctlConfig added in v1.1.0

func NewMeshctlConfig() MeshctlConfig

new initialized meshctl config

func ParseMeshctlConfig added in v1.1.0

func ParseMeshctlConfig(meshctlConfigPath string) (MeshctlConfig, error)

parse the meshctl config file into a MeshctlConfig struct If the file doesn't exist or is invalid, return an error

func (MeshctlConfig) AddDataPlaneCluster added in v1.1.0

func (c MeshctlConfig) AddDataPlaneCluster(name string, kc MeshctlCluster) error

add a data plane cluster config

func (MeshctlConfig) AddMgmtCluster added in v1.1.0

func (c MeshctlConfig) AddMgmtCluster(kc MeshctlCluster)

add the management cluster config

func (MeshctlConfig) FilePath added in v1.1.0

func (c MeshctlConfig) FilePath() string

returns the path of the file storing the config

func (MeshctlConfig) IsMgmtCluster added in v1.1.0

func (c MeshctlConfig) IsMgmtCluster(name string) bool

returns the mgmt meshctl cluster name

func (MeshctlConfig) MgmtCluster added in v1.1.0

func (c MeshctlConfig) MgmtCluster() MeshctlCluster

returns the mgmt meshctl cluster config

func (MeshctlConfig) RemoteClusters added in v1.1.0

func (c MeshctlConfig) RemoteClusters() map[string]MeshctlCluster

return cluster names and configs for all remote clusters

Jump to

Keyboard shortcuts

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