controller

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: 46 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	IdentifierKey         = "identifier"
	OriginWorkloadNameKey = "origin-workload-name"
	OriginWorkloadTypeKey = "origin-workload-type"

	EnvoySidecarImage         = "nocalhost-docker.pkg.coding.net/nocalhost/public/nocalhost-envoy:v1"
	MeshControlPlaneImage     = "nocalhost-docker.pkg.coding.net/nocalhost/public/nocalhost-control-plane:v1"
	MeshManager               = "mesh-manager"
	AnnotationMeshEnable      = "dev.mesh.nocalhost.dev"
	AnnotationMeshUuid        = "dev.mesh.nocalhost.dev/uuid"
	AnnotationMeshType        = "dev.mesh.nocalhost.dev/type"
	AnnotationMeshHeaderKey   = "dev.mesh.nocalhost.dev/header-key"
	AnnotationMeshHeaderValue = "dev.mesh.nocalhost.dev/header-value"
	AnnotationMeshPort        = "dev.mesh.nocalhost.dev/port"
	AnnotationMeshTypeDev     = "dev"
	AnnotationMeshTypeOrigin  = "origin"
	EnvoyMeshSidecarName      = "nocalhost-mesh"
)
View Source
const (
	OriginSpecJson = "nocalhost.origin.spec.json" // deprecated
)

Variables

This section is empty.

Functions

func AddEnvoySidecarForMesh

func AddEnvoySidecarForMesh(spec *v1.PodTemplateSpec) (exist bool)

func GetAnnotationFromUnstructured

func GetAnnotationFromUnstructured(u *unstructured.Unstructured, key string) (string, error)

GetAnnotationFromUnstructured get annotation from unstructured

func GetDefaultPodName

func GetDefaultPodName(ctx context.Context, p *Controller) (string, error)

func GetOriginalContainers

func GetOriginalContainers(client *clientgoutils.ClientGoUtils, workloadType base.SvcType, workloadName, path string) ([]v1.Container, error)

func GetPodTemplateFromSpecPath

func GetPodTemplateFromSpecPath(path string, unstructuredObj map[string]interface{}) (*corev1.PodTemplateSpec, error)

func GetSvcConfig

func GetSvcConfig(ns, appName, svcName, kubeconfig string, svcType base.SvcType) (*profile.ServiceConfigV2, error)

func GetUnstructuredMapByPath

func GetUnstructuredMapByPath(path string, u map[string]interface{}) (map[string]interface{}, error)

GetUnstructuredMapByPath Path must be like: /spec/template

func IsResourcesLimitTooLow

func IsResourcesLimitTooLow(r *corev1.ResourceRequirements) bool

IsResourcesLimitTooLow Check if resource limit is lower than 2 cpu, 2Gi men

func RemoveUselessInfo

func RemoveUselessInfo(u *unstructured.Unstructured)

func StopPortForward

func StopPortForward(ns, nid, app, svc string, portForward *profile.DevPortForward) error

func UpdateSvcConfig

func UpdateSvcConfig(ns, appName, kubeconfig string, config *profile.ServiceConfigV2) error

Types

type ContainerDevEnv

type ContainerDevEnv struct {
	DevEnv []*profile.Env
}

type Controller

type Controller struct {
	NameSpace   string
	AppName     string
	Name        string
	Identifier  string
	DevModeType profile.DevModeType
	Type        base.SvcType
	Client      *clientgoutils.ClientGoUtils
	AppMeta     *appmeta.ApplicationMeta

	DevModeAction base.DevModeAction
	// contains filtered or unexported fields
}

Controller presents a k8s controller https://kubernetes.io/docs/concepts/architecture/controller

func NewController

func NewController(ns, name, appName, identifier string, svcType base.SvcType,
	client *clientgoutils.ClientGoUtils, appMeta *appmeta.ApplicationMeta) (*Controller, error)

func (*Controller) AddPortForwardToDB

func (c *Controller) AddPortForwardToDB(port *profile.DevPortForward) error

You should `CheckIfPortForwardExists` before adding a port-forward to db

func (*Controller) BuildPodController

func (c *Controller) BuildPodController() pod_controller.PodController

func (*Controller) CheckDevModePodIsRunning

func (c *Controller) CheckDevModePodIsRunning() (string, error)

func (*Controller) CheckIfExist

func (c *Controller) CheckIfExist() error

func (*Controller) CheckIfPortForwardExists

func (c *Controller) CheckIfPortForwardExists(localPort, remotePort int) (bool, error)

func (*Controller) Config

func (c *Controller) Config() *profile.ServiceConfigV2

func (*Controller) CreateSyncThingSecret

func (c *Controller) CreateSyncThingSecret(container string, localSyncDir []string, duplicateDevMode bool) error

func (*Controller) DecreaseDevModeCount

func (c *Controller) DecreaseDevModeCount() error

func (*Controller) DeletePortForwardFromDB

func (c *Controller) DeletePortForwardFromDB(localPort, remotePort int) error

func (*Controller) DevEnd

func (c *Controller) DevEnd(reset bool) error

func (*Controller) DuplicateModeRollBack

func (c *Controller) DuplicateModeRollBack() error

func (*Controller) EndDevPortForward

func (c *Controller) EndDevPortForward(localPort int, remotePort int) error

func (*Controller) EnterPodTerminal

func (c *Controller) EnterPodTerminal(podName, container, shell, banner string) error

EnterPodTerminal Try to use shell defined in devContainerShell to enter pod's terminal If devContainerShell is not defined or shell defined in devContainerShell failed to enter terminal, use /bin/sh If container not specified, the first container will be used

func (*Controller) FindOutSyncthingProcess

func (c *Controller) FindOutSyncthingProcess(whileProcessFound func(int) error) error

func (*Controller) GetAppConfig

func (c *Controller) GetAppConfig() *profile.NocalHostAppConfigV2

func (*Controller) GetAppProfile

func (c *Controller) GetAppProfile() (*profile.AppProfileV2, error)

func (*Controller) GetContainerImage

func (c *Controller) GetContainerImage(container string) (string, error)

func (*Controller) GetContainers

func (c *Controller) GetContainers() ([]v1.Container, error)

func (*Controller) GetCurrentDevModeType

func (c *Controller) GetCurrentDevModeType() profile.DevModeType

func (*Controller) GetDescription

func (c *Controller) GetDescription() *profile.SvcProfileV2

func (*Controller) GetDevContainerEnv

func (c *Controller) GetDevContainerEnv(container string) *ContainerDevEnv

func (*Controller) GetDevContainerName

func (c *Controller) GetDevContainerName(container string) string

func (*Controller) GetDevImage

func (c *Controller) GetDevImage(container string) string

func (*Controller) GetDevModePodName

func (c *Controller) GetDevModePodName() (string, error)

func (*Controller) GetDevSidecarImage

func (c *Controller) GetDevSidecarImage(container string) string

func (*Controller) GetDevSidecarLanguage

func (c *Controller) GetDevSidecarLanguage(container string) string

func (*Controller) GetDuplicateModePodList

func (c *Controller) GetDuplicateModePodList() ([]v1.Pod, error)

func (*Controller) GetImagePullPolicy

func (c *Controller) GetImagePullPolicy(container string) corev1.PullPolicy

func (*Controller) GetOriginalContainers

func (c *Controller) GetOriginalContainers() ([]v1.Container, error)

func (*Controller) GetPVCsBySvc

func (c *Controller) GetPVCsBySvc() ([]v1.PersistentVolumeClaim, error)

GetPVCsBySvc Get all PersistVolumeClaims created by specified service

func (*Controller) GetPersistentVolumeDirs

func (c *Controller) GetPersistentVolumeDirs(container string) []*profile.PersistentVolumeDir

func (*Controller) GetPodList

func (c *Controller) GetPodList() ([]corev1.Pod, error)

GetPodList If in Replace DevMode and DevModeAction.Create is true, return pods of generated deployment Others, return pods of the workload

func (*Controller) GetPodTemplate

func (c *Controller) GetPodTemplate() (*corev1.PodTemplateSpec, error)

func (*Controller) GetPortForward

func (c *Controller) GetPortForward(localPort, remotePort int) (*profile.DevPortForward, error)

GetPortForward If not found return err

func (*Controller) GetPortForwardForSync

func (c *Controller) GetPortForwardForSync() (*profile.DevPortForward, error)

func (*Controller) GetProfile

func (c *Controller) GetProfile() (*profile.SvcProfileV2, error)

func (*Controller) GetProfileForUpdate

func (c *Controller) GetProfileForUpdate() (*profile.AppProfileV2, error)

GetProfileForUpdate You need to closeDB for profile explicitly

func (*Controller) GetStorageClass

func (c *Controller) GetStorageClass(container string) string

func (*Controller) GetSyncDir

func (c *Controller) GetSyncDir() string

func (*Controller) GetSyncThingPid

func (c *Controller) GetSyncThingPid() (int, error)

func (*Controller) GetSyncThingPidFile

func (c *Controller) GetSyncThingPidFile() string

func (*Controller) GetSyncThingSecretName

func (c *Controller) GetSyncThingSecretName() string

func (*Controller) GetTypeMeta

func (c *Controller) GetTypeMeta() (metav1.TypeMeta, error)

func (*Controller) GetUnstructured

func (c *Controller) GetUnstructured() (unstructuredMap *unstructured.Unstructured, err error)

func (*Controller) GetWorkDir

func (c *Controller) GetWorkDir(container string) string

func (*Controller) IncreaseDevModeCount

func (c *Controller) IncreaseDevModeCount() error

func (*Controller) IsInDevMode

func (c *Controller) IsInDevMode() bool

func (*Controller) IsInDevModeStarting

func (c *Controller) IsInDevModeStarting() bool

func (*Controller) IsInDuplicateDevMode

func (c *Controller) IsInDuplicateDevMode() bool

func (*Controller) IsInDuplicateDevModeStarting

func (c *Controller) IsInDuplicateDevModeStarting() bool

func (*Controller) IsInReplaceDevMode

func (c *Controller) IsInReplaceDevMode() bool

IsInReplaceDevMode return true if under dev starting or start complete

func (*Controller) IsInReplaceDevModeStarting

func (c *Controller) IsInReplaceDevModeStarting() bool

func (*Controller) IsPortForwarding

func (c *Controller) IsPortForwarding() bool

func (*Controller) IsProcessor

func (c *Controller) IsProcessor() bool

IsProcessor Check if service is developing in this device

func (*Controller) ListHPA

func (*Controller) ListPodOfGeneratedDeployment

func (c *Controller) ListPodOfGeneratedDeployment() ([]corev1.Pod, error)

func (*Controller) LoadConfigFromHub

func (c *Controller) LoadConfigFromHub() error

func (*Controller) LoadConfigFromHubC

func (c *Controller) LoadConfigFromHubC(container string) error

func (*Controller) NewSyncthing

func (c *Controller) NewSyncthing(container string, localSyncDir []string, syncDouble bool) (
	*syncthing.Syncthing, error,
)

func (*Controller) NewSyncthingHttpClient

func (c *Controller) NewSyncthingHttpClient(reqTimeoutSecond int) *req.SyncthingHttpClient

func (*Controller) PatchDevModeManifest

func (c *Controller) PatchDevModeManifest(ctx context.Context, ops *model.DevStartOptions) error

func (*Controller) PortForward

func (c *Controller) PortForward(podName string, localPort, remotePort int, role string) error

PortForward Role: If set to "SYNC", means it is a pf used for syncthing

func (*Controller) PortForwardAfterDevStart

func (c *Controller) PortForwardAfterDevStart(podName, containerName string) error

func (*Controller) ReloadConfig

func (c *Controller) ReloadConfig() profile.ServiceConfigV2

func (*Controller) ReplaceDuplicateModeImage

func (c *Controller) ReplaceDuplicateModeImage(ctx context.Context, ops *model.DevStartOptions) error

ReplaceDuplicateModeImage Create a duplicate deployment instead of replacing image

func (*Controller) ReplaceImage

func (c *Controller) ReplaceImage(ctx context.Context, ops *model.DevStartOptions) error

func (*Controller) RollBack

func (c *Controller) RollBack(reset bool) error

func (*Controller) RollbackFromAnnotation

func (c *Controller) RollbackFromAnnotation(reset bool) error

func (*Controller) SetPortForwardedStatus

func (c *Controller) SetPortForwardedStatus(is bool) error

func (*Controller) SetSyncingStatus

func (c *Controller) SetSyncingStatus(is bool) error

func (*Controller) SetSyncthingPort

func (c *Controller) SetSyncthingPort(remotePort, remoteGUIPort, localPort, localGUIPort int) error

func (*Controller) StopAllPortForward

func (c *Controller) StopAllPortForward() error

func (*Controller) StopFileSyncOnly

func (c *Controller) StopFileSyncOnly() error

func (*Controller) StopPortForwardByPort

func (c *Controller) StopPortForwardByPort(port string) error

StopPortForwardByPort port format 8080:80

func (*Controller) StopSyncAndPortForwardProcess

func (c *Controller) StopSyncAndPortForwardProcess(cleanRemoteSecret bool) error

func (*Controller) UpdateConfig

func (c *Controller) UpdateConfig(config profile.ServiceConfigV2) error

func (*Controller) UpdatePortForwardStatus

func (c *Controller) UpdatePortForwardStatus(localPort int, remotePort int, portStatus string, reason string) error

func (*Controller) UpdateSvcProfile

func (c *Controller) UpdateSvcProfile(modify func(*profile.SvcProfileV2) error) error

type DefaultController

type DefaultController struct {
	*Controller
}

func (*DefaultController) ReplaceImage

func (j *DefaultController) ReplaceImage(ctx context.Context, ops *model.DevStartOptions) error

func (*DefaultController) RollBack

func (j *DefaultController) RollBack(reset bool) error

type DuplicateRawPodController

type DuplicateRawPodController struct {
	*Controller
}

func (*DuplicateRawPodController) ReplaceImage

func (*DuplicateRawPodController) RollBack

func (r *DuplicateRawPodController) RollBack(reset bool) error

type RawPodController

type RawPodController struct {
	*Controller
}

RawPodController represents a pod not managed by any controller

func (*RawPodController) ReplaceImage

func (r *RawPodController) ReplaceImage(ctx context.Context, ops *model.DevStartOptions) error

func (*RawPodController) RollBack

func (r *RawPodController) RollBack(reset bool) error

Jump to

Keyboard shortcuts

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