Documentation ¶
Index ¶
- Constants
- Variables
- func AbstractServiceValidation(dir string) error
- func AddConfiguredUserInputs(configVars map[string]interface{}, envvars map[string]string) error
- func AddDefaultUserInputs(uis []exchange.UserInput, envmap map[string]string)
- func CommonExecutionSetup(homeDirectory string, userInputFile string, projectType string, cmd string) (string, *register.InputFile, *container.ContainerWorker)
- func CommonProjectValidation(dir string, userInputFile string, projectType string, cmd string, ...)
- func CreateDependencyGitIgnoreFile(directory string) error
- func CreateDockerFiles(directory string) error
- func CreateFile(directory string, fileName string, obj interface{}) error
- func CreateFileWithConent(directory string, filename string, content string, ...) error
- func CreateHorizonGitIgnoreFile(directory string) error
- func CreateHznEnvFile(directory string, org string, specRef string, version string, ...) error
- func CreateMakeFile(directory string, hznenv_dir string) error
- func CreatePatternDefinition(directory string) error
- func CreatePatternDefinitionAllArches(directory string) error
- func CreateServiceDefinition(directory string, specRef string, imageInfo map[string]string, noImageGen bool, ...) error
- func CreateServiceFile(directory string) error
- func CreateServiceImageFiles(directory string, hznenv_dir string) error
- func CreateServicePolicy(directory string) error
- func CreateSourceCodeManagementFiles(directory string) error
- func CreateUserInputs(directory string, specRef string) error
- func CreateWorkingDir(dir string) error
- func DependenciesExists(directory string, okToCreate bool) (bool, error)
- func DependencyFetch(homeDirectory string, project string, specRef string, url string, org string, ...)
- func DependencyList(homeDirectory string)
- func DependencyRemove(homeDirectory string, specRef string, url string, version string, arch string, ...)
- func FileExists(directory string, fileName string) (bool, error)
- func FileNotExist(dir string, cmd string, fileName string, check func(string) (bool, error))
- func FileValidation(configFiles []string, configType string, projectType string, cmd string) []string
- func GetAbstractDefinition(directory string) (cliexchange.AbstractServiceFile, error)
- func GetDependencyFiles(directory string, fileSuffix string) ([]os.FileInfo, error)
- func GetDevWorkingDirectory() string
- func GetFile(directory string, fileName string, obj interface{}) error
- func GetImageInfoFromImageList(images []string, version string, noImageGen bool) (map[string]string, string, error)
- func GetNodeId() string
- func GetPatternDefinition(directory string, name string) (*cliexchange.PatternFile, error)
- func GetServiceDefinition(directory string, name string) (*cliexchange.ServiceFile, error)
- func GetServiceDependencies(directory string, deps []exchange.ServiceDependency) ([]*cliexchange.ServiceFile, error)
- func GetServicePolicy(directory string, name string) (*cliexchange.ServicePolicyFile, error)
- func GetServiceSpecFromImage(image string) (string, string, error)
- func GetUserInputs(homeDirectory string, userInputFile string) (*register.InputFile, string, error)
- func GetUserInputsVariableConfiguration(homeDirectory string, userInputFile string) ([]register.MicroWork, error)
- func GetWorkingDir(dashD string, verifyExists bool) (string, error)
- func GlobalSetAsAttributes(global []register.GlobalSet) ([]persistence.Attribute, error)
- func IsServiceProject(directory string) bool
- func PatternDefinitionAllArchesExists(directory string) (bool, error)
- func PatternDefinitionExists(directory string) (bool, error)
- func ProcessStartDependencies(dir string, deps []*cliexchange.ServiceFile, globals []register.GlobalSet, ...) (map[string]docker.ContainerNetwork, error)
- func ProcessStopDependencies(dir string, deps []*cliexchange.ServiceFile, cw *container.ContainerWorker) error
- func RefreshServiceDependencies(homeDirectory string, newDepDef cliexchange.AbstractServiceFile) error
- func RemoveConfiguredVariables(homeDirectory string, theDep cliexchange.AbstractServiceFile) error
- func RemoveServiceDependency(homeDirectory string, theDepDef cliexchange.AbstractServiceFile) error
- func ServiceDefinitionExists(directory string) (bool, error)
- func ServiceNew(homeDirectory string, org string, specRef string, version string, ...)
- func ServicePolicyExists(directory string) (bool, error)
- func ServiceStartTest(homeDirectory string, userInputFile string, configFiles []string, ...)
- func ServiceStopTest(homeDirectory string)
- func ServiceValidate(homeDirectory string, userInputFile string, configFiles []string, ...) []string
- func SetUserInputsVariableConfiguration(homeDirectory string, sDef cliexchange.AbstractServiceFile, ...) error
- func StartContainers(deployment *containermessage.DeploymentDescription, specRef string, ...) (map[string]docker.ContainerNetwork, error)
- func StopService(dc *cliexchange.DeploymentConfig, cw *container.ContainerWorker) error
- func UpdateDependencyFile(homeDirectory string, sDef cliexchange.AbstractServiceFile) error
- func UpdateDependentDependencies(homeDirectory string, depProject string) error
- func UpdateServiceDefandUserInputFile(homeDirectory string, sDef cliexchange.AbstractServiceFile, ...) error
- func UpdateVariableConfiguration(homeDirectory string, sDef cliexchange.AbstractServiceFile, ...) (*register.InputFile, error)
- func UserInputExists(directory string) (bool, error)
- func ValidateDependencies(directory string, userInputs *register.InputFile, userInputsFilePath string, ...) error
- func ValidateService(directory string, fInfo os.FileInfo, userInputs *register.InputFile, ...) error
- func ValidateServiceDefinition(directory string, fileName string) error
- func ValidateUserInput(i *register.InputFile, directory string, originalUserInputFilePath string, ...) error
- func VerifyEnvironment(homeDirectory string, mustExist bool, needExchange bool, userCreds string) (string, error)
- type ServiceDependency
- type ServiceSpec
Constants ¶
const DEFAULT_BASE_OS_VALUE = "alpine:latest"
const DEFAULT_DEPENDENCY_DIR = "dependencies"
const DEFAULT_DEVTOOL_HZN_FSS_WORKING_DIR = "/tmp/hzndev/"
const DEFAULT_GLOBALSET_TYPE = ""
const DEFAULT_PROP_VALUE = "value1"
const DEFAULT_SDEF_SPECIFIC_VERSION = "specific_version_number"
const DEFAULT_SDEF_URL = ""
const DEFAULT_WORKING_DIR = "horizon"
const DEFUALT_PROP_NAME = "prop1"
const DEPENDENCY_COMMAND = "dependency"
const DEPENDENCY_FETCH_COMMAND = "fetch"
const DEPENDENCY_GITIGNORE_FILE = "dependencies/.gitignore"
const DEPENDENCY_GITIGNORE_FILE_CONTENT = `*.service.definition.json
`
const DEPENDENCY_LIST_COMMAND = "list"
const DEPENDENCY_REMOVE_COMMAND = "remove"
const DEVTOOL_HZN_DEVICE_ID = "HZN_DEVICE_ID"
const DEVTOOL_HZN_EXCHANGE_URL = "HZN_EXCHANGE_URL"
const DEVTOOL_HZN_FSS_CSS_PORT = "HZN_DEV_FSS_CSS_PORT"
const DEVTOOL_HZN_FSS_IMAGE_TAG = "HZN_DEV_FSS_IMAGE_TAG"
const DEVTOOL_HZN_FSS_WORKING_DIR = "HZN_DEV_FSS_WORKING_DIR"
const DEVTOOL_HZN_ORG = "HZN_ORG_ID"
Constants that hold the name of env vars used with the context of the hzn dev commands.
const DEVTOOL_HZN_PATTERN = "HZN_PATTERN"
const DEVTOOL_HZN_USER = "HZN_EXCHANGE_USER_AUTH"
const DOCKER_FILE = "Dockerfile"
const DOCKER_FILE_CONTENT = `FROM BASE_OS
COPY *.sh /
WORKDIR /
CMD /service.sh`
const HORIZON_GITIGNORE_FILE = ".gitignore"
const HORIZON_GITIGNORE_FILE_CONTENT = `/.hzn.json.tmp.mk
`
const HZNENV_FILE = "hzn.json"
const MAKE_FILE = "Makefile"
const MAKE_FILE_CONTENT = `` /* 1021-byte string literal not displayed */
const PATTERN_DEFINITION_ALL_ARCHES_FILE = "pattern-all-arches.json"
const PATTERN_DEFINITION_FILE = "pattern.json"
const SERVICE_COMMAND = "service"
These constants define the hzn dev subcommands supported by this module.
const SERVICE_CREATION_COMMAND = "new"
const SERVICE_DEFINITION_FILE = "service.definition.json"
const SERVICE_FILE = "service.sh"
const SERVICE_FILE_CONTENT = `` /* 132-byte string literal not displayed */
const SERVICE_NEW_DEFAULT_VERSION = "0.0.1"
const SERVICE_POLICY_FILE = "service.policy.json"
const SERVICE_START_COMMAND = "start"
const SERVICE_STOP_COMMAND = "stop"
const SERVICE_VERIFY_COMMAND = "verify"
const USERINPUT_FILE = "userinput.json"
Variables ¶
var BASE_OS_VALUE = map[string]string{"amd64": "alpine:latest", "arm": "arm32v6/alpine:latest", "arm64": "arm64v8/alpine:latest"}
Functions ¶
func AddConfiguredUserInputs ¶
Convert user input variables and values (for a service) to environment variables and add them to an env var map.
func AddDefaultUserInputs ¶
Convert default user inputs to environment variables in a map. The input map is modified by this function. If a variable is already in the input map, it is not modified.
func CommonExecutionSetup ¶
func CommonExecutionSetup(homeDirectory string, userInputFile string, projectType string, cmd string) (string, *register.InputFile, *container.ContainerWorker)
This function is used to setup context to execute a service container.
func CommonProjectValidation ¶
func CommonProjectValidation(dir string, userInputFile string, projectType string, cmd string, userCreds string, autoAddDep bool)
autoAddDep -- if true, the dependent services will be automatically added if they can be found from the exchange
func CreateDockerFiles ¶
This function creates 3 Dockerfiles, for amd64, arm and arm64.
func CreateFile ¶
This function takes one of the project json objects and writes it to a file in the project.
func CreateFileWithConent ¶
func CreateFileWithConent(directory string, filename string, content string, substitutes map[string]string, perm_exec bool) error
check the file existance, substitute the variables and save the file
func CreateHznEnvFile ¶
func CreateHznEnvFile(directory string, org string, specRef string, version string, image_base string) error
It creates a hzn.json file that contains the enviromental variables needed for this project.
func CreateMakeFile ¶
func CreatePatternDefinition ¶
It creates a pattern definition config object and writes it to the project in the file system.
func CreatePatternDefinitionAllArches ¶
It creates a pattern definition config object for all architectures and writes it to the project in the file system.
func CreateServiceDefinition ¶
func CreateServiceDefinition(directory string, specRef string, imageInfo map[string]string, noImageGen bool, deploymentType string) error
Sort of like a constructor, it creates a service definition config object and writes it to the project in the file system.
func CreateServiceFile ¶
func CreateServiceImageFiles ¶
It creates a sample Dockerfile for the service container image in the file system. For now we only handle the first image.
func CreateServicePolicy ¶
Sort of like a constructor, it creates a service policy object and writes it to the project in the file system.
func CreateSourceCodeManagementFiles ¶
It creates gitignore files
func CreateUserInputs ¶
Sort of like a constructor, it creates a user input config object and writes it to the project in the file system.
func CreateWorkingDir ¶
Create the working directory if needed.
func DependenciesExists ¶
Check for the existence of the dependency directory in the project.
func DependencyFetch ¶
func DependencyFetch(homeDirectory string, project string, specRef string, url string, org string, version string, arch string, userCreds string, userInputFile string)
This is the entry point for the hzn dev dependency fetch command.
func DependencyList ¶
func DependencyList(homeDirectory string)
This is the entry point for the hzn dev dependency list command.
func DependencyRemove ¶
func DependencyRemove(homeDirectory string, specRef string, url string, version string, arch string, org string)
This is the entry point for the hzn dev dependency remove command.
func FileExists ¶
Check for file existence and return any errors.
func FileNotExist ¶
Check for a file's existence or error out of the command. This is just a way to consolidate the error handling because we have several files that we're dealing with.
func FileValidation ¶
func FileValidation(configFiles []string, configType string, projectType string, cmd string) []string
Validate that the input list of files actually exist.
func GetAbstractDefinition ¶
func GetAbstractDefinition(directory string) (cliexchange.AbstractServiceFile, error)
Sort of like a constructor, it creates an in memory object except that it is created from a service definition config file in the current project. This function assumes the caller has determined the exact location of the file. This function also assumes that the project pointed to by the directory parameter is assumed to contain the kind of definition the caller expects.
func GetDependencyFiles ¶
Returns an os.FileInfo object for each dependency file. This function assumes the caller has determined the exact location of the files.
func GetDevWorkingDirectory ¶
func GetDevWorkingDirectory() string
func GetFile ¶
This function demarshals the file bytes into the input obj structure. The contents of what obj points to will be modified by this function.
func GetImageInfoFromImageList ¶
func GetImageInfoFromImageList(images []string, version string, noImageGen bool) (map[string]string, string, error)
This function extracts the image names from the image list and returns a map of name~image pairs. If the image does not have version tag specified, this function will add $SERVICE_VERSION as the tag so that it's easy for the user to update the version later. And it will append_$ARCH to the image name so distiguash images from different arch.
func GetPatternDefinition ¶
func GetPatternDefinition(directory string, name string) (*cliexchange.PatternFile, error)
Sort of like a constructor, it creates an in memory object except that it is created from the patern definition config file in the current project. This function assumes the caller has determined the exact location of the file.
func GetServiceDefinition ¶
func GetServiceDefinition(directory string, name string) (*cliexchange.ServiceFile, error)
Sort of like a constructor, it creates an in memory object except that it is created from the service definition config file in the current project. This function assumes the caller has determined the exact location of the file.
func GetServiceDependencies ¶
func GetServiceDependencies(directory string, deps []exchange.ServiceDependency) ([]*cliexchange.ServiceFile, error)
func GetServicePolicy ¶
func GetServicePolicy(directory string, name string) (*cliexchange.ServicePolicyFile, error)
Sort of like a constructor, it creates an in memory object from the service policy file. This function assumes the caller has determined the exact location of the file.
func GetServiceSpecFromImage ¶
It is used by "hzn dev service new" when the specRef is an empty string. This function generates a service specRef and version from the image name provided by the user.
func GetUserInputs ¶
Sort of like a constructor, it creates an in memory object except that it is created from the user input config file in the current project. This function assumes the caller has determined the exact location of the file.
func GetUserInputsVariableConfiguration ¶
func GetUserInputsVariableConfiguration(homeDirectory string, userInputFile string) ([]register.MicroWork, error)
Given a userinput file, extract the configured variables based on the type of project.
func GetWorkingDir ¶
The current working directory could be specified via input (as an absolute or relative path) or it could be defaulted if there is no input. If it must exist but does not, return an error.
func GlobalSetAsAttributes ¶
func GlobalSetAsAttributes(global []register.GlobalSet) ([]persistence.Attribute, error)
Convert each attribute in the global set of attributes to a persistent attribute. This enables us to reuse the validation logic and to reuse the logic that converts persistent attributes to environment variables.
func IsServiceProject ¶
Indicates whether or not the given project is a service project.
func PatternDefinitionAllArchesExists ¶
Check for the existence of the pattern definition all in one config file in the project.
func PatternDefinitionExists ¶
Check for the existence of the pattern definition config file in the project.
func ProcessStartDependencies ¶
func ProcessStartDependencies(dir string, deps []*cliexchange.ServiceFile, globals []register.GlobalSet, configUserInputs []register.MicroWork, cw *container.ContainerWorker) (map[string]docker.ContainerNetwork, error)
func ProcessStopDependencies ¶
func ProcessStopDependencies(dir string, deps []*cliexchange.ServiceFile, cw *container.ContainerWorker) error
func RefreshServiceDependencies ¶
func RefreshServiceDependencies(homeDirectory string, newDepDef cliexchange.AbstractServiceFile) error
Refresh the RequiredServices dependencies in the definition. This is called when new dependencies are added or removed.
func RemoveConfiguredVariables ¶
func RemoveConfiguredVariables(homeDirectory string, theDep cliexchange.AbstractServiceFile) error
Remove configured variables from the userinputs file
func RemoveServiceDependency ¶
func RemoveServiceDependency(homeDirectory string, theDepDef cliexchange.AbstractServiceFile) error
func ServiceDefinitionExists ¶
Check for the existence of the service definition config file in the project.
func ServiceNew ¶
func ServiceNew(homeDirectory string, org string, specRef string, version string, images []string, noImageGen bool, dconfig string, noPattern bool, noPolicy bool)
Create skeletal horizon metadata files to establish a new service project.
func ServicePolicyExists ¶
Check for the existence of the service policy file in the project.
func ServiceStartTest ¶
func ServiceStopTest ¶
func ServiceStopTest(homeDirectory string)
Services are stopped in the reverse order they were started, parents first and then leaf nodes last in order to minimize the possibility of a parent throwing an error during execution because a leaf node is gone.
func ServiceValidate ¶
func SetUserInputsVariableConfiguration ¶
func SetUserInputsVariableConfiguration(homeDirectory string, sDef cliexchange.AbstractServiceFile, configuredVars []register.MicroWork) error
func StartContainers ¶
func StartContainers(deployment *containermessage.DeploymentDescription, specRef string, version string, globals []register.GlobalSet, defUserInputs []exchange.UserInput, configUserInputs []register.MicroWork, org string, dc *cliexchange.DeploymentConfig, cw *container.ContainerWorker, msNetworks map[string]docker.ContainerNetwork, service bool, agreementBased bool, id string) (map[string]docker.ContainerNetwork, error)
func StopService ¶
func StopService(dc *cliexchange.DeploymentConfig, cw *container.ContainerWorker) error
func UpdateDependencyFile ¶
func UpdateDependencyFile(homeDirectory string, sDef cliexchange.AbstractServiceFile) error
func UpdateDependentDependencies ¶
Copy the dependency files out, validate them and write them back.
func UpdateServiceDefandUserInputFile ¶
func UpdateServiceDefandUserInputFile(homeDirectory string, sDef cliexchange.AbstractServiceFile, skipServcieDef bool) error
update the service definition file and userinput file with this dependent service
func UpdateVariableConfiguration ¶
func UpdateVariableConfiguration(homeDirectory string, sDef cliexchange.AbstractServiceFile, configuredVars []register.MicroWork) (*register.InputFile, error)
Given a userinput file, a dependency definition and a set of configured user input variables, copy the configured variables into the userinput file.
func UserInputExists ¶
Check for the existence of the user input config file in the project.
func ValidateDependencies ¶
func ValidateDependencies(directory string, userInputs *register.InputFile, userInputsFilePath string, projectType string, userCreds string, autoAddDep bool) error
Validate that the dependencies are complete and coherent with the rest of the definitions in the project. Any errors will be returned to the caller.
func ValidateService ¶
func ValidateServiceDefinition ¶
Validate that the service definition file is complete and coherent with the rest of the definitions in the project. If the file is not valid the reason will be returned in the error.
func ValidateUserInput ¶
func ValidateUserInput(i *register.InputFile, directory string, originalUserInputFilePath string, projectType string) error
Validate that the userinputs file is complete and coherent with the rest of the definitions in the project. If the file is not valid the reason will be returned in the error.
Types ¶
type ServiceDependency ¶
type ServiceDependency struct { Service ServiceSpec TopSvcRefs []*ServiceSpec // the top services that eventually reference this service FileInfo os.FileInfo }
func NewServiceDependency ¶
func NewServiceDependency(service *ServiceSpec, topService *ServiceSpec, fileInfo os.FileInfo) *ServiceDependency
func (*ServiceDependency) AddTopRef ¶
func (sd *ServiceDependency) AddTopRef(topService *ServiceSpec)
Add a top service reference to this dependency
func (ServiceDependency) String ¶
func (sd ServiceDependency) String() string
type ServiceSpec ¶
func NewServiceSpec ¶
func NewServiceSpec(specref, org, version, arch string) *ServiceSpec
func (ServiceSpec) Matches ¶
func (sp ServiceSpec) Matches(sp2 ServiceSpec) bool
func (ServiceSpec) String ¶
func (sp ServiceSpec) String() string