api

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: Apache-2.0 Imports: 30 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"
	DefaultRotateKeys       = "yes"
	QliksenseMetadataName   = "QliksenseConfigMetadata"
	DefaultMongoDbUri       = "mongodb://qlik-default-mongodb:27017/qliksense?ssl=false"
	DefaultMongoDbUriKey    = "mongoDbUri"
)
View Source
const (
	RSA_KEY_LENGTH = 4096

	QliksensePublicKey  = "qliksensePub"
	QliksensePrivateKey = "qliksensePriv"
)

Variables

This section is empty.

Functions

func DecodeToPrivateKey

func DecodeToPrivateKey(priv []byte) (*rsa.PrivateKey, error)

DecodeToPrivateKey bytes to private key

func DecodeToPublicKey

func DecodeToPublicKey(pub []byte) (*rsa.PublicKey, error)

DecodeToPublicKey bytes to public key

func Decrypt

func Decrypt(ct []byte, priv *rsa.PrivateKey) ([]byte, error)

Decrypt decrypts data with private key

func DirExists

func DirExists(dirname string) bool

DirExists checks if a directory exists

func DownloadFile

func DownloadFile(url, baseFolder, installerName string) error

func EncodePrivateKey

func EncodePrivateKey(priv *rsa.PrivateKey) []byte

EncodePrivateKey private key to bytes

func EncodePublicKey

func EncodePublicKey(pub *rsa.PublicKey) ([]byte, error)

EncodePublicKey public key to bytes

func Encrypt

func Encrypt(pt []byte, pub *rsa.PublicKey) ([]byte, error)

Encrypt encrypts data with public key

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 GenerateAndStoreSecretKeypair

func GenerateAndStoreSecretKeypair(secretsPath string) error

GenerateAndStoreSecretKeypair generates and stores key pairs

func GenerateRSAEncryptionKeys

func GenerateRSAEncryptionKeys(publicKeyFilePath, privateKeyFilePath string) error

GenerateRSAEncryptionKeys is used to generate a new public-private key pair

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 resoruces in the provided namespace, if namespace="" then use whatever the kubectl default is

func KubectlDelete

func KubectlDelete(manifests, namespace string) error

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

func KubectlDirectOps

func KubectlDirectOps(opr []string, namespace 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 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 *rsa.PrivateKey) error

func (*DockerConfigJsonSecret) ToYaml

func (d *DockerConfigJsonSecret) ToYaml(encryptionKey *rsa.PublicKey) ([]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 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) GetCustomCrdsPath added in v0.9.15

func (cr *QliksenseCR) GetCustomCrdsPath() string

GetCustomCrdsPath get crds path if exist in the profile dir

func (*QliksenseCR) GetImageRegistry

func (cr *QliksenseCR) GetImageRegistry() 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) 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) 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) GetContextEncryptionKeyPair

func (qc *QliksenseConfig) GetContextEncryptionKeyPair(contextName string) (*rsa.PublicKey, *rsa.PrivateKey, error)

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

func (qc *QliksenseConfig) GetCurrentContextEncryptionKeyPair() (*rsa.PublicKey, *rsa.PrivateKey, 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) 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) ([]*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