utils

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package utils provides CLI utility functions and structs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertMapOfBytesToMapOfStrings added in v0.0.26

func ConvertMapOfBytesToMapOfStrings(contentMap map[string][]byte) map[string]string

func CreateDirectory added in v0.0.26

func CreateDirectory(dirPath string, mode fs.FileMode)

func CreateKubernetesClient

func CreateKubernetesClient(contextName string) (client.Client, error)

func CreateKubernetesClientOrDie

func CreateKubernetesClientOrDie(contextName string) client.Client

func CreateROrDie

func CreateROrDie(env *ENV, obj client.Object)

func DeleteAllOfOrDie

func DeleteAllOfOrDie(env *ENV, obj client.Object, opts ...client.DeleteAllOfOption)

func DeleteOrDie

func DeleteOrDie(env *ENV, obj client.Object, opts ...client.DeleteOption) bool

func EnsureNamespaceOrDie added in v0.0.24

func EnsureNamespaceOrDie(env *ENV, name string)

func EnsureServiceAccountOrDie added in v0.0.24

func EnsureServiceAccountOrDie(env *ENV, name string)

func ExecuteKubectlClient added in v0.0.28

func ExecuteKubectlClient(ns string, podName string, containerName string, executeCommand string)

func GetCRUDSubcommands

func GetCRUDSubcommands() (*cobra.Command, *cobra.Command, *cobra.Command)

func GetClientset added in v0.0.26

func GetClientset(kubeContext string) (*rest.Config, *kubernetes.Clientset)

func GetFileContent

func GetFileContent(filePath string) ([]byte, error)

func GetKubectlPath added in v0.0.28

func GetKubectlPath() string

func GetM

func GetM(env *ENV, name string, obj client.Object) (bool, error)

func GetMOrDie

func GetMOrDie(env *ENV, name string, obj client.Object) bool

func ReadYAMLToMapOrDie added in v0.0.28

func ReadYAMLToMapOrDie(filePath string) map[string]interface{}

func RunCmdOrDie added in v0.0.23

func RunCmdOrDie(cmd string, args ...string) string

func RunCmdWithEnvOrDie added in v0.0.23

func RunCmdWithEnvOrDie(environ []string, cmd string, args ...string) string

func RunRemoteCmd added in v0.0.26

func RunRemoteCmd(kubeContext string, namespace string, podName string, containerName string, cmdArgs []string) *bytes.Buffer

func SetLogger added in v0.0.32

func SetLogger(command *cobra.Command)

SetLogger enables the DEBUG LogLevel in the Logger when the debug flag is set

func UpdateROrDie

func UpdateROrDie(env *ENV, obj client.Object)

func VarListToMap added in v0.0.24

func VarListToMap(varsList []string) map[string]string

func WriteContentToFile added in v0.0.26

func WriteContentToFile(filePath string, content []byte, mode fs.FileMode)

Types

type ENV

type ENV struct {
	Cli client.Client
	Ns  string
	Ctx context.Context
}

Moving code from cli/sfconfig/cmd/utils/utils.go as we need it to avoid dead code

func GetCLIENV added in v0.0.28

func GetCLIENV(kmd *cobra.Command) (string, ENV)

type SoftwareFactoryConfig

type SoftwareFactoryConfig struct {
	Contexts map[string]SoftwareFactoryConfigContext `json:"contexts" mapstructure:"contexts"`
	Default  string                                  `json:"default-context" mapstructure:"default-context"`
}

type SoftwareFactoryConfigContext

type SoftwareFactoryConfigContext struct {
	ConfigRepository string `json:"config-repository-path" mapstructure:"config-repository-path"`
	Manifest         string `json:"manifest-file" mapstructure:"manifest-file"`
	IsStandalone     bool   `json:"standalone" mapstructure:"standalone"`
	Namespace        string `json:"namespace" mapstructure:"namespace"`
	KubeContext      string `json:"kube-context" mapstructure:"kube-context"`
	FQDN             string `json:"fqdn" mapstructure:"fqdn"`
	Dev              struct {
		AnsibleMicroshiftRolePath string `json:"ansible-microshift-role-path" mapstructure:"ansible-microshift-role-path"`
		SFOperatorRepositoryPath  string `json:"sf-operator-repository-path" mapstructure:"sf-operator-repository-path"`
		Microshift                struct {
			Host                string `json:"host" mapstructure:"host"`
			User                string `json:"user" mapstructure:"user"`
			OpenshiftPullSecret string `json:"openshift-pull-secret" mapstructure:"openshift-pull-secret"`
			DiskFileSize        string `json:"disk-file-size" mapstructure:"disk-file-size"`
			ETCDOnRAMDisk       bool   `json:"etcd-on-ramdisk" mapstructure:"etcd-on-ramdisk"`
		} `json:"microshift" mapstructure:"microshift"`
		Tests struct {
			DemoReposPath string            `json:"demo-repos-path" mapstructure:"demo-repos-path"`
			ExtraVars     map[string]string `json:"extra-vars" mapstructure:"extra-vars"`
		} `json:"tests" mapstructure:"tests"`
	} `json:"development" mapstructure:"development"`
	Components struct {
		Nodepool struct {
			CloudsFile string `json:"clouds-file" mapstructure:"clouds-file"`
			KubeFile   string `json:"kube-file" mapstructure:"kube-file"`
		} `json:"nodepool" mapstructure:"nodepool"`
	} `json:"components" mapstructure:"components"`
}

CLI config struct

func GetCLIContext

func GetCLIContext(command *cobra.Command) (SoftwareFactoryConfigContext, error)

func GetCLIctxOrDie

func GetCLIctxOrDie(kmd *cobra.Command, args []string, allowedArgs []string) SoftwareFactoryConfigContext

Jump to

Keyboard shortcuts

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