dvoc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 22 Imported by: 0

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

Index

Constants

View Source
const (
	CommandHttp                   = "http"
	CommandEnv                    = "env"
	CommandCopyToPod              = "copyToPod"
	CommandCopyFromPod            = "copyFromPod"
	CommandMicroServiceExec       = "microserviceExec"
	CommandMicroServiceUp         = "microserviceUp"
	CommandMicroServiceUpOnly     = "microserviceUpOnly"
	CommandMicroServiceDown       = "microserviceDown"
	CommandMicroServiceSave       = "microserviceSave"
	CommandMicroServiceRestore    = "microserviceRestore"
	CommandMicroServiceCacheClean = "microserviceCacheClean"
	CommandExpose                 = "expose"
	CommandNet                    = "net"
	CommandOs                     = "os"
	CommandPortForward            = "forward"
	CommandSql                    = "sql"
)
View Source
const (
	MicroServiceDeleteForced                = 0
	MicroServiceDeleteTrySaveAndForceDelete = 1
	MicroServiceDeleteSaveAndSafeDelete     = 2
	MicroServiceSaveTemporaryFolder         = "__dobryvechir_microcore"
	MicroServiceProperty                    = "MICROSERVICE"
)
View Source
const (
	M2MTokenPrefix          = "M2M_TOKEN_"
	M2MTokenPath            = "M2MTOKEN_PATH"
	M2MAuthorizationRequest = "AuthorizationM2MService"
)
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"
)
View Source
const (
	Authorization = "Authorization"
)

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 AddProcessFunction

func AddProcessFunction(key string, processor ProcessFunction)

func CleanM2MTokenInCache

func CleanM2MTokenInCache(microserviceName string)

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 *dvjson.DvFieldInfo) (dst *dvjson.DvFieldInfo, err error)

func ConfigTransformerDc

func ConfigTransformerDc(src *dvjson.DvFieldInfo) (dst *dvjson.DvFieldInfo, err error)

func ConfigTransformerRoute

func ConfigTransformerRoute(src *dvjson.DvFieldInfo) (dst *dvjson.DvFieldInfo, err error)

func ConfigTransformerSvc

func ConfigTransformerSvc(src *dvjson.DvFieldInfo) (dst *dvjson.DvFieldInfo, err error)

func CopyToBaseFolder

func CopyToBaseFolder(baseFolder string, params string) error

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 ExecuteProcessFunction

func ExecuteProcessFunction(fn *ProcessFunction, pauseTime int, totalTime int, command string, group *sync.WaitGroup, ctx *dvmeta.RequestContext) bool

func ExecuteSequence

func ExecuteSequence(prefix string, ctx *dvmeta.RequestContext) bool

func ExecuteSingleCommand

func ExecuteSingleCommand(pauseTime int, totalTime int, prefix string, command string) 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) (*dvjson.DvFieldInfo, error)

func GetConfigurationByOpenShiftObjectTypeAndName

func GetConfigurationByOpenShiftObjectTypeAndName(objectName string, openShiftObjectType string) (*dvjson.DvFieldInfo, error)

func GetExistingFullOpenShiftTemplate

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

func GetIdentityProviderClientCredentials

func GetIdentityProviderClientCredentials(microServiceName string) (user string, pw string, ok bool)

func GetKubernetesConfigurationPart

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

func GetLiveConfiguration

func GetLiveConfiguration(cmdLine string) (*dvjson.DvFieldInfo, error)

func GetLiveDeploymentConfiguration

func GetLiveDeploymentConfiguration(microServiceName string) (*dvjson.DvFieldInfo, error)

func GetM2MToken

func GetM2MToken(microserviceName string) (token string, okFinal bool)

func GetM2MTokenFromFileSystem

func GetM2MTokenFromFileSystem(microserviceName string) (token string, ok bool)

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 GetMicroServicePropertyName

func GetMicroServicePropertyName(microServiceName string) string

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 MicroServiceRestoration

func MicroServiceRestoration(microServiceName string, templateFileName string) error

func NetRequest

func NetRequest(method string, url string, body string, headers map[string]string, options map[string]interface{}) ([]byte, error)

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 []*dvjson.DvFieldInfo, silent bool) (res []*dvjson.DvFieldInfo, err error)

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 *dvjson.DvFieldInfo, err error)

func ReadPodReadyEnvironment

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

func ReadTemplateParameters

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

func ReduceMicroServiceSaveInfo

func ReduceMicroServiceSaveInfo(microServiceName string)

func RegisterOC

func RegisterOC() bool

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 SaveM2MTokenInFileSystem

func SaveM2MTokenInFileSystem(microserviceName string, accessToken *AccessToken)

func SaveMicroServiceOpenShiftInfo

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

func SaveOpenshiftSecret

func SaveOpenshiftSecret(folder string, microServiceName string) bool

func SmartNetInit

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

func SmartNetRun

func SmartNetRun(data []interface{}) bool

func SmartNetRunByConfig

func SmartNetRunByConfig(config *SmartNetConfig, ctx *dvmeta.RequestContext) 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 AccessToken

type AccessToken struct {
	AccessToken      string `json:"access_token"`
	TokenType        string `json:"token_type"`
	ExpiresIn        int    `json:"expires_in"`
	RefreshExpiresIn int    `json:"refresh_expires_in"`
	RefreshToken     string `json:"refresh_token"`
	NotBeforePolicy  int    `json:"not-before-policy"`
	SessionState     string `json:"session_state"`
	Scope            string `json:"scope"`
}

type ConfigTransformer

type ConfigTransformer func(*dvjson.DvFieldInfo) (*dvjson.DvFieldInfo, 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 ProcessFunction

type ProcessFunction struct {
	Init  func(command string, ctx *dvmeta.RequestContext) ([]interface{}, bool)
	Run   func([]interface{}) bool
	Async bool
}

type SmartNetConfig

type SmartNetConfig struct {
	Url      string                 `json:"url"`
	Method   string                 `json:"method"`
	Headers  string                 `json:"headers"`
	Template SmartNetConfigTemplate `json:"template"`
	Result   string                 `json:"result"`
	Body     string                 `json:"body"`
}

type SmartNetConfigTemplate

type SmartNetConfigTemplate struct {
	Src string `json:"src"`
	Dst string `json:"dst"`
}

Jump to

Keyboard shortcuts

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