appmeta

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEV_STA EVENT = "DEV_STA"
	DEV_END EVENT = "DEV_END"

	STARTING DevStartStatus = "STARTING"
	STARTED  DevStartStatus = "STARTED"
	NONE     DevStartStatus = "NONE"
)
View Source
const (
	SecretType       = "dev.nocalhost/application.meta"
	SecretNamePrefix = "dev.nocalhost.application."
	CmNamePrefix     = "dev.nocalhost.config."
	AnnotationKey    = "dev.nocalhost"
	CmConfigKey      = "config"

	SecretUninstallBackOffKey = "time"
	SecretHelmReleaseNameKey  = "r"
	SecretNamespaceIdKey      = "nid"
	SecretPostInstallKey      = "po"
	SecretPostUpgradeKey      = "pou"
	SecretPostDeleteKey       = "pod"
	SecretPreInstallKey       = "p"
	SecretPreUpgradeKey       = "pu"
	SecretPreDeleteKey        = "pd"
	SecretManifestKey         = "m"
	SecretDevMetaKey          = "v"
	SecretAppTypeKey          = "t"
	SecretConfigKey           = "c"
	SecretStateKey            = "s"
	SecretDepKey              = "d"

	Helm           AppType = "helmGit"
	HelmRepo       AppType = "helmRepo"
	Manifest       AppType = "rawManifest"
	ManifestGit    AppType = "rawManifestGit"
	ManifestLocal  AppType = "rawManifestLocal"
	HelmLocal      AppType = "helmLocal"
	KustomizeGit   AppType = "kustomizeGit"
	KustomizeLocal AppType = "kustomizeLocal"

	UNINSTALLED ApplicationState = "UNINSTALLED"
	INSTALLING  ApplicationState = "INSTALLING"
	INSTALLED   ApplicationState = "INSTALLED"

	UNKNOWN ApplicationState = "UNKNOWN"

	DependenceConfigMapPrefix = "nocalhost-depends-do-not-overwrite"

	DEV_STARTING_SUFFIX = ">...Starting"
	DuplicateSuffix     = "-duplicate"
)

Variables

View Source
var ErrAlreadyDev = errors.New("Svc already in dev mode")

Functions

func ConfigMapName

func ConfigMapName(appName string) string

func FillingExtField

func FillingExtField(s *profile2.SvcProfileV2, meta *ApplicationMeta, appName, ns, identifier string)

func GetAppNameFromConfigMapName

func GetAppNameFromConfigMapName(cmName string) string

func GetApplicationName

func GetApplicationName(secretName string) (string, error)

resolve Application name by k8s 'metadata.name'

func HasConfigMapPrefix

func HasConfigMapPrefix(key string) bool

func HasDevStartingSuffix

func HasDevStartingSuffix(name string) bool

Types

type AppType

type AppType string

func AppTypeOf

func AppTypeOf(s string) AppType

func (AppType) IsHelm

func (a AppType) IsHelm() bool

type ApplicationDevMeta

type ApplicationDevMeta map[base.SvcType]map[string]string

func (*ApplicationDevMeta) Events

type ApplicationEvent

type ApplicationEvent struct {
	Identifier   string
	ResourceName string
	EventType    EVENT
	DevType      base.SvcType
}

type ApplicationMeta

type ApplicationMeta struct {

	// could not be updated
	Application string `json:"application"`

	HelmReleaseName string `json:"helm_release_name"`

	// could not be updated
	Ns string `json:"ns"`

	ApplicationType  AppType          `json:"application_type"`
	ApplicationState ApplicationState `json:"application_state"`
	DepConfigName    string           `json:"dep_config_name"`

	PreInstallManifest  string `json:"pre_install_manifest"`
	PostInstallManifest string `json:"post_install_manifest"`
	PreUpgradeManifest  string `json:"pre_upgrade_manifest"`
	PostUpgradeManifest string `json:"post_upgrade_manifest"`
	PreDeleteManifest   string `json:"pre_delete_manifest"`
	PostDeleteManifest  string `json:"post_delete_manifest"`

	Manifest string `json:"manifest"`

	// back off timestamp when application uninstall
	// may invalid while inaccurate sys time
	UninstallBackOff int64 `json:"uninstall_back_off"`

	// manage the dev status of the application
	DevMeta ApplicationDevMeta `json:"dev_meta"`

	// store all the config of application
	Config *profile2.NocalHostAppConfigV2 `json:"config"`

	// something like database
	Secret *corev1.Secret `json:"secret"`

	// to distinguish same ns/app when using multiple K8s cluster
	NamespaceId string `json:"namespace_id"`
	// contains filtered or unexported fields
}

application meta is the application meta info container

func Decode

func Decode(secret *corev1.Secret) (*ApplicationMeta, error)

func FakeAppMeta

func FakeAppMeta(ns, application string) *ApplicationMeta

func (*ApplicationMeta) CheckIfSvcDeveloping

func (a *ApplicationMeta) CheckIfSvcDeveloping(name, identifier string, svcType base.SvcType, modeType profile2.DevModeType) DevStartStatus

func (*ApplicationMeta) Delete

func (a *ApplicationMeta) Delete() error

Delete a application will not actually delete the secret just make the application as UNINSTALL state and set a protect time UninstallBackOff then clean the secret data

func (*ApplicationMeta) DoWithTempOperator

func (a *ApplicationMeta) DoWithTempOperator(configBytes []byte, funny func() error) error

sometimes meta will not initail the go client, this method can present to use a temp kubeconfig for some K8s's oper

func (*ApplicationMeta) GenerateNidINE

func (a *ApplicationMeta) GenerateNidINE() error

func (*ApplicationMeta) GetApplicationConfig

func (a *ApplicationMeta) GetApplicationConfig() *profile2.ApplicationConfig

func (*ApplicationMeta) GetApplicationDevMeta

func (a *ApplicationMeta) GetApplicationDevMeta() ApplicationDevMeta

func (*ApplicationMeta) GetClient

func (*ApplicationMeta) GetCurrentDevModeTypeOfWorkload

func (a *ApplicationMeta) GetCurrentDevModeTypeOfWorkload(workloadName string, workloadType base.SvcType, identifier string) profile2.DevModeType

func (*ApplicationMeta) InitGoClient

func (a *ApplicationMeta) InitGoClient(kubeConfigPath string) error

func (*ApplicationMeta) Initial

func (a *ApplicationMeta) Initial(force bool) error

Initial initial the application, try to create a secret if not exist and it's state is INSTALLING or modify the exists secret as INSTALLING if the secret state is UNINSTALL params: force - force to re initial the appmeta, (while app uninstall, there is 10s re initial protect) if want to disable the protect, set force as true

func (*ApplicationMeta) IsHelm

func (a *ApplicationMeta) IsHelm() bool

func (*ApplicationMeta) IsInstalled

func (a *ApplicationMeta) IsInstalled() bool

func (*ApplicationMeta) IsInstalling

func (a *ApplicationMeta) IsInstalling() bool

func (*ApplicationMeta) IsNotInstall

func (a *ApplicationMeta) IsNotInstall() bool

func (*ApplicationMeta) IsUnknown

func (a *ApplicationMeta) IsUnknown() bool

func (*ApplicationMeta) NewResourceReader

func (a *ApplicationMeta) NewResourceReader() *clientgoutils.Resource

func (*ApplicationMeta) NotInstallTips

func (a *ApplicationMeta) NotInstallTips() string

func (*ApplicationMeta) OneTimesInitial

func (a *ApplicationMeta) OneTimesInitial(fun func(meta *ApplicationMeta), force bool) error

Initial initial the application, try to create a secret if not exist and it's state is INSTALLED or modify the exists secret as INSTALLED if the secret state is UNINSTALL

func (*ApplicationMeta) ProtectedFromReInstall

func (a *ApplicationMeta) ProtectedFromReInstall() bool

func (*ApplicationMeta) ReAssignmentBySecret

func (a *ApplicationMeta) ReAssignmentBySecret(secret *corev1.Secret) error

func (*ApplicationMeta) SvcDevEnd

func (a *ApplicationMeta) SvcDevEnd(name, identifier string, svcType base.SvcType, modeType profile2.DevModeType) error

func (*ApplicationMeta) SvcDevModePossessor

func (a *ApplicationMeta) SvcDevModePossessor(name string, svcType base.SvcType, identifier string, modeType profile2.DevModeType) bool

func (*ApplicationMeta) SvcDevStartComplete

func (a *ApplicationMeta) SvcDevStartComplete(name string, svcType base.SvcType, identifier string, modeType profile2.DevModeType) error

func (*ApplicationMeta) SvcDevStarting

func (a *ApplicationMeta) SvcDevStarting(name string, svcType base.SvcType, identifier string, modeType profile2.DevModeType) error

SvcDevStarting call this func first recode 'name>...starting' as developing while complete enter dev start, should call #SvcDevStartComplete to mark svc completely enter dev mode

func (*ApplicationMeta) Uninstall

func (a *ApplicationMeta) Uninstall(force bool) error

Uninstall uninstall the application and delete the secret from k8s cluster

func (*ApplicationMeta) Update

func (a *ApplicationMeta) Update() error

Update if update occurs errors, it will get a new secret from k8s, and retry update again, default retry times is 5

type ApplicationMetaSimple

type ApplicationMetaSimple struct {
	Application      string           `json:"application"`
	Ns               string           `json:"ns"`
	ApplicationState ApplicationState `json:"application_state"`
	// manage the dev status of the application
	DevMeta            ApplicationDevMeta `json:"dev_meta"`
	Manifest           string             `json:"manifest"`
	PreInstallManifest string             `json:"pre_install_manifest"`
}

type ApplicationMetaSimples

type ApplicationMetaSimples []*ApplicationMetaSimple

type ApplicationMetas

type ApplicationMetas []*ApplicationMeta

func (ApplicationMetas) Desc

func (as ApplicationMetas) Desc() (result ApplicationMetaSimples)

describe the applications meta for output

type ApplicationState

type ApplicationState string

func ApplicationStateOf

func ApplicationStateOf(s string) ApplicationState

type DevStartStatus

type DevStartStatus string

type EVENT

type EVENT string

type ApplicationDevType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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