Build Configuration

go-msx Build uses YAML build configuration files to define the build to be executed. A build configuration describes the build metadata for one of:

  • Microservice
  • Command Line tool
  • Service Pack
  • Library

A build configuration file can include these artifacts:

  • Binary artifacts
  • Assemblies (tarballs)
  • Resources
  • Runtime Configuration Files
  • Docker Images

Configuration Sources

Like all go-msx applications, go-msx-build can retrieve configuration from a variety of sources:

  • Environment
  • Command-Line Options
  • Build Configuration Files
  • Application Configuration Files
  • Defaults

To specify the primary build configuration file, pass the --config option to build:

go run cmd/build/build.go --config cmd/build/build.yml

This will normally be handled by the Makefile.

Configuration passed in by either Environment Variables or Command-Line Options will override values also specified in Files or Defaults.

Environment Variables

Some settings are intended to be injected from environment variables. These include:

  • docker.username (DOCKER_USERNAME)
  • docker.password (DOCKER_PASSWORD)
  • artifactory.username (ARTIFACTORY_USERNAME)
  • artifactory.password (ARTIFACTORY_PASSWORD)
  • build.number (BUILD_NUMBER)
  • manifest.folder (MANIFEST_FOLDER)
  • jenkins.username (JENKINS_USERNAME)
  • jenkins.password (JENKINS_PASSWORD)
  • github.token (GITHUB_TOKEN)

It is considered unsafe or inflexible to store them directly in the configuration file. The default generated Jenkinsfile will automatically inject these environment variables as required by the relevant steps.

Application Configuration

Some settings below are intended to be read from the application configuration files.
These include:

  • info.app.* - bootstrap.yml
  • server.* - bootstrap.yml

To ensure these are being read from the correct source, ensure the executable.config-files list contains the base application configuration files (eg bootstrap.yml).

Example:

executable:
  configFiles:
    - bootstrap.yml

Configuration Sections

executable

The executable configuration specifies the entrypoint and primary configuration file(s) of this build.

KeyDefaultRequiredDescription
executable.cmdappOptionalThe cmd sub-folder containing the application main module.
executable.config-files-RequiredA list of configuration files within the main module to include in the build.

Example:

executable:
  configFiles:
    - bootstrap.yml
    - dnaservice.production.yml

msx

The msx configuration specifies details of the MSX release to interface with.

KeyDefaultRequiredDescription
msx.release-RequiredThe MSX release of this microservice (output).
msx.deployment-group-RequiredThe deployment group of the build.
msx.platform.parent-artifacts-RequiredMaven artifact roots to scan for default properties.
msx.platform.version-RequiredThe platform version to use for locating maven artifacts. Accepts EDGE and STABLE builds.
msx.platform.include-groups-RequiredMaven artifact groupIds to include in artifact scanning.
msx.platform.swagger-artifactcom.cisco.nfv:nfv-swaggerOptionalMSX artifact groupId and artifactId for nfv-swagger.
msx.platform.swagger-webjarorg.webjars:swagger-ui:3.23.11OptionalMaven artifact triple for swagger web jar.

Example:

msx:
  release: 3.10.0
  deploymentGroup: dna
  platform:
    parentArtifacts:
      - com.cisco.vms:vms-service-starter
      - com.cisco.vms:vms-service-starter-core
      - com.cisco.vms:vms-service-starter-kafka
      - com.cisco.nfv:nfv-integration-consul-leader
    version: 3.10.0-EDGE
    includeGroups: "com.cisco.**"

docker

The docker configuration controls interactions with the docker daemon, global repository, images, and Dockerfile scripts.

KeyDefaultRequiredDescription
docker.dockerfiledocker/DockerfileOptionalThe Dockerfile used for this build.
docker.baseimagemsx-base-buster:3.9.0-70OptionalThe base image within the repository.
docker.repositorydockerhub.cisco.com/vms-platform-dev-dockerOptionalThe repository source and destination.
docker.username-OptionalUser name to authenticate to repository.
docker.password-OptionalPassword to authenticate to repository.
docker.buildkit-Optionaltrue to use docker buildkit when building the docker image.
docker.base.dynamic.enabledtrueOptionaltrue to use manifests to dynamically locate the base docker image.
docker.base.dynamic.streamEI-StableOptionalManifest stream to search within for manifests
docker.base.dynamic.version${msx.release}OptionalMSX release to search within for manifests
docker.base.dynamic.manifestmsxbase-bullseye-manifestOptionalMSX manifest to search within for builds
docker.base.dynamic.imagemsx-base-imageOptionalManifest key identifying the image to use

Example:

docker:
    dockerfile: build/package/Dockerfile

kubernetes

The kubernetes configuration provides defaults for generating kubernetes manifests.

KeyDefaultRequiredDescription
kubernetes.groupplatformmsOptionalThe kubernetes group used for pods in production.

manifest

The manifest configuration specifies how to build and publish installer manifests.

KeyDefaultRequiredDescription
manifest.folderBuild-StableOptionalThe maven output folder to publish the manifest to.

resources

The resources section identifies the files to be included as part of the docker image.

Each entry has the following properties:

KeyDefaultRequiredDescription
resources.includes-OptionalList of globs of files to include. Processed first.
resources.excludes-OptionalList of globs of files to exclude. Processed second.

Example:

resources:
  includes:
    - "/internal/migrate/**/*.sql"
    - "/internal/populate/**/*"
  excludes:
    - "/internal/populate/**/*.go"

assemblies

The assemblies configuration specifies .tar file generation. The .tar files will be included in generated manifests and published (unless disabled).

KeyDefaultRequiredDescription
assemblies.rootplatform-commonOptionalThe folder from which assemblies are created by default. All sub-folders with a 'templates' folder or 'manifest.json' are included.
assemblies.custom-OptionalList of custom assemblies to include. See below

Example:

assemblies:
  root: platform-common

assemblies.custom

The assemblies.custom setting contains a list of custom assemblies to generate. These will be uploaded to artifactory and recorded as binaries in the manifest, unless disabled with artifactory.assemblies.

Each entry in this list has the following properties:

KeyDefaultRequiredDescription
path-RequiredThe root path of the assembly files.
path-prefix-OptionalA folder inside the assembly to prefix the files during the build.
manifest-prefix-RequiredThe prefix of the file name in the manifest.
manifest-key-RequiredThe location of the entry in the JSON manifest.
includes/**/*OptionalGlob of files to include. Processed first.
excludes-OptionalGlob of files to exclude. Processed second.

Example:

To create an assembly file called "skyfallui-files-${release}-${build}.tar":

assemblies:
  custom:
    - path: ui/build
      pathPrefix: services
      manifestPrefix: skyfallui-files
      manifestKey: ${msx.deploymentGroup}-ui
  • Each file from the ui/build subtree will be prefixed with the services folder in the output tar. e.g. 'ui/build/dna/index.js' will be relocated to services/dna/index.js.
  • The assembly will be added to the generated artifact manifests at e.g. dna-ui.

artifactory

The artifactory configuration specifies artifactory connectivity, folders, binaries, and images.

KeyDefaultRequiredDescription
artifactory.assembliestrueOptionalInclude assemblies in publishing and manifests
artifactory.installerdeployments/kubernetesOptionalThe folder in which installer binaries can be found. eg pod, rc, meta templates.
artifactory.repositoryhttps://.../vms-3.0-binariesOptionalThe base url for storing published artifacts
artifactory.installer-folderbinaries/vms-3.0-binariesOptionalThe folder prefix of binaries to record in the manifest
artifactory.username-OptionalThe user name with which to authenticate to Artifactory.
artifactory.password-OptionalThe password with which to authenticate to Artifactory.
artifactory.custom-OptionalList of custom binaries to include. See below
artifactory.images-OptionalList of docker images to include.

Example:

artifactory:
  installer: deployments/production
  images:
    - nacservice

artifactory.custom

The artifactory.custom setting contains a list of custom binaries to include. These will be uploaded to artifactory and recorded in the manifest.

Each entry in this list has the following properties:

KeyRequiredDescription
pathRequiredThe source path of the file to include.
output-nameRequiredThe destination name of the file.
manifest-prefixRequiredThe prefix of the file name in the manifest.
manifest-keyRequiredThe location of the entry in the JSON manifest.

Example:

artifactory:
  custom:
    - path: deploymentvariables/nac_deployment_variables.yml
      outputName: nac_deployment_variables.yml
      manifestPrefix: deployment-variables
      manifestKey: deployment_variables
    - path: deploymentvariables/nac_variables.yml
      outputName: nac_variables.yml
      manifestPrefix: variables
      manifestKey: variables    

generate

The generate configuration specifies paths to be generated by the generate target. Mostly these will refer to folders on which to run go generate to produce mocks.
Specialized generators such as openapi are described in following sections.

NOTE: Embedding using vfs has been deprecated in favor of go:embed which executes during the go build process.

KeyDefaultRequiredDescription
generate[*].path-RequiredFolder to generate outputs
generate[*].commandgo generateOptionalCommand to execute

generate[*].openapi

The openapi generator can be used to auto-generate OpenApi clients from contract specifications.

KeyDefaultRequiredDescription
generate[*].openapi.spec-RequiredConsumer contract location
generate[*].openapi.config-RequiredOpenApi client generator config file

go

The go configuration specifies environment variables and options to be passed to Go tools during the build.

KeyDescription
go.env.all.*Environment variables for all platforms
go.env.linux.*Environment variables for linux platform
go.env.darwin.*Environment variables for darwin (MacOS) platform
go.vet.options[*]List of command line options to pass to go vet

build

The build configuration specifies information about the build used to generate buildinfo.yml.

KeyDefaultRequiredDescription
build.numberSNAPSHOTRequiredThe build number of this build.
build.groupcom.cisco.msxOptionalThe build group.

info.app

The info.app configuration specifies details about the application used across all parts of the build.

KeyDefaultRequiredDescription
info.app.name-RequiredThe name of the application being built.
info.app.attributes.display-name-RequiredThe display name of the application being built.

Example:

info.app:
    name: dnaservice
    attributes:
      displayName: DNA Microservice

server

The server configuration specifies details about the web server used across all parts of the build.

KeyDefaultRequiredDescription
server.port-RequiredThe web server port of the application being built.

Example:

server:
    port: 9393

jenkins

The jenkins configuration specifies details about the Jenkins CI server used by the project.

KeyDefaultRequiredDescription
jenkins.job-OptionalThe simplified job path to the Jenkins Job on the server.
jenkins.serverhttps://jenkins.infra.ciscomsx.comOptionalThe base url of the Jenkins CI server.
jenkins.username-OptionalUser name to authenticate to Jenkins.
jenkins.password-OptionalAPI Token to authenticate to Jenkins. Can be created on the User Configure page in Jenkins UI.

Example:

jenkins.job: eng-sp-umbrella/builds/umbrellaservice

github

The github configuration specifies details about the GitHub Source Control server used by the project.

KeyDefaultRequiredDescription
github.repository'${spring.application.name}'OptionalThe name of the repository on the server.
github.organization'NFV-BU'OptionalThe owner of the repository on the server.
github.serverhttps://cto-github.cisco.comOptionalThe base url of the GitHub server.
github.token-OptionalAPI Token to authenticate to GitHub. Can be created on the User Settings > Developer Settings > Personal Access Tokens page in the GitHub UI.
github.hook.push${jenkins.server}/github-webhook/OptionalGithub Push Webhook to configure on the repository.
github.hook.pull-request${jenkins.server}/ghprbhook/OptionalGithub PR Webhook to configure on the repository.
github.teams.jenkinsJenkins-generic-usersOptionalGitHub CI Team to assign write access to the repository.
github.teams.eng-OptionalGitHub Engineering Team to assign write access to the repository.

Example:

github.organization: xiaoydu

aws

The aws configuration specifies credentials and target details for AWS.

KeyDefaultRequiredDescription
aws.access-key-id${aws.access.key.id}OptionalAccess Key Id to authenticate to AWS.
aws.secret-access-key${aws.secret.access.key}OptionalSecret Access Key to authenticate to AWS.

These values default to the standard environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) so no extra configuration should be required if using them.

deploy

The deploy configuration specifies the target for package deployment.

KeyDefaultRequiredDescription
deploy.host-RequiredSSH config host name to target for deployment. Must point to an installer container.

openapi

The openapi configuration specifies producer and consumer contract locations (local and upstream), along with schema resolution aliases.

KeyDefaultRequiredDescription
openapi.specapi/openapi.yamlOptionalThe project-root relative location of the producer contract specification.
openapi.contracts[*].consumer-RequiredLocal copy of the consumer contract for client generation.
openapi.contracts[*].producer-RequiredUpstream copy of the producer contract for client generation.
openapi.alias[*].from-RequiredCanonical schema url to be loaded from an alternative source
openapi.alias[*].to-RequiredAlternative source location for schema

Example:

# Contract Management
openapi:
  # Local (producer) API contract
  spec: api/openapi.yaml

  # Remote (consumer) API contract pairs
  contracts:
    - consumer: internal/stream/.openapi/manage-service-8.yaml
      producer: https://cto-github.cisco.com/raw/NFV-BU/msx-platform-specs/develop/manage-service-8.yaml

  # Alternative sources for well-known schema
  alias:
    - from: https://api.swaggerhub.com/domains/Cisco-Systems46/msx-common-domain/8
      to: https://cto-github.cisco.com/raw/NFV-BU/msx-platform-specs/sdk1.0.10/common-domain-8.yaml