dvoc

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 21 Imported by: 2

Documentation

Overview

********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2020 - 2021 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

Index

Constants

View Source
const (
	CommandCopyToPod              = "copyToPod"
	CommandCopyFromPod            = "copyFromPod"
	CommandEnv                    = "env"
	CommandExpose                 = "expose"
	CommandMicroServiceCacheClean = "microserviceCacheClean"
	CommandMicroServiceDown       = "microserviceDown"
	CommandMicroServiceExec       = "microserviceExec"
	CommandMicroServiceSave       = "microserviceSave"
	CommandMicroServiceTemplate   = "microserviceTemplate"
	CommandMicroServiceRestore    = "microserviceRestore"
	CommandMicroServiceUp         = "microserviceUp"
	CommandMicroServiceUpOnly     = "microserviceUpOnly"
)
View Source
const (
	MicroServiceDeleteForced                = 0
	MicroServiceDeleteTrySaveAndForceDelete = 1
	MicroServiceDeleteSaveAndSafeDelete     = 2
	MicroServiceSaveTemporaryFolder         = "__dobryvechir_microcore"
	MicroServiceProperty                    = "MICROSERVICE"
)
View Source
const (
	LogFatal   = 0
	LogError   = 1
	LogWarning = 2
	LogInfo    = 3
	LogDetail  = 4
	LogDebug   = 5
	LogTrace   = 6
)
View Source
const (
	OcPostgreSql                          = "postgresql"
	OcMongoDb                             = "mongodb"
	DbaaSServerUrlTemplateProperty        = "DBAAS_SERVER"
	DbaaSServerUrlDefault                 = "{dbaas-agent}/api/v1/dbaas/{{{OPENSHIFT_NAMESPACE}}}/databases"
	DbaaSRequestMethodProperty            = "DBAAS_REQUEST_METHOD"
	DbaaSRequestMethod                    = "PUT"
	DbaaSRequestBodyTenantAwareProperty   = "DBAAS_REQUEST_TENANT_AWARE"
	DbaaSRequestBodyTenantUnawareProperty = "DBAAS_REQUEST_TENANT_UNAWARE"
	DbaaSRequestBodyTenantAwareDefault    = "" /* 308-byte string literal not displayed */
	DbaaSRequestBodyTenantUnawareDefault  = "" /* 279-byte string literal not displayed */
)
View Source
const (
	StrategyReadWriteSingleFileBest    = 0
	StrategyReadWriteSingleFileThruCat = 1
	StrategyReadWriteSingleFileThruDir = 2
)
View Source
const (
	MicroserviceUrlProperty           = "MICROSERVICE_PATH_"
	ApplicationInsideCloud            = "APPLICATION_INSIDE_CLOUD"
	MicroServiceExposedRoute          = "http://{SERVICE}-{{{OPENSHIFT_NAMESPACE}}}.{{{OPENSHIFT_SERVER}}}.{{{OPENSHIFT_DOMAIN}}}"
	MicroServiceInternalRoute         = "http://{SERVICE}:8080"
	MicroServiceExposedRouteTemplate  = "MICROSERVICE_EXPOSED_ROUTE_TEMPLATE"
	MicroServiceInternalRouteTemplate = "MICROSERVICE_INTERNAL_ROUTE_TEMPLATE"
)
View Source
const (
	TenantIdProperty = "TENANT_ID"
	TenantProperty   = "TENANT"
)

Variables

View Source
var (
	TenantResolvePropertyPrefix     = "TENANT_RESOLVER"
	TenantResolveUrlTemplateDefault = "{public-gateway}/api/v2/tenant-manager/registration/tenants?dns={TENANT}"
	TenantResolveMethodDefault      = "GET"
	TenantResolveBodyDefault        = ""
)
View Source
var Log = LogError
View Source
var StragegyReadWriteSingleFileThruDirExclude = make(map[string]bool)
View Source
var StrategyReadWriteSingleFile = StrategyReadWriteSingleFileThruCat
View Source
var TemplateObjectPriority = map[string]int{
	"deploymentconfig": 1,
	"imagestream":      2,
	"service":          3,
	"configmap":        4,
	"route":            5,
	"serviceaccount":   6,
	"secret":           7,
}

Functions

func ComposeOpenShiftJsonTemplate

func ComposeOpenShiftJsonTemplate(params map[string]string) ([]byte, error)

func ComposeOpenShiftJsonTemplateBySample

func ComposeOpenShiftJsonTemplateBySample(sample string, requiredParams map[string]string, params map[string]string) ([]byte, error)

func ConfigTransformerConfigMap

func ConfigTransformerConfigMap(src *dvevaluation.DvVariable) (dst *dvevaluation.DvVariable, err error)

func ConfigTransformerDc

func ConfigTransformerDc(src *dvevaluation.DvVariable) (dst *dvevaluation.DvVariable, err error)

func ConfigTransformerRoute

func ConfigTransformerRoute(src *dvevaluation.DvVariable) (dst *dvevaluation.DvVariable, err error)

func ConfigTransformerSvc

func ConfigTransformerSvc(src *dvevaluation.DvVariable) (dst *dvevaluation.DvVariable, err error)

func CopyFromPodInit added in v1.0.2

func CopyFromPodInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func CopyFromPodRun added in v1.0.2

func CopyFromPodRun(data []interface{}) bool

func CopyToBaseFolder

func CopyToBaseFolder(baseFolder string, params string) error

func CopyToPodInit added in v1.0.2

func CopyToPodInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func CopyToPodRun added in v1.0.2

func CopyToPodRun(data []interface{}) bool

func CreateClientCredentials

func CreateClientCredentials(user string, pw string, microserviceName string) bool

func CreateMicroService

func CreateMicroService(params map[string]string, files map[string]string, commands []string) bool

func DeletePod

func DeletePod(name string) bool

func DownMicroServiceCommands

func DownMicroServiceCommands(deleteInfo []string) (ok bool)

func DownWholeMicroService

func DownWholeMicroService(microServiceName string, mode int, debugNotSaved bool) bool

func DownWholeMicroServiceHard

func DownWholeMicroServiceHard(microServiceName string, microServiceAliases string, includeList []string) bool

func EnsureTenantIdInGlobalProperties

func EnsureTenantIdInGlobalProperties() bool

func ExecuteCommandOnPod

func ExecuteCommandOnPod(name string, command string) (info string, err error)

func ExecuteCommandOnPodByPodName

func ExecuteCommandOnPodByPodName(podName string, command string) (info string, err error)

func ExecuteCommandOnSpecificPod

func ExecuteCommandOnSpecificPod(podName string, command string) (info string, err error)

func ExecuteCommandsOnPod

func ExecuteCommandsOnPod(microServiceName string, commands []string) bool

func ExposeMicroServiceInit added in v1.0.2

func ExposeMicroServiceInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func ExposeMicroServiceRun added in v1.0.2

func ExposeMicroServiceRun(data []interface{}) bool

func FindAddHeaderInNginxConfig

func FindAddHeaderInNginxConfig(data string, headerName string, afterPos int) (posStart int, posEnd int)

func FixContentSecurityPolicyLine

func FixContentSecurityPolicyLine(originalLine string, source string) string

func GetConfigurationByOpenShiftObjectType

func GetConfigurationByOpenShiftObjectType(microServiceName string, openShiftObjectType string) (*dvevaluation.DvVariable, error)

func GetConfigurationByOpenShiftObjectTypeAndName

func GetConfigurationByOpenShiftObjectTypeAndName(objectName string, openShiftObjectType string) (*dvevaluation.DvVariable, error)

func GetExistingFullOpenShiftTemplate

func GetExistingFullOpenShiftTemplate(microServiceName string, notCritical bool) (deployment string, deleteInfo []string, services []string, routes []string, configMaps []string, errFinal error)

func GetKubernetesConfigurationPart

func GetKubernetesConfigurationPart(cmdLine string, kind string, mode int, fn ConfigTransformer, notCritical bool) (string, error)

func GetLiveConfiguration

func GetLiveConfiguration(cmdLine string) (*dvevaluation.DvVariable, error)

func GetLiveDeploymentConfiguration

func GetLiveDeploymentConfiguration(microServiceName string) (*dvevaluation.DvVariable, error)

func GetMicroServiceConfigMaps

func GetMicroServiceConfigMaps(microServiceName string, notCritical bool) ([]string, []string, error)

func GetMicroServiceDeploymentConfigs

func GetMicroServiceDeploymentConfigs(microServiceName string, notCritical bool) ([]string, error)

func GetMicroServiceFullList

func GetMicroServiceFullList() ([]string, error)

func GetMicroServiceRouteConfigs

func GetMicroServiceRouteConfigs(routes []string, notCritical bool) ([]string, error)

func GetMicroServiceRoutes

func GetMicroServiceRoutes(services []string) ([]string, error)

func GetMicroServiceServiceConfigs

func GetMicroServiceServiceConfigs(services []string, notCritical bool) ([]string, error)

func GetMicroServiceServices

func GetMicroServiceServices(microServiceName string) ([]string, error)

func GetObjectFullList

func GetObjectFullList(shortName string) ([]string, error)

func GetObjectFullListByObjectType

func GetObjectFullListByObjectType(openShiftObjectType string) ([]string, error)

func GetOpenshiftSecrets

func GetOpenshiftSecrets(microserviceName string) (user string, ps string, okFinal bool)

func GetParamByMapOrGlobal

func GetParamByMapOrGlobal(params map[string]string, key string, baseName string) (res string)

func GetPodName

func GetPodName(microserviceName string, silent bool) (name string, ok bool)

func GetRsyncOptionsForSingleFile

func GetRsyncOptionsForSingleFile(fileName string) string

func GetShortOpenShiftNameForObjectType

func GetShortOpenShiftNameForObjectType(openShiftObjectType string) (string, error)

func GetSpecificVariableAtServer

func GetSpecificVariableAtServer(microServiceName string, key string) (data string, err error)

func GetStartEndPartsOfGeneralTemplate

func GetStartEndPartsOfGeneralTemplate(microServiceName string) (string, string, map[string]string)

func GetUrlByGlobalPropertiesAndService

func GetUrlByGlobalPropertiesAndService(globalUrlTemplatePropertyName, defaultUrlTemplate, serviceName string) (string, error)

func InitBySettings

func InitBySettings(parameters map[string]string, functionPool map[string]interface{})

func IntroduceContentSecurityPolicyInNginxConfig

func IntroduceContentSecurityPolicyInNginxConfig(data string, hosts string) string

func IsMicroServicePresent

func IsMicroServicePresent(name string) (bool, error)

func MicroServiceCacheCleanInit added in v1.0.2

func MicroServiceCacheCleanInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func MicroServiceCacheCleanRun added in v1.0.2

func MicroServiceCacheCleanRun(data []interface{}) bool

func MicroServiceDownInit added in v1.0.2

func MicroServiceDownInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func MicroServiceDownRun added in v1.0.2

func MicroServiceDownRun(data []interface{}) bool

func MicroServiceExecInit added in v1.0.2

func MicroServiceExecInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func MicroServiceExecRun added in v1.0.2

func MicroServiceExecRun(data []interface{}) bool

func MicroServiceRestoration

func MicroServiceRestoration(microServiceName string, templateFileName string) error

func MicroServiceRestoreInit added in v1.0.2

func MicroServiceRestoreInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func MicroServiceRestoreRun added in v1.0.2

func MicroServiceRestoreRun(data []interface{}) bool

func MicroServiceSaveInit added in v1.0.2

func MicroServiceSaveInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func MicroServiceSaveRun added in v1.0.2

func MicroServiceSaveRun(data []interface{}) bool

func MicroServiceSaveSingle added in v1.0.2

func MicroServiceSaveSingle(microServiceName string, folder string) (createFile string, deleteFile string, ok bool)

func MicroServiceTemplateInit added in v1.0.2

func MicroServiceTemplateInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func MicroServiceTemplateRun added in v1.0.2

func MicroServiceTemplateRun(data []interface{}) bool

func MicroServiceUpInit added in v1.0.2

func MicroServiceUpInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func MicroServiceUpOnlyRun added in v1.0.2

func MicroServiceUpOnlyRun(data []interface{}) bool

func MicroServiceUpRun added in v1.0.2

func MicroServiceUpRun(data []interface{}) bool

func OcLogin

func OcLogin() bool

func OpenShiftAddRoutesTOBeExposed

func OpenShiftAddRoutesTOBeExposed(routeList string)

func OpenShiftConvertListToMap

func OpenShiftConvertListToMap(list string) (res map[string][]string, ok bool)

func OpenShiftCopyFileFromPod

func OpenShiftCopyFileFromPod(fileName string, podName string, strategy int) error

func OpenShiftCopyFileToPod

func OpenShiftCopyFileToPod(fileName string, podName string, strategy int) error

func OpenShiftCopyFolderFromPod

func OpenShiftCopyFolderFromPod(folderName string, fullPodName string) error

func OpenShiftCopyFolderToPod

func OpenShiftCopyFolderToPod(folderName string, fullPodName string) error

func OpenShiftEnsureExposeRoutes

func OpenShiftEnsureExposeRoutes() bool

func OpenShiftExposeSpecificRoutes

func OpenShiftExposeSpecificRoutes(routes []string) bool

func OpenShiftGetPodNameAndPath

func OpenShiftGetPodNameAndPath(name string) (tmpFolder string, serviceName, podName string, pathName string, fileName string, err error)

func OpenShiftNginxRestart

func OpenShiftNginxRestart(name string) error

func OpenShiftReadTextFile

func OpenShiftReadTextFile(name string, strategy int) (data string, err error)

func OpenShiftReset

func OpenShiftReset(list string) bool

func OpenShiftResetUp

func OpenShiftResetUp(service string)

func OpenShiftScale

func OpenShiftScale(list string, replicas int) bool

func OpenShiftScaleToReplicas

func OpenShiftScaleToReplicas(microService string, replicas int) bool

func OpenShiftSetEnv

func OpenShiftSetEnv(list string) bool

** For environment variable changes: When an old value is set, openshift automatically does nothing When a new value is set, openshift makes a change to the deployment config and an old pod is destroyed and a new pod is created and started

func OpenShiftSetEnvironment

func OpenShiftSetEnvironment(microService string, env []string) bool

func OpenShiftWriteTextFile

func OpenShiftWriteTextFile(name string, data string, strategy int) error

func OrderTemplateObjectsByDependencies

func OrderTemplateObjectsByDependencies(objects []*dvevaluation.DvVariable, silent bool) (res []*dvevaluation.DvVariable, err error)

func ProcessEnvSettingInit added in v1.0.2

func ProcessEnvSettingInit(command string, ctx *dvcontext.RequestContext) ([]interface{}, bool)

func ProcessEnvSettingsRun added in v1.0.2

func ProcessEnvSettingsRun(data []interface{}) bool

func PropertyForSpecificMicroService

func PropertyForSpecificMicroService(microServiceName string, prefix string) string

func ReadDirectoryFromPod

func ReadDirectoryFromPod(podName string, distributionFolder string, podFolder string, options string) bool

func ReadPodEnvironmentAndDC

func ReadPodEnvironmentAndDC(microServiceName string) (res map[string]string, dc *dvevaluation.DvVariable, err error)

func ReadPodReadyEnvironment

func ReadPodReadyEnvironment(microServiceName string) (res map[string]string, dc *dvevaluation.DvVariable, err error)

func ReadTemplateParameters

func ReadTemplateParameters(templateData []byte) (res map[string]string, obj *dvevaluation.DvVariable, err error)

func ReduceMicroServiceSaveInfo

func ReduceMicroServiceSaveInfo(microServiceName string)

func RegisterUserCredentialsWithIdentityProvider

func RegisterUserCredentialsWithIdentityProvider(user, pw, microServiceName string, onBehalfMicroserviceName string, tmpSuffix string) bool

func ResetPodNameCache

func ResetPodNameCache()

func ResolveMicroServiceUrl

func ResolveMicroServiceUrl(microServiceName string) (string, error)

func ResolveMostSimilarObjectByMicroserviceNameAndObjectType

func ResolveMostSimilarObjectByMicroserviceNameAndObjectType(microServiceName string, objectType string) (name string, ok bool)

func ResolveTenantIdByTenant

func ResolveTenantIdByTenant(tenant string) (string, error)

func ResolveUrlRequestByGlobalPropertiesAndDefaults

func ResolveUrlRequestByGlobalPropertiesAndDefaults(prefix string, defaultMethod string, defaultUrl string, defaultBody string, headers map[string]string, replacer map[string]string) (string, error)

func ResolveUrlTemplate

func ResolveUrlTemplate(globalPropertiesTemplate string, defaultTemplate string) (string, error)

func RunOCCommand

func RunOCCommand(params string) (string, bool)

func RunOCCommandFailureAllowed

func RunOCCommandFailureAllowed(params string, allowedFailureMessages []string) (string, int)

func RunOCCommandLoginUnsafe

func RunOCCommandLoginUnsafe(params string, allowedFailureMessages []string, envParams []string) (string, int)

func RunOCCommandOrCache

func RunOCCommandOrCache(cmdLine string) (string, error)

func RunOCCommandOrCacheFailureAllowed

func RunOCCommandOrCacheFailureAllowed(cmdLine string, allowedFailureMessages []string) (string, error)

func RunOCCommandWithEditor

func RunOCCommandWithEditor(params string) (string, bool)

func SaveMicroServiceOpenShiftInfo

func SaveMicroServiceOpenShiftInfo(microServiceName string, save int) (deleteInfo []string, deployment string, ok bool)

func SaveOpenshiftSecret

func SaveOpenshiftSecret(folder string, microServiceName string) bool

func UpdateContentSecurityPolicyOnPods

func UpdateContentSecurityPolicyOnPods(pods string, hosts string) bool

func UploadFiles

func UploadFiles(microServiceName string, fileMap map[string]string, commands []string) bool

func WaitPodIsReady

func WaitPodIsReady(microServiceName string) bool

func WriteDirectoryToPod

func WriteDirectoryToPod(podName string, distributionFolder string, podFolder string, options string) bool

Types

type ConfigTransformer

type ConfigTransformer func(*dvevaluation.DvVariable) (*dvevaluation.DvVariable, error)

type ConnectionPropertiesInfo

type ConnectionPropertiesInfo struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Url      string `json:"url"`
	DbName   string `json:"name"`
	UserName string `json:"username"`
	Password string `json:"password"`
}

type DbaasInfo

type DbaasInfo struct {
	ConnectionProperties ConnectionPropertiesInfo `json:"connectionProperties"`
}

func GetDbaasProperties

func GetDbaasProperties(microServiceName string, m2mToken string, database string, tenantId string) (*DbaasInfo, error)

type MicroServiceSearch added in v1.0.2

type MicroServiceSearch struct {
	MicroServices string `json:"services"`
	WorkFolder    string `json:"folder"`
	Options       string `json:"options"`
	Output        string `json:"output"`
}

Jump to

Keyboard shortcuts

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