profile

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: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// nocalhost-docker.pkg.coding.net/nocalhost/public/minideb:latest"
	DefaultDevImage  = ""
	DefaultWorkDir   = "/home/nocalhost-dev"
	DuplicateDevMode = DevModeType("duplicate")
	ReplaceDevMode   = DevModeType("replace")
	NoneDevMode      = DevModeType("")
)

Variables

This section is empty.

Functions

func ProfileV2Key

func ProfileV2Key(ns, app string) string

Types

type AppProfileV2

type AppProfileV2 struct {
	Name string `json:"name" yaml:"name"`

	// install/uninstall field, should move out of profile
	// Deprecated
	ChartName string `json:"chartName" yaml:"chartName,omitempty"` // This name may come from config.yaml or --helm-chart-name
	// Deprecated TODO move to appMeta
	ReleaseName string `json:"releaseName yaml:releaseName"`
	// Deprecated
	DependencyConfigMapName string `json:"dependencyConfigMapName" yaml:"dependencyConfigMapName,omitempty"`
	// Deprecated
	Installed bool `json:"installed" yaml:"installed"`
	// Deprecated
	ResourcePath RelPath `json:"resourcePath" yaml:"resourcePath"`
	// Deprecated
	IgnoredPath RelPath `json:"ignoredPath" yaml:"ignoredPath"`
	// Deprecated
	PreInstall SortedRelPath `json:"onPreInstall" yaml:"onPreInstall"`
	// Deprecated
	AppType string `json:"appType" yaml:"appType"`

	// app global field
	Namespace  string `json:"namespace" yaml:"namespace"`
	Kubeconfig string `json:"kubeconfig" yaml:"kubeconfig,omitempty"`

	// for previous version, associate path is stored in profile
	// and now it store in a standalone db
	AssociateMigrate bool `json:"associate_migrate" yaml:"associate_migrate"`

	// app global status
	Identifier string `json:"identifier" yaml:"identifier"`
	Secreted   bool   `json:"secreted" yaml:"secreted"` // always true for new versions, but from earlier version, the flag for upload profile to secret

	// svc runtime status
	SvcProfile []*SvcProfileV2 `json:"svcProfile" yaml:"svcProfile"` // This will not be nil after `dev start`, and after `dev start`, application.GetSvcProfile() should not be nil
	// contains filtered or unexported fields
}

func NewAppProfileV2ForUpdate

func NewAppProfileV2ForUpdate(ns, name, nid string) (*AppProfileV2, error)

func (*AppProfileV2) CloseDb

func (a *AppProfileV2) CloseDb() error

func (*AppProfileV2) GenerateIdentifierIfNeeded

func (a *AppProfileV2) GenerateIdentifierIfNeeded() string

this method will not save the Identifier, make sure it will be saving while use

func (*AppProfileV2) Save

func (a *AppProfileV2) Save() error

func (*AppProfileV2) SvcProfileV2

func (a *AppProfileV2) SvcProfileV2(svcName string, svcType string) *SvcProfileV2

SvcProfileV2 The result will not be nil

type ApplicationConfig

type ApplicationConfig struct {
	Name         string  `json:"name" yaml:"name,omitempty"`
	Type         string  `json:"manifestType" yaml:"manifestType,omitempty"`
	ResourcePath RelPath `json:"resourcePath" yaml:"resourcePath"`
	IgnoredPath  RelPath `json:"ignoredPath" yaml:"ignoredPath"`

	PreInstall  SortedRelPath `json:"onPreInstall" yaml:"onPreInstall"`
	PostInstall SortedRelPath `json:"onPostInstall" yaml:"onPostInstall"`
	PreUpgrade  SortedRelPath `json:"onPreUpgrade" yaml:"onPreUpgrade"`
	PostUpgrade SortedRelPath `json:"onPostUpgrade" yaml:"onPostUpgrade"`
	PreDelete   SortedRelPath `json:"onPreDelete" yaml:"onPreDelete"`
	PostDelete  SortedRelPath `json:"onPostDelete" yaml:"onPostDelete"`

	HelmValues     []*HelmValue       `json:"helmValues" yaml:"helmValues"`
	HelmVals       interface{}        `json:"helmVals" yaml:"helmVals"`
	HelmVersion    string             `json:"helmVersion" yaml:"helmVersion"`
	Env            []*Env             `json:"env" yaml:"env"`
	EnvFrom        EnvFrom            `json:"envFrom,omitempty" yaml:"envFrom,omitempty"`
	ServiceConfigs []*ServiceConfigV2 `json:"services" yaml:"services,omitempty"`
}

func (*ApplicationConfig) LoadManifests

func (c *ApplicationConfig) LoadManifests(tmpDir *fp.FilePathEnhance) []string

type ConfigProperties

type ConfigProperties struct {
	Version string `json:"version" yaml:"version"`
	EnvFile string `json:"envFile" yaml:"envFile"`
}

type ContainerConfig

type ContainerConfig struct {
	Name    string                  `validate:"Container" json:"name" yaml:"name"`
	Hub     *HubConfig              `json:"hub" yaml:"hub,omitempty"`
	Install *ContainerInstallConfig `json:"install,omitempty" yaml:"install,omitempty"`
	Dev     *ContainerDevConfig     `json:"dev" yaml:"dev"`
}

type ContainerDevConfig

type ContainerDevConfig struct {
	GitUrl                string                 `json:"gitUrl" yaml:"gitUrl"`
	Image                 string                 `json:"image" yaml:"image"`
	ImagePullPolicy       corev1.PullPolicy      `json:"imagePullPolicy,omitempty" yaml:"imagePullPolicy,omitempty"`
	Shell                 string                 `json:"shell" yaml:"shell"`
	WorkDir               string                 `json:"workDir" yaml:"workDir"`
	StorageClass          string                 `validate:"StorageClass" json:"storageClass" yaml:"storageClass"`
	DevContainerName      string                 `json:"devContainerName,omitempty" yaml:"devContainerName,omitempty"`
	DevContainerResources *ResourceQuota         `json:"resources" yaml:"resources"`
	PersistentVolumeDirs  []*PersistentVolumeDir `validate:"dive" json:"persistentVolumeDirs" yaml:"persistentVolumeDirs"`
	Command               *DevCommands           `json:"command" yaml:"command"`
	DebugConfig           *DebugConfig           `json:"debug" yaml:"debug"`
	HotReload             bool                   `json:"hotReload" yaml:"hotReload"`
	UseDevContainer       bool                   `json:"useDevContainer,omitempty" yaml:"useDevContainer,omitempty"`
	Sync                  *SyncConfig            `json:"sync" yaml:"sync"`
	Env                   []*Env                 `json:"env" yaml:"env"`
	EnvFrom               *EnvFrom               `json:"envFrom,omitempty" yaml:"envFrom,omitempty"`
	PortForward           []string               `validate:"dive,PortForward" json:"portForward" yaml:"portForward"`
	SidecarImage          string                 `json:"sidecarImage,omitempty" yaml:"sidecarImage,omitempty"`
	Patches               []base.PatchItem       `json:"patches,omitempty" yaml:"patches,omitempty"`
}

type ContainerInstallConfig

type ContainerInstallConfig struct {
	Env         []*Env   `json:"env" yaml:"env"`
	EnvFrom     EnvFrom  `json:"envFrom" yaml:"envFrom"`
	PortForward []string `json:"portForward" yaml:"portForward"`
}

type ContainerProfileV2

type ContainerProfileV2 struct {
	Name string
}

type DebugConfig

type DebugConfig struct {
	RemoteDebugPort int    `validate:"Port" json:"remoteDebugPort" yaml:"remoteDebugPort"`
	Language        string `validate:"Language" json:"language" yaml:"language"`
}

type DependLabelSelector

type DependLabelSelector struct {
	Pods []string `json:"pods" yaml:"pods"`
	Jobs []string `json:"jobs" yaml:"jobs"`
	TCP  []string `json:"tcp" yaml:"tcp"`
	HTTP []string `json:"http" yaml:"http"`
}

type DevCommands

type DevCommands struct {
	Build          []string `json:"build,omitempty" yaml:"build,omitempty"`
	Run            []string `json:"run" yaml:"run"`
	Debug          []string `json:"debug" yaml:"debug"`
	HotReloadRun   []string `json:"hotReloadRun,omitempty" yaml:"hotReloadRun,omitempty"`
	HotReloadDebug []string `json:"hotReloadDebug,omitempty" yaml:"hotReloadDebug,omitempty"`
}

type DevModeType

type DevModeType string

func (DevModeType) IsDuplicateDevMode

func (d DevModeType) IsDuplicateDevMode() bool

func (DevModeType) IsReplaceDevMode

func (d DevModeType) IsReplaceDevMode() bool

func (DevModeType) ToString

func (d DevModeType) ToString() string

type DevPortForward

type DevPortForward struct {
	LocalPort       int               `json:"localport" yaml:"localport"`
	RemotePort      int               `json:"remoteport" yaml:"remoteport"`
	Role            string            `json:"role" yaml:"role"`
	Status          string            `json:"status" yaml:"status"`
	Reason          string            `json:"reason" yaml:"reason"`
	PodName         string            `json:"podName" yaml:"podName"`
	Labels          map[string]string `json:"labels" yaml:"labels"`
	OwnerKind       string            `json:"ownerKind" yaml:"ownerKind"`
	OwnerApiVersion string            `json:"ownerApiVersion" yaml:"ownerApiVersion"`
	OwnerName       string            `json:"ownerName" yaml:"ownerName"`
	Updated         string            `json:"updated" yaml:"updated"`
	Sudo            bool              `json:"sudo" yaml:"sudo"`
	DaemonServerPid int               `json:"daemonserverpid" yaml:"daemonserverpid"`
	ServiceType     string            `json:"servicetype" yaml:"servicetype"`
}

type Env

type Env struct {
	Name  string `json:"name" yaml:"name"`
	Value string `json:"value" yaml:"value"`
}

type EnvFile

type EnvFile struct {
	Path string `json:"path" yaml:"path"`
}

type EnvFrom

type EnvFrom struct {
	EnvFile []*EnvFile `json:"envFile" yaml:"envFile"`
}

type HelmValue

type HelmValue struct {
	Key   string `json:"key" yaml:"key"`
	Value string `json:"value" yaml:"value"`
}

type HubConfig

type HubConfig struct {
	Image string `json:"image" yaml:"image"`
}

type NocalHostAppConfig

type NocalHostAppConfig struct {
	PreInstall   SortedRelPath        `json:"onPreInstall" yaml:"onPreInstall"`
	ResourcePath RelPath              `json:"resourcePath" yaml:"resourcePath"`
	SvcConfigs   []*ServiceDevOptions `json:"services" yaml:"services"`
	Name         string               `json:"name" yaml:"name"`
	Type         string               `json:"manifestType" yaml:"manifestType"`
	IgnoredPath  RelPath              `json:"ignoredPath" yaml:"ignoredPath"`
}

Deprecated

type NocalHostAppConfigV2

type NocalHostAppConfigV2 struct {
	ConfigProperties  ConfigProperties  `json:"configProperties" yaml:"configProperties"`
	Migrated          bool              `json:"migrated" yaml:"migrated"` // Only used for checking if config has migrate in meta
	ApplicationConfig ApplicationConfig `json:"application" yaml:"application"`
}

func (*NocalHostAppConfigV2) FindSvcConfigInHub

func (n *NocalHostAppConfigV2) FindSvcConfigInHub(svcName string, svcType base.SvcType, container, image string) *ServiceConfigV2

func (*NocalHostAppConfigV2) GetSvcConfigS

func (n *NocalHostAppConfigV2) GetSvcConfigS(svcName string, svcType base.SvcType) ServiceConfigV2

GetSvcConfigS If ServiceConfig not found, return a default one

func (*NocalHostAppConfigV2) GetSvcConfigV2

func (n *NocalHostAppConfigV2) GetSvcConfigV2(svcName string, svcType base.SvcType) *ServiceConfigV2

func (*NocalHostAppConfigV2) SetSvcConfigV2

func (n *NocalHostAppConfigV2) SetSvcConfigV2(svcConfig ServiceConfigV2)

type NocalhostResource

type NocalhostResource interface {
	Load(resourceDir string) []string
}

type PersistentVolumeDir

type PersistentVolumeDir struct {
	Path                 string `json:"path" yaml:"path"`
	Capacity             string `validate:"Quantity" json:"capacity,omitempty" yaml:"capacity,omitempty"`
	WaitForFirstConsumer bool   `json:"waitForFirstConsumer,omitempty" yaml:"waitForFirstConsumer,omitempty"`
}

type QuotaList

type QuotaList struct {
	Memory string `validate:"Quantity" json:"memory" yaml:"memory"`
	Cpu    string `validate:"Quantity" json:"cpu" yaml:"cpu"`
}

type RelPath

type RelPath []string

func (*RelPath) Load

func (c *RelPath) Load(fp *fp.FilePathEnhance) []string

type ResourceQuota

type ResourceQuota struct {
	Limits   *QuotaList `json:"limits" yaml:"limits"`
	Requests *QuotaList `json:"requests" yaml:"requests"`
}

type ServiceConfigV2

type ServiceConfigV2 struct {
	Name                string               `validate:"required" json:"name" yaml:"name"`
	Type                string               `validate:"required" json:"serviceType" yaml:"serviceType"`
	PriorityClass       string               `json:"priorityClass,omitempty" yaml:"priorityClass,omitempty"`
	DependLabelSelector *DependLabelSelector `json:"dependLabelSelector,omitempty" yaml:"dependLabelSelector,omitempty"`
	ContainerConfigs    []*ContainerConfig   `validate:"dive" json:"containers" yaml:"containers"`
}

func (*ServiceConfigV2) GetContainerConfig

func (s *ServiceConfigV2) GetContainerConfig(container string) *ContainerConfig

func (*ServiceConfigV2) GetContainerDevConfig

func (s *ServiceConfigV2) GetContainerDevConfig(containerName string) *ContainerDevConfig

func (*ServiceConfigV2) GetContainerDevConfigOrDefault

func (s *ServiceConfigV2) GetContainerDevConfigOrDefault(containerName string) *ContainerDevConfig

GetContainerDevConfigOrDefault Compatible for v1 Finding `containerName` config, if not found, use the first container config

func (*ServiceConfigV2) GetDefaultContainerDevConfig

func (s *ServiceConfigV2) GetDefaultContainerDevConfig() *ContainerDevConfig

type ServiceDevOptions

type ServiceDevOptions struct {
	Name                  string                 `json:"name" yaml:"name"`
	Type                  string                 `json:"serviceType" yaml:"serviceType"`
	GitUrl                string                 `json:"gitUrl" yaml:"gitUrl"`
	DevImage              string                 `json:"devContainerImage" yaml:"devContainerImage"`
	WorkDir               string                 `json:"workDir" yaml:"workDir"`
	Sync                  []string               `json:"syncDirs" yaml:"syncDirs,omitempty"` // dev start -s
	PriorityClass         string                 `json:"priorityClass,omitempty" yaml:"priorityClass,omitempty"`
	PersistentVolumeDirs  []*PersistentVolumeDir `json:"persistentVolumeDirs" yaml:"persistentVolumeDirs"`
	BuildCommand          []string               `json:"buildCommand,omitempty" yaml:"buildCommand,omitempty"`
	RunCommand            []string               `json:"runCommand,omitempty" yaml:"runCommand,omitempty"`
	DebugCommand          []string               `json:"debugCommand,omitempty" yaml:"debugCommand,omitempty"`
	HotReloadRunCommand   []string               `json:"hotReloadRunCommand,omitempty" yaml:"hotReloadRunCommand,omitempty"`
	HotReloadDebugCommand []string               `json:"hotReloadDebugCommand,omitempty" yaml:"hotReloadDebugCommand,omitempty"`
	DevContainerShell     string                 `json:"devContainerShell" yaml:"devContainerShell"`
	DevContainerResources *ResourceQuota         `json:"devContainerResources" yaml:"devContainerResources"`
	DevPort               []string               `json:"devPorts" yaml:"devPorts"`
	Jobs                  []string               `json:"dependJobsLabelSelector" yaml:"dependJobsLabelSelector,omitempty"`
	Pods                  []string               `json:"dependPodsLabelSelector" yaml:"dependPodsLabelSelector,omitempty"`
	SyncedPattern         []string               `json:"syncFilePattern" yaml:"syncFilePattern"`
	IgnoredPattern        []string               `json:"ignoreFilePattern" yaml:"ignoreFilePattern"`
}

type SortedRelPath

type SortedRelPath []*WeightablePath

func (SortedRelPath) Len

func (a SortedRelPath) Len() int

func (SortedRelPath) Less

func (a SortedRelPath) Less(i, j int) bool

func (*SortedRelPath) Load

func (c *SortedRelPath) Load(fp *fp.FilePathEnhance) []string

func (SortedRelPath) Swap

func (a SortedRelPath) Swap(i, j int)

type SvcProfile

type SvcProfile struct {
	*ServiceDevOptions `yaml:"rawConfig"`
	ActualName         string `json:"actualName" yaml:"actualName"` // for helm, actualName may be ReleaseName-Name
	Developing         bool   `json:"developing" yaml:"developing"`
	PortForwarded      bool   `json:"portForwarded" yaml:"portForwarded"`
	Syncing            bool   `json:"syncing" yaml:"syncing"`
	// same as local available port, use for port-forward
	RemoteSyncthingPort int `json:"remoteSyncthingPort" yaml:"remoteSyncthingPort"`
	// same as local available port, use for port-forward
	RemoteSyncthingGUIPort int    `json:"remoteSyncthingGUIPort" yaml:"remoteSyncthingGUIPort"`
	SyncthingSecret        string `json:"syncthingSecret" yaml:"syncthingSecret"` // secret name
	// syncthing local port
	LocalSyncthingPort                     int      `json:"localSyncthingPort" yaml:"localSyncthingPort"`
	LocalSyncthingGUIPort                  int      `json:"localSyncthingGUIPort" yaml:"localSyncthingGUIPort"`
	LocalAbsoluteSyncDirFromDevStartPlugin []string `json:"localAbsoluteSyncDirFromDevStartPlugin" yaml:"localAbsoluteSyncDirFromDevStartPlugin"`
	DevPortList                            []string `json:"devPortList" yaml:"devPortList"`
	PortForwardStatusList                  []string `json:"portForwardStatusList" yaml:"portForwardStatusList"`
	PortForwardPidList                     []string `json:"portForwardPidList" yaml:"portForwardPidList"`
	// .nhignore's pattern configuration
	SyncedPatterns  []string `json:"syncFilePattern" yaml:"syncFilePattern"`
	IgnoredPatterns []string `json:"ignoreFilePattern" yaml:"ignoreFilePattern"`
}

type SvcProfileV2

type SvcProfileV2 struct {
	//*ServiceConfigV2 `json:"rawConfig" yaml:"rawConfig"` // deprecated, move to app mate
	//ContainerProfile []*ContainerProfileV2 `json:"containerProfile" yaml:"containerProfile"`
	ActualName string `json:"actualName" yaml:"actualName"` // deprecated - for helm, actualName may be ReleaseName-Name

	// todo: Is this will conflict with ServiceConfigV2 ? by hxx
	Name string `json:"name" yaml:"name"`
	Type string `json:"serviceType" yaml:"serviceType"`

	PortForwarded bool     `json:"portForwarded" yaml:"portForwarded"`
	Syncing       bool     `json:"syncing" yaml:"syncing"`
	SyncDirs      []string `json:"syncDirs" yaml:"syncDirs,omitempty"` // dev start -s
	// same as local available port, use for port-forward
	RemoteSyncthingPort int `json:"remoteSyncthingPort" yaml:"remoteSyncthingPort"`
	// same as local available port, use for port-forward
	RemoteSyncthingGUIPort int `json:"remoteSyncthingGUIPort" yaml:"remoteSyncthingGUIPort"`
	//SyncthingSecret                     string `json:"syncthingSecret" yaml:"syncthingSecret"` // secret name
	//DuplicateDevModeSyncthingSecretName string `json:"duplicateDevModeSyncthingSecretName" yaml:"duplicateDevModeSyncthingSecretName"`
	// syncthing local port
	LocalSyncthingPort                     int               `json:"localSyncthingPort" yaml:"localSyncthingPort"`
	LocalSyncthingGUIPort                  int               `json:"localSyncthingGUIPort" yaml:"localSyncthingGUIPort"`
	LocalAbsoluteSyncDirFromDevStartPlugin []string          `json:"localAbsoluteSyncDirFromDevStartPlugin" yaml:"localAbsoluteSyncDirFromDevStartPlugin"`
	DevPortForwardList                     []*DevPortForward `json:"devPortForwardList" yaml:"devPortForwardList"` // combine DevPortList,PortForwardStatusList and PortForwardPidList

	// nocalhost supports config from local dir under "Associate" Path, it's priority is highest
	LocalConfigLoaded bool `json:"localconfigloaded" yaml:"localconfigloaded"`

	// nocalhost also supports cfg from annotations, it's priority is lower than local cfg and higher than cm cfg
	AnnotationsConfigLoaded bool `json:"annotationsconfigloaded" yaml:"annotationsconfigloaded"`

	// nocalhost also supports config from cm, lowest priority
	CmConfigLoaded bool `json:"cmconfigloaded" yaml:"cmconfigloaded"`

	// deprecated, read only, but actually store in
	// [SvcPack internal/nhctl/nocalhost/dev_dir_mapping_db.go:165]
	// associate for the local dir
	Associate string `json:"associate" yaml:"associate"`

	// deprecated
	// for earlier version of nocalhost
	// from app meta, this status return ture may under start developing (pod not ready, etc..)
	Developing bool `json:"developing" yaml:"developing"`

	// from app meta
	DevelopStatus string `json:"develop_status" yaml:"develop_status"`

	// mean the current controller is possess by current nhctl context
	// and the syncthing process is listen on current device
	Possess bool `json:"possess" yaml:"possess"`

	// LocalDevMode can be started in every local desktop and not influence each other
	DevModeType DevModeType `json:"devModeType" yaml:"devModeType"` // Used by ide plugin

	// recorded the container that enter the devmode
	// notice: exit devmode will not set this value to null
	OriginDevContainer string `json:"originDevContainer" yaml:"originDevContainer"`
}

func (*SvcProfileV2) GetName

func (s *SvcProfileV2) GetName() string

func (*SvcProfileV2) GetType

func (s *SvcProfileV2) GetType() string

type SyncConfig

type SyncConfig struct {
	Type              string   `validate:"SyncType" json:"type" yaml:"type"`
	Mode              string   `validate:"SyncMode" json:"mode,omitempty" yaml:"mode,omitempty"`
	DeleteProtection  *bool    `json:"deleteProtection,omitempty" yaml:"deleteProtection,omitempty"`
	FilePattern       []string `json:"filePattern" yaml:"filePattern"`
	IgnoreFilePattern []string `json:"ignoreFilePattern" yaml:"ignoreFilePattern"`
}

type WeightablePath

type WeightablePath struct {
	Path   string `json:"path" yaml:"path"`
	Weight string `json:"weight" yaml:"weight"`
}

Jump to

Keyboard shortcuts

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