Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertConfigFileV1ToV2(srcFile string, destFile string) error
- func LoadSvcCfgFromStrIfValid(config string, svcName string, svcType base.SvcType) (*profile.NocalHostAppConfigV2, *profile.ServiceConfigV2, error)
- func RenderConfig(renderItem envsubst.RenderItem) (*profile.NocalHostAppConfigV2, error)
- func RenderConfigForSvc(renderItem envsubst.RenderItem) ([]*profile.ServiceConfigV2, error)
- func StandardNocalhostMetas(releaseName, releaseNamespace string) *clientgoutils.ApplyFlags
- type Application
- func BuildApplication(name string, flags *app_flags.InstallFlags, kubeconfig string, ...) (*Application, error)
- func NewApplication(name string, ns string, kubeconfig string, initClient bool) (*Application, error)
- func NewApplicationM(name string, ns string, kubeconfig string, meta *appmeta.ApplicationMeta, ...) (*Application, error)
- func (a *Application) CleanUpTmpResources() error
- func (a *Application) CleanupResources() error
- func (a *Application) Controller(name string, svcType base.SvcType) (*controller.Controller, error)
- func (a *Application) Exec(pod v1.Pod, container string, commands []string) error
- func (a *Application) GetAllPVCs() ([]v1.PersistentVolumeClaim, error)
- func (a *Application) GetAppMeta() *appmeta.ApplicationMeta
- func (a *Application) GetApplicationConfigV2() *profile.ApplicationConfig
- func (a *Application) GetClient() *clientgoutils.ClientGoUtils
- func (a *Application) GetConfigFile() (string, error)
- func (a *Application) GetConfigMap(resourceName string) (*v1.ConfigMap, error)
- func (a *Application) GetConfigPath() string
- func (a *Application) GetConfigV2Path() string
- func (a *Application) GetDependencies() []*SvcDependency
- func (a *Application) GetDescription() *profile.AppProfileV2
- func (a *Application) GetHomeDir() string
- func (a *Application) GetInstallEnvForDep() *InstallEnvForDep
- func (a *Application) GetObjectMeta(resourceName, resourceType string) (*MetaWrapper, error)
- func (a *Application) GetProfile() (*profile.AppProfileV2, error)
- func (a *Application) GetResourceDir(tmpDir string) []string
- func (a *Application) GetSvcProfile(svcName string, svcType base.SvcType) (*profile.SvcProfileV2, error)
- func (a *Application) GetType() appmeta.AppType
- func (a *Application) HasBeenGenerateSecret() bool
- func (a *Application) InitAndCheckIfSvcExist(svcName string, svcType string) (*controller.Controller, error)
- func (a *Application) InitService(svcName string, svcType string) (*controller.Controller, error)
- func (a *Application) Install(flags *HelmFlags) (err error)
- func (a *Application) InstallDepConfigMap(appMeta *appmeta.ApplicationMeta) error
- func (a *Application) InstallKustomize(doApply bool) error
- func (a *Application) InstallManifest(doApply bool) error
- func (a *Application) IsAnyServiceInDevMode() bool
- func (a *Application) IsHelm() bool
- func (a *Application) IsKustomize() bool
- func (a *Application) IsManifest() bool
- func (a *Application) MarkAsGenerated()
- func (a *Application) PortForward(pod string, localPort, remotePort int, readyChan, stopChan chan struct{}, ...) error
- func (a *Application) PortForwardFollow(podName string, localPort int, remotePort int, okChan chan struct{}) error
- func (a *Application) PostInstallHook() error
- func (a *Application) PostUpgradeHook() error
- func (a *Application) PreInstallHook() error
- func (a *Application) PreUpgradeHook() error
- func (a *Application) PrepareForPostDeleteHook() error
- func (a *Application) PrepareForPreDeleteHook() error
- func (a *Application) PrepareForUpgrade(flags *flag.InstallFlags) error
- func (a *Application) ReloadCfg(reloadFromMeta, silence bool) errordeprecated
- func (a *Application) ReloadSvcCfg(svcName string, svcType base.SvcType, reloadFromMeta, silence bool) error
- func (a *Application) SaveAppProfileV2(config *profile.ApplicationConfig) error
- func (a *Application) Uninstall(force bool) error
- func (a *Application) UpdateProfile(modify func(*profile.AppProfileV2) error) error
- func (a *Application) Upgrade(installFlags *flag.InstallFlags) error
- type ContainerEnvForDep
- type FileSyncOptions
- type HelmFlags
- type InstallEnvForDep
- type MetaWrapper
- type PortForwardEndOptions
- type PortForwardOptions
- type RepoDto
- type ServiceEnvForDep
- type SvcDependency
- type SyncStatusDirOptions
- type SyncStatusOptions
Constants ¶
const ( DefaultSecretGenSign = "secreted" DefaultApplicationConfigPath = ".config.yaml" DefaultApplicationConfigV2Path = ".config_v2.yaml" DefaultGitNocalhostDir = ".nocalhost" // DefaultApplicationConfigDirName DefaultConfigNameInGitNocalhostDir = "config.yaml" DefaultNewFilePermission = 0700 DefaultConfigFilePermission = 0644 DefaultClientGoTimeOut = time.Minute * 5 // nhctl init // TODO when release DefaultInitHelmGitRepo = "https://github.com/nocalhost/nocalhost.git" DefaultInitHelmCODINGGitRepo = "https://e.coding.net/nocalhost/nocalhost/nocalhost.git" DefaultInitHelmType = "helmGit" DefaultInitWatchDeployment = "nocalhost-api" DefaultInitWatchWebDeployment = "nocalhost-web" DefaultInitNocalhostService = "nocalhost-web" DefaultInitInstallApplicationName = "nocalhost" DefaultInitUserEmail = "foo@nocalhost.dev" DefaultInitMiniKubePortForwardPort = 31219 DefaultInitPassword = "123456" DefaultInitAdminUserName = "admin@admin.com" DefaultInitAdminPassWord = "123456" DefaultInitName = "Nocalhost" DefaultInitWaitNameSpace = "nocalhost-reserved" DefaultInitCreateNameSpaceLabels = "nocalhost-init" DefaultInitWaitDeployment = "nocalhost-dep" // TODO when release DefaultInitHelmResourcePath = "deployments/chart" DefaultInitPortForwardTimeOut = time.Minute * 1 DefaultInitApplicationGithub = "{\"source\":\"git\",\"install_type\":\"rawManifest\"," + "\"resource_dir\":[\"manifest/templates\"],\"application_name\":\"bookinfo\"," + "\"application_url\":\"https://github.com/nocalhost/bookinfo.git\"}" DefaultInitApplicationHelm = "{\"source\":\"git\",\"install_type\":\"helm_chart\"," + "\"application_url\":\"git@github.com:nocalhost/bookinfo.git\"," + "\"application_config_path\":\"config.helm.yaml\",\"application_name\":" + "\"bookinfo-helm\",\"resource_dir\":[]}" DefaultInitApplicationKustomize = "{\"source\":\"git\",\"install_type\":\"kustomize\"," + "\"application_name\":\"bookinfo-kustomize\",\"application_url\":" + "\"git@github.com:nocalhost/bookinfo.git\",\"application_config_path\"" + ":\"config.kustomize.yaml\",\"resource_dir\":[]}" DefaultInitApplicationCODING = "{\"source\":\"git\",\"install_type\":" + "\"rawManifest\",\"resource_dir\":[\"manifest/templates\"],\"application_name\"" + ":\"bookinfo\",\"application_url\":" + "\"https://e.coding.net/nocalhost/nocalhost/bookinfo.git\"}" DefaultInitApplicationBookinfoTracing = "{\"source\":\"git\",\"install_type\":\"rawManifest\"," + "\"resource_dir\":[\"manifest/templates\"],\"application_name\":\"bookinfo-tracing\"," + "\"application_url\":\"https://github.com/nocalhost/bookinfo-tracing.git\"}" // Init Component Version Control, HEAD means build from tag DefaultNocalhostMainBranch = "HEAD" DefaultNocalhostDepDockerRegistry = "nocalhost-docker.pkg.coding.net/nocalhost/public/nocalhost-dep" DefaultDevContainerShell = "(zsh || bash || sh)" DependenceConfigMapPrefix = "nocalhost-depends-do-not-overwrite" // Port-forward PortForwardManual = "manual" PortForwardDevPorts = "devPorts" )
Variables ¶
var ( // do not change this error message ErrNotFound = errors.New("Application not found") ErrInstalling = errors.New("Application is installing") )
Functions ¶
func ConvertConfigFileV1ToV2 ¶
func LoadSvcCfgFromStrIfValid ¶
func LoadSvcCfgFromStrIfValid(config string, svcName string, svcType base.SvcType) ( *profile.NocalHostAppConfigV2, *profile.ServiceConfigV2, error)
LoadSvcCfgFromStrIfValid CAUTION: appCfg may nil!
func RenderConfig ¶
func RenderConfig(renderItem envsubst.RenderItem) (*profile.NocalHostAppConfigV2, error)
V2
func RenderConfigForSvc ¶
func RenderConfigForSvc(renderItem envsubst.RenderItem) ([]*profile.ServiceConfigV2, error)
func StandardNocalhostMetas ¶
func StandardNocalhostMetas(releaseName, releaseNamespace string) *clientgoutils.ApplyFlags
Types ¶
type Application ¶
type Application struct { Name string NameSpace string KubeConfig string AppType string Identifier string // may be nil, only for install or upgrade // dir use to load the user's resource ResourceTmpDir string // contains filtered or unexported fields }
func BuildApplication ¶
func BuildApplication(name string, flags *app_flags.InstallFlags, kubeconfig string, namespace string) ( *Application, error, )
BuildApplication When a application is installed, something representing the application will build, including:
- An directory (NhctlAppDir) under $NhctlHomeDir/ns/$NameSpace will be created and initiated
- An config will be created and upload to the secret in the k8s cluster, it may come from an config file under .nocalhost in your git repository or an outer config file in your local file system
- An leveldb will be created under $NhctlAppDir, it will record the status of this application
build a new application
func NewApplication ¶
func NewApplication(name string, ns string, kubeconfig string, initClient bool) (*Application, error)
NewApplication When new a application, kubeconfig is required to get meta in k8s cluster KubeConfig can be acquired from profile in leveldb
func NewApplicationM ¶
func NewApplicationM(name string, ns string, kubeconfig string, meta *appmeta.ApplicationMeta, initClient bool) (*Application, error)
func (*Application) CleanUpTmpResources ¶
func (a *Application) CleanUpTmpResources() error
func (*Application) CleanupResources ¶
func (a *Application) CleanupResources() error
func (*Application) Controller ¶
func (a *Application) Controller(name string, svcType base.SvcType) (*controller.Controller, error)
func (*Application) GetAllPVCs ¶
func (a *Application) GetAllPVCs() ([]v1.PersistentVolumeClaim, error)
Get all PersistVolumeClaims created by this application
func (*Application) GetAppMeta ¶
func (a *Application) GetAppMeta() *appmeta.ApplicationMeta
func (*Application) GetApplicationConfigV2 ¶
func (a *Application) GetApplicationConfigV2() *profile.ApplicationConfig
func (*Application) GetClient ¶
func (a *Application) GetClient() *clientgoutils.ClientGoUtils
func (*Application) GetConfigFile ¶
func (a *Application) GetConfigFile() (string, error)
func (*Application) GetConfigMap ¶
func (a *Application) GetConfigMap(resourceName string) (*v1.ConfigMap, error)
func (*Application) GetConfigPath ¶
func (a *Application) GetConfigPath() string
This path is independent from getConfigPathInGitResourcesDir()
func (*Application) GetDependencies ¶
func (a *Application) GetDependencies() []*SvcDependency
func (*Application) GetDescription ¶
func (a *Application) GetDescription() *profile.AppProfileV2
func (*Application) GetHomeDir ¶
func (a *Application) GetHomeDir() string
func (*Application) GetInstallEnvForDep ¶
func (a *Application) GetInstallEnvForDep() *InstallEnvForDep
func (*Application) GetObjectMeta ¶
func (a *Application) GetObjectMeta(resourceName, resourceType string) (*MetaWrapper, error)
func (*Application) GetProfile ¶
func (a *Application) GetProfile() (*profile.AppProfileV2, error)
func (*Application) GetResourceDir ¶
func (a *Application) GetResourceDir(tmpDir string) []string
Get local path of resource dirs If resource path undefined, use git url
func (*Application) GetSvcProfile ¶
func (a *Application) GetSvcProfile(svcName string, svcType base.SvcType) (*profile.SvcProfileV2, error)
func (*Application) GetType ¶
func (a *Application) GetType() appmeta.AppType
func (*Application) HasBeenGenerateSecret ¶
func (a *Application) HasBeenGenerateSecret() bool
func (*Application) InitAndCheckIfSvcExist ¶
func (a *Application) InitAndCheckIfSvcExist(svcName string, svcType string) (*controller.Controller, error)
func (*Application) InitService ¶
func (a *Application) InitService(svcName string, svcType string) (*controller.Controller, error)
func (*Application) Install ¶
func (a *Application) Install(flags *HelmFlags) (err error)
Install different type of Application: Helm, Manifest, Kustomize
func (*Application) InstallDepConfigMap ¶
func (a *Application) InstallDepConfigMap(appMeta *appmeta.ApplicationMeta) error
func (*Application) InstallKustomize ¶
func (a *Application) InstallKustomize(doApply bool) error
Install different type of Application: Kustomize
func (*Application) InstallManifest ¶
func (a *Application) InstallManifest(doApply bool) error
Install different type of Application: Manifest
func (*Application) IsAnyServiceInDevMode ¶
func (a *Application) IsAnyServiceInDevMode() bool
func (*Application) IsHelm ¶
func (a *Application) IsHelm() bool
func (*Application) IsKustomize ¶
func (a *Application) IsKustomize() bool
func (*Application) IsManifest ¶
func (a *Application) IsManifest() bool
func (*Application) MarkAsGenerated ¶
func (a *Application) MarkAsGenerated()
func (*Application) PortForward ¶
func (a *Application) PortForward(pod string, localPort, remotePort int, readyChan, stopChan chan struct{}, g genericclioptions.IOStreams) error
func (*Application) PortForwardFollow ¶
func (a *Application) PortForwardFollow(podName string, localPort int, remotePort int, okChan chan struct{}) error
func (*Application) PostInstallHook ¶
func (a *Application) PostInstallHook() error
func (*Application) PostUpgradeHook ¶
func (a *Application) PostUpgradeHook() error
func (*Application) PreInstallHook ¶
func (a *Application) PreInstallHook() error
func (*Application) PreUpgradeHook ¶
func (a *Application) PreUpgradeHook() error
func (*Application) PrepareForPostDeleteHook ¶
func (a *Application) PrepareForPostDeleteHook() error
func (*Application) PrepareForPreDeleteHook ¶
func (a *Application) PrepareForPreDeleteHook() error
func (*Application) PrepareForUpgrade ¶
func (a *Application) PrepareForUpgrade(flags *flag.InstallFlags) error
func (*Application) ReloadCfg
deprecated
func (a *Application) ReloadCfg(reloadFromMeta, silence bool) error
Deprecated: this method is no need any more, because config is always load from secrets now
func (*Application) ReloadSvcCfg ¶
func (a *Application) ReloadSvcCfg(svcName string, svcType base.SvcType, reloadFromMeta, silence bool) error
ReloadSvcCfg try load config from cm first then load from local under associateDir/.nocalhost/config.yaml at last load config from local profile
func (*Application) SaveAppProfileV2 ¶
func (a *Application) SaveAppProfileV2(config *profile.ApplicationConfig) error
func (*Application) Uninstall ¶
func (a *Application) Uninstall(force bool) error
func (*Application) UpdateProfile ¶
func (a *Application) UpdateProfile(modify func(*profile.AppProfileV2) error) error
func (*Application) Upgrade ¶
func (a *Application) Upgrade(installFlags *flag.InstallFlags) error
type ContainerEnvForDep ¶
type FileSyncOptions ¶
type InstallEnvForDep ¶
type InstallEnvForDep struct { Global []*profile.Env `json:"global" yaml:"global"` Service []*ServiceEnvForDep `json:"service" yaml:"service"` }
Used by dep
type MetaWrapper ¶
type MetaWrapper struct {
metav1.ObjectMeta `json:"metadata,omitempty"`
}
type PortForwardEndOptions ¶
type PortForwardEndOptions struct {
Port string // 8080:8080
}
type PortForwardOptions ¶
type PortForwardOptions struct { Pid int `json:"pid" yaml:"pid"` DevPort []string // 8080:8080 or :8080 means random localPort PodName string // directly port-forward pod //ServiceType string // service type such deployment Way string // port-forward way, value is manual or devPorts RunAsDaemon bool Forward bool Follow bool // will stock until send ctrl+c or occurs error }
type ServiceEnvForDep ¶
type ServiceEnvForDep struct { Name string `json:"name" yaml:"name"` Type string `json:"type" yaml:"type"` Container []*ContainerEnvForDep `json:"container" yaml:"container"` }