api

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QliksenseConfigApiVersion = "v1"
	QliksenseConfigApiGroup   = "config.qlik.com"
	QliksenseConfigKind       = "QliksenseConfig"

	QliksenseApiVersion     = "v1"
	QliksenseKind           = "Qliksense"
	QliksenseGroup          = "qlik.com"
	QliksenseDefaultProfile = "docker-desktop"
	QliksenseMetadataName   = "QliksenseConfigMetadata"
	DefaultMongodbUri       = "mongodb://qlik-default-mongodb:27017/qliksense?ssl=false"
	DefaultMongodbUriKey    = "mongodbUri"
)
View Source
const (
	QLIK_GIT_REPO = "https://github.com/qlik-oss/qliksense-k8s"
)

Variables

This section is empty.

Functions

func CopyDirectory added in v0.10.0

func CopyDirectory(source string, dest string) error

copy source directory to destination

func DecryptData added in v0.10.0

func DecryptData(ciphertext []byte, userKey string) ([]byte, error)

func DirExists

func DirExists(dirname string) bool

DirExists checks if a directory exists

func DownloadFile

func DownloadFile(url, baseFolder, installerName string) error

func EncryptData added in v0.10.0

func EncryptData(plaintext []byte, userKey string) ([]byte, error)

func ExecuteTaskWithBlinkingStdoutFeedback

func ExecuteTaskWithBlinkingStdoutFeedback(task func() (interface{}, error), feedback string) (result interface{}, err error)

func ExplodePackage

func ExplodePackage(destination, fileToUntar string) error

func FileExists

func FileExists(filename string) bool

FileExists checks if a file exists

func GenerateAndStoreSecretKey added in v0.10.0

func GenerateAndStoreSecretKey(secretsDir string) (string, error)

GenerateAndStoreSecretKey generates and stores key

func GenerateKey added in v0.10.0

func GenerateKey() (string, error)

func GetKubectlNamespace

func GetKubectlNamespace() string

func K8sSecretFromYaml

func K8sSecretFromYaml(k8sSecretBytes []byte) (v1.Secret, error)

func K8sSecretToYaml

func K8sSecretToYaml(k8sSecret v1.Secret) ([]byte, error)

func K8sToYaml

func K8sToYaml(k8sObj interface{}) ([]byte, error)

func KubectlApply

func KubectlApply(manifests, namespace string) error

KubectlApply create resources in the provided namespace, if namespace="" then use whatever the kubectl default is

func KubectlApplyVerbose added in v0.14.0

func KubectlApplyVerbose(manifests, namespace string, verbose bool) error

func KubectlDelete

func KubectlDelete(manifests, namespace string) error

KubectlDelete delete resources in the provided namespace, if namespace="" then use whatever the kubectl default is

func KubectlDeleteVerbose added in v0.14.0

func KubectlDeleteVerbose(manifests, namespace string, verbose bool) error

func KubectlDirectOps

func KubectlDirectOps(opr []string, namespace string) (string, error)

func LoadSecretKey added in v0.10.0

func LoadSecretKey(secretsDir string) (string, error)

func LogDebugMessage

func LogDebugMessage(strMessage string, args ...interface{})

LogDebugMessage logs a debug message

func ReadFromFile

func ReadFromFile(content interface{}, sourceFile string) error

ReadFromFile (content, targetFile) reads content from specified sourcefile

func ReadFromStream

func ReadFromStream(content interface{}, reader io.Reader) error

ReadFromStream reads from input stream and creat yaml struct of type content

func ReadKeys

func ReadKeys(keyFile string) ([]byte, error)

ReadKeys reads key file from disk

func SetKubectlNamespace

func SetKubectlNamespace(ns string)

func UnZipFile

func UnZipFile(destination, fileToUnzip string) error

func UntarGzFile

func UntarGzFile(destination, fileToUntar string) error

func WriteToFile

func WriteToFile(content interface{}, targetFile string) error

WriteToFile (content, targetFile) writes content into specified file

Types

type ClientGoUtils added in v0.23.0

type ClientGoUtils struct {
	Verbose bool
}

func (*ClientGoUtils) CreatePreflightTestDeployment added in v0.23.0

func (p *ClientGoUtils) CreatePreflightTestDeployment(clientset kubernetes.Interface, namespace string, depName string, imageName string) (*appsv1.Deployment, error)

func (*ClientGoUtils) CreatePreflightTestPod added in v0.23.0

func (p *ClientGoUtils) CreatePreflightTestPod(clientset kubernetes.Interface, namespace, podName, imageName string, secretNames map[string]string, commandToRun []string) (*apiv1.Pod, error)

func (*ClientGoUtils) CreatePreflightTestSecret added in v0.23.0

func (p *ClientGoUtils) CreatePreflightTestSecret(clientset kubernetes.Interface, namespace, secretName string, secretData []byte) (*apiv1.Secret, error)

func (*ClientGoUtils) CreatePreflightTestService added in v0.23.0

func (p *ClientGoUtils) CreatePreflightTestService(clientset kubernetes.Interface, namespace string, svcName string) (*apiv1.Service, error)

func (*ClientGoUtils) CreateStatefulSet added in v0.23.0

func (p *ClientGoUtils) CreateStatefulSet(clientset kubernetes.Interface, namespace string, statefulSetName string, imageName string) (*appsv1.StatefulSet, error)

func (*ClientGoUtils) DeleteDeployment added in v0.23.0

func (p *ClientGoUtils) DeleteDeployment(clientset kubernetes.Interface, namespace, name string) error

func (*ClientGoUtils) DeleteK8sSecret added in v0.23.0

func (p *ClientGoUtils) DeleteK8sSecret(clientset kubernetes.Interface, namespace string, secretName string) error

func (*ClientGoUtils) DeletePod added in v0.23.0

func (p *ClientGoUtils) DeletePod(clientset kubernetes.Interface, namespace, name string) error

func (*ClientGoUtils) DeleteService added in v0.23.0

func (p *ClientGoUtils) DeleteService(clientset kubernetes.Interface, namespace, name string) error

func (*ClientGoUtils) GetK8SClientSet added in v0.23.0

func (p *ClientGoUtils) GetK8SClientSet(kubeconfig []byte, contextName string) (*kubernetes.Clientset, *rest.Config, error)

func (*ClientGoUtils) GetPodContainerLogs added in v0.23.0

func (p *ClientGoUtils) GetPodContainerLogs(clientset kubernetes.Interface, pod *apiv1.Pod, container string) (string, error)

func (*ClientGoUtils) GetPodLogs added in v0.23.0

func (p *ClientGoUtils) GetPodLogs(clientset kubernetes.Interface, pod *apiv1.Pod) (string, error)

func (*ClientGoUtils) GetPodsAndPodLogsFromFailedInitContainer added in v0.23.0

func (p *ClientGoUtils) GetPodsAndPodLogsFromFailedInitContainer(clientset kubernetes.Interface, lbls map[string]string, namespace, containerName string) (map[string]string, error)

func (*ClientGoUtils) GetService added in v0.23.0

func (p *ClientGoUtils) GetService(clientset kubernetes.Interface, namespace, svcName string) (*apiv1.Service, error)

func (*ClientGoUtils) LoadKubeConfigAndNamespace added in v0.23.0

func (p *ClientGoUtils) LoadKubeConfigAndNamespace() (string, []byte, error)

func (*ClientGoUtils) LogVerboseMessage added in v0.23.0

func (p *ClientGoUtils) LogVerboseMessage(strMessage string, args ...interface{})

func (*ClientGoUtils) RetryOnError added in v0.23.0

func (p *ClientGoUtils) RetryOnError(mf func() error) error

func (*ClientGoUtils) WaitForDeployment added in v0.23.0

func (p *ClientGoUtils) WaitForDeployment(clientset kubernetes.Interface, namespace string, pfDeployment *appsv1.Deployment) error

func (*ClientGoUtils) WaitForDeploymentToDelete added in v0.23.0

func (p *ClientGoUtils) WaitForDeploymentToDelete(clientset kubernetes.Interface, namespace, deploymentName string) error

func (*ClientGoUtils) WaitForPod added in v0.23.0

func (p *ClientGoUtils) WaitForPod(clientset kubernetes.Interface, namespace string, pod *apiv1.Pod) error

func (*ClientGoUtils) WaitForPodToDie added in v0.23.0

func (p *ClientGoUtils) WaitForPodToDie(clientset kubernetes.Interface, namespace string, pod *apiv1.Pod) error

type Context

type Context struct {
	Name   string `json:"name,omitempty" yaml:"name,omitempty"`
	CrFile string `json:"crFile,omitempty" yaml:"crFile,omitempty"`
}

Context is exported

type ContextSpec

type ContextSpec struct {
	Contexts       []Context `json:"contexts" yaml:"contexts"`
	CurrentContext string    `json:"currentContext" yaml:"currentContext"`
}

ContextSpec is exported

type DockerConfigJsonSecret

type DockerConfigJsonSecret struct {
	Name     string
	Uri      string
	Username string
	Password string
	Email    string
}

func (*DockerConfigJsonSecret) FromYaml

func (d *DockerConfigJsonSecret) FromYaml(secretBytes []byte, decryptionKey string) error

func (*DockerConfigJsonSecret) ToYaml

func (d *DockerConfigJsonSecret) ToYaml(encryptionKey string) ([]byte, error)

type Metadata

type Metadata struct {
	Name   string            `json:"name,omitempty" yaml:"name,omitempty"`
	Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
}

Metadata is exported

type PreflightConfig added in v0.10.0

type PreflightConfig struct {
	metav1.TypeMeta   `json:",inline" yaml:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	Spec              *PreflightSpec `json:"spec" yaml:"spec"`
	QliksenseHomePath string         `json:"-" yaml:"-"`
}

func NewPreflightConfig added in v0.10.0

func NewPreflightConfig(qHome string) *PreflightConfig

NewPreflightConfig create empty PreflightConfig object if preflit/preflight-config.yaml not exist

func NewPreflightConfigEmpty added in v0.10.0

func NewPreflightConfigEmpty(qHome string) *PreflightConfig

NewPreflightConfigEmpty create empty PreflightConfig object

func (*PreflightConfig) AddImage added in v0.10.0

func (p *PreflightConfig) AddImage(imageFor, imageName string)

func (*PreflightConfig) AddMinK8sV added in v0.10.0

func (p *PreflightConfig) AddMinK8sV(version string)

func (*PreflightConfig) AddMinMongoV added in v0.17.0

func (p *PreflightConfig) AddMinMongoV(version string)

func (*PreflightConfig) GetConfigFilePath added in v0.10.0

func (p *PreflightConfig) GetConfigFilePath() string

GetConfigFilePath return preflight-config.yaml file path

func (*PreflightConfig) GetImageMap added in v0.10.0

func (p *PreflightConfig) GetImageMap() map[string]string

func (*PreflightConfig) GetImageName added in v0.10.0

func (p *PreflightConfig) GetImageName(imageFor string, accountForImageRegistry bool) (string, error)

func (*PreflightConfig) GetMinK8sVersion added in v0.10.0

func (p *PreflightConfig) GetMinK8sVersion() string

func (*PreflightConfig) GetMinMongoVersion added in v0.17.0

func (p *PreflightConfig) GetMinMongoVersion() string

func (*PreflightConfig) Initialize added in v0.10.0

func (p *PreflightConfig) Initialize() error

func (*PreflightConfig) IsExistOnDisk added in v0.10.0

func (p *PreflightConfig) IsExistOnDisk() bool

func (*PreflightConfig) Write added in v0.10.0

func (p *PreflightConfig) Write() error

Write write PreflightConfig object into the ~/.qliksense/preflight/preflight-config.yaml file

type PreflightSpec added in v0.10.0

type PreflightSpec struct {
	MinK8sVersion   string            `json:"minK8sVersion,omitempty" yaml:"minK8sVersion,omitempty"`
	MinMongoVersion string            `json:"minMongoVersion,omitempty" yaml:"minMongoVersion,omitempty"`
	Images          map[string]string `json:"images,omitempty" yaml:"images,omitempty"`
}

type QliksenseCR

type QliksenseCR struct {
	kapi_config.KApiCr `json:",inline" yaml:",inline"`
}
type CommonConfig struct {
	metav1.TypeMeta   `json:",inline" yaml:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}

QliksenseCR is exported

func CreateCRObjectFromString

func CreateCRObjectFromString(crContent string) (*QliksenseCR, error)

CreateCRObjectFromString create a QliksenseCR from string content

func GetCRObject

func GetCRObject(crfile string) (*QliksenseCR, error)

GetCRObject create a qliksense CR object from file

func (*QliksenseCR) AddCommonConfig

func (qliksenseCR *QliksenseCR) AddCommonConfig(contextName string)

AddCommonConfig adds common configs into CRs

func (*QliksenseCR) AddLabelToCr

func (cr *QliksenseCR) AddLabelToCr(key, value string)

func (*QliksenseCR) DeleteRepo added in v0.10.0

func (cr *QliksenseCR) DeleteRepo() error

DeleteRepo delete the manifest repo and unset manifestsRoot

func (*QliksenseCR) GetCustomCrdsPath added in v0.9.15

func (cr *QliksenseCR) GetCustomCrdsPath() string

GetCustomCrdsPath get crds path if exist in the profile dir

func (*QliksenseCR) GetFetchAccessToken added in v0.10.0

func (cr *QliksenseCR) GetFetchAccessToken(encryptionKey string) string

func (*QliksenseCR) GetFetchUrl added in v0.10.0

func (cr *QliksenseCR) GetFetchUrl() string

func (*QliksenseCR) GetK8sSecretsFolder

func (cr *QliksenseCR) GetK8sSecretsFolder(qlikSenseHomeDir string) string

func (*QliksenseCR) GetLabelFromCr

func (cr *QliksenseCR) GetLabelFromCr(key string) string

func (*QliksenseCR) GetString

func (cr *QliksenseCR) GetString() (string, error)

func (*QliksenseCR) IsEULA

func (cr *QliksenseCR) IsEULA() bool

func (*QliksenseCR) IsRepoExist added in v0.9.12

func (cr *QliksenseCR) IsRepoExist() bool

func (*QliksenseCR) SetEULA

func (cr *QliksenseCR) SetEULA(value string)

func (*QliksenseCR) SetFetchAccessSecretName added in v0.10.0

func (cr *QliksenseCR) SetFetchAccessSecretName(sec string)

func (*QliksenseCR) SetFetchAccessToken added in v0.10.0

func (cr *QliksenseCR) SetFetchAccessToken(token, encryptionKey string) error

func (*QliksenseCR) SetFetchUrl added in v0.10.0

func (cr *QliksenseCR) SetFetchUrl(url string)

func (*QliksenseCR) Validate

func (cr *QliksenseCR) Validate() bool

Validate validate CR

type QliksenseConfig

type QliksenseConfig struct {
	metav1.TypeMeta   `json:",inline" yaml:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	Spec              *ContextSpec `json:"spec" yaml:"spec"`
	QliksenseHomePath string       `json:"-" yaml:"-"`
}

QliksenseConfig is exported

func NewQConfig

func NewQConfig(qsHome string) *QliksenseConfig

NewQConfig create QliksenseConfig object from file ~/.qliksense/config.yaml

func NewQConfigE

func NewQConfigE(qsHome string) (*QliksenseConfig, error)

func NewQConfigEmpty

func NewQConfigEmpty(qsHome string) *QliksenseConfig

func (*QliksenseConfig) AddBaseQliksenseConfigs

func (qliksenseConfig *QliksenseConfig) AddBaseQliksenseConfigs(defaultQliksenseContext string)

AddBaseQliksenseConfigs adds configs into config.yaml

func (*QliksenseConfig) AddToContexts

func (qc *QliksenseConfig) AddToContexts(ctx Context) error

func (*QliksenseConfig) AddToContextsRaw

func (qc *QliksenseConfig) AddToContextsRaw(crName, crFile string)

AddToContexts add the context into qc.Spec.Contexts

func (*QliksenseConfig) BuildCrFileAbsolutePath

func (qc *QliksenseConfig) BuildCrFileAbsolutePath(contextName string) string

BuildCrFileAbsolutePath build absolute path for a cr ie. ~/.qliksense/contexts/qlik-defautl/qlik-default.yaml

func (*QliksenseConfig) BuildCrFilePath

func (qc *QliksenseConfig) BuildCrFilePath(contextName string) string

BuildCrFilePath build cr file path i.e. contexts/qlik-default/qlik-default.yaml

func (*QliksenseConfig) BuildCurrentManifestsRoot

func (qc *QliksenseConfig) BuildCurrentManifestsRoot(version string) string

func (*QliksenseConfig) BuildRepoPath

func (qc *QliksenseConfig) BuildRepoPath(version string) string

func (*QliksenseConfig) BuildRepoPathForContext

func (qc *QliksenseConfig) BuildRepoPathForContext(contextName, version string) string

func (*QliksenseConfig) CreateContextDirs

func (qc *QliksenseConfig) CreateContextDirs(contextName string) error

CreateContextDirs create context dir structure ~/.qliksense/contexts/contextName

func (*QliksenseConfig) CreateOrWriteCrAndContext

func (qc *QliksenseConfig) CreateOrWriteCrAndContext(cr *QliksenseCR) error

CreateOrWriteCrAndContext create necessary folder structure, update config.yaml and context yaml files

func (*QliksenseConfig) DeletePullDockerConfigJsonSecret

func (qc *QliksenseConfig) DeletePullDockerConfigJsonSecret() error

func (*QliksenseConfig) DeletePushDockerConfigJsonSecret

func (qc *QliksenseConfig) DeletePushDockerConfigJsonSecret() error

func (*QliksenseConfig) DeleteRepoForCurrent added in v0.10.0

func (qc *QliksenseConfig) DeleteRepoForCurrent(version string) error

func (*QliksenseConfig) GetAndTransformCrObject

func (qc *QliksenseConfig) GetAndTransformCrObject(crfile string) (*QliksenseCR, error)

func (*QliksenseConfig) GetCR

func (qc *QliksenseConfig) GetCR(contextName string) (*QliksenseCR, error)

GetCR create a QliksenseCR object for a particular context from file ~/.qliksense/contexts/<contx-name>/<contx-name>.yaml

func (*QliksenseConfig) GetCRFilePath

func (qc *QliksenseConfig) GetCRFilePath(contextName string) string

func (*QliksenseConfig) GetContextPath

func (qc *QliksenseConfig) GetContextPath(contextName string) string

func (*QliksenseConfig) GetCurrentCR

func (qc *QliksenseConfig) GetCurrentCR() (*QliksenseCR, error)

GetCurrentCR create a QliksenseCR object for current context

func (*QliksenseConfig) GetCurrentContextDir

func (qc *QliksenseConfig) GetCurrentContextDir() (string, error)

func (*QliksenseConfig) GetCurrentContextEjsonKeyDir

func (qc *QliksenseConfig) GetCurrentContextEjsonKeyDir() (string, error)

func (*QliksenseConfig) GetCurrentContextSecretsDir

func (qc *QliksenseConfig) GetCurrentContextSecretsDir() (string, error)

func (*QliksenseConfig) GetDecryptedCr

func (qc *QliksenseConfig) GetDecryptedCr(cr *QliksenseCR) (*QliksenseCR, error)

GetDecryptedCr it decrypts all the encrypted value and return a new CR

func (*QliksenseConfig) GetEncryptionKeyFor added in v0.10.0

func (qc *QliksenseConfig) GetEncryptionKeyFor(contextName string) (string, error)

func (*QliksenseConfig) GetEncryptionKeyForCurrent added in v0.10.0

func (qc *QliksenseConfig) GetEncryptionKeyForCurrent() (string, error)

func (*QliksenseConfig) GetPullDockerConfigJsonSecret

func (qc *QliksenseConfig) GetPullDockerConfigJsonSecret() (*DockerConfigJsonSecret, error)

func (*QliksenseConfig) GetPushDockerConfigJsonSecret

func (qc *QliksenseConfig) GetPushDockerConfigJsonSecret() (*DockerConfigJsonSecret, error)

func (*QliksenseConfig) IsContextExist

func (qc *QliksenseConfig) IsContextExist(ctxName string) bool

func (*QliksenseConfig) IsRepoExist

func (qc *QliksenseConfig) IsRepoExist(contextName, version string) bool

func (*QliksenseConfig) IsRepoExistForCurrent

func (qc *QliksenseConfig) IsRepoExistForCurrent(version string) bool

func (*QliksenseConfig) SetCrLocation

func (qc *QliksenseConfig) SetCrLocation(contextName, filePath string) (*QliksenseConfig, error)

SetCrLocation sets the CR location for a context. Helpful during test

func (*QliksenseConfig) SetCurrentContextName

func (qc *QliksenseConfig) SetCurrentContextName(name string)

SetCurrentContextName set the qc.Spec.CurrentContext

func (*QliksenseConfig) SetPullDockerConfigJsonSecret

func (qc *QliksenseConfig) SetPullDockerConfigJsonSecret(dockerConfigJsonSecret *DockerConfigJsonSecret) error

func (*QliksenseConfig) SetPushDockerConfigJsonSecret

func (qc *QliksenseConfig) SetPushDockerConfigJsonSecret(dockerConfigJsonSecret *DockerConfigJsonSecret) error

func (*QliksenseConfig) SwitchCurrentCRToVersionAndProfile

func (qliksenseConfig *QliksenseConfig) SwitchCurrentCRToVersionAndProfile(version, profile string) error

func (*QliksenseConfig) TransformAndWriteCr

func (qc *QliksenseConfig) TransformAndWriteCr(cr *QliksenseCR, file string) error

func (*QliksenseConfig) Write

func (qc *QliksenseConfig) Write() error

Write write QliksenseConfig into config.yaml

func (*QliksenseConfig) WriteCR

func (qc *QliksenseConfig) WriteCR(cr *QliksenseCR) error

func (*QliksenseConfig) WriteCurrentContextCR

func (qc *QliksenseConfig) WriteCurrentContextCR(cr *QliksenseCR) error

type ServiceKeyValue

type ServiceKeyValue struct {
	SvcName string
	Key     string
	Value   string
}

ServiceKeyValue holds the combination of service, key and value

func ProcessConfigArgs

func ProcessConfigArgs(args []string, base64Encoded bool) ([]*ServiceKeyValue, error)

ProcessConfigArgs processes args and returns an service, key, value slice

Jump to

Keyboard shortcuts

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