Metadata-Version: 2.1
Name: deployhub
Version: 9.3.119
Summary: UNKNOWN
Home-page: https://ortelius.io
Author: Steve Taylor
Author-email: steve@deployhub.com
License: GNU AFFERO GENERAL PUBLIC LICENSE
Project-URL: Project Repo, https://github.com/ortelius/compupdate
Project-URL: Issues, https://github.com/ortelius/ortelius/issues
Project-URL: CLI Documentation, https://github.com/ortelius/compupdate/blob/main/doc/dh.md
Project-URL: Python API Documentation, https://github.com/ortelius/compupdate/blob/main/doc/deployhub.md
Platform: UNKNOWN
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: click
Requires-Dist: qtoml
Requires-Dist: PyYAML
Requires-Dist: requests
Requires-Dist: configobj
Requires-Dist: flatten-dict

<a name="dh"></a>
# dh

DeployHub's CLI using the dhapi module.

**Arguments**:


  ACTION - one of the following

- `deploy` - deploy the application to the evironment
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --appname
    > --appversion (optional)
    > --deployenv

- `approve` - approve the application version
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --appname
    > --appversion (optional)

- `move` - move the application version using the supplied task
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --appname
    > --appversion (optional)
    > --from_domain
    > --task

- `updatecomp` - create/replace the component version for the application verion
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --compname
    > --compvariant (optional)
    > --compversion (optional)
    > --autocompinc (optional)
    > --appname (optional)
    > --appversion (optional)
    > --autoappinc (optional)
    > --compattr

  - Predefined Key/Values:
    * BuildId - Identifier for the CI job
    * BuildNumber - Build number for the CI job
    * BuildUrl - url for the CI job
    * Chart - Helm Chart for the component
    * ChartNamespace - Name space for the component to be deployed to
    * ChartRepo - Helm Chart Repo Name
    * ChartRepoUrl - Helm Chart Repo Url
    * ChartVersion - Helm Chart version
    * CustomAction - Custom Action to assign to the Component
    * DockerBuildDate - Timestamp when the image was created
    * DockerRepo - Registry which the image was pushed to
    * DockerSha - Digest for the image
    * DockerTag - Tag for the image
    * GitBranch - Git branch in the git repo
    * GitCommit - Git commit that triggered the CI job
    * GitRepo - Git repo that triggered the CI job
    * GitTag - Git tag in the git repo
    * GitUrl - Full url to the git repo
    * operator - Operator name
    * Readme - Readme location in the Git Repo
    * ServiceOwner - Owner of the Service
    * ServiceOwnerEmail - Email for the Owner of the Service
    * ServiceOwnerPhone - Phone number for the Owner of the Service

- `assign` - assigns a component version to an application verion
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --compname
    > --compvariant (optional)
    > --compversion (optional)
    > --appname
    > --appversion (optional)

- `kv` - assigns the key/values pairs to the component verion
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --compname
    > --compvariant (optional)
    > --compversion (optional)
    > --kvconfig

- `envscript` - creates a bash file from the component toml file
  - Usage:
    > --envvars
    > --envvars_sh

- `export` - exports a domain including all objects to stdout
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --from_dom

- `import` - imports the export file into the new domain
  - Usage:
    > --dhurl
    > --dhuser
    > --dhpass
    > --from_dom
    > --to_dom

  Parameter Descriptions:
  - `--dhurl` - DeployHub Url
  - `--dhuser` - DeployHub User
  - `--dhpass` - DeployHub Password
  - `--appname` - Application Name
  - `--appversion` - Application Version
  - `--appautoinc` - Application Auto Increment Version
  - `--deployenv` - Deployment Environment
  - `--compname` - Component Name
  - `--compvariant` - Component Variant
  - `--compversion` - Component Version
  - `--compautoinc` - Component Auto Increment Version
  - `--kvconfig` - Directory containing the json and properties file
  - `--crdatasource` - Change Request Data Source for the Component
  - `--changerequest` - Change Request for Component, use multiple time for each Change Request Id
  - `--deploydata` - The json file that contains the application, environment and log details
  - `--from_domain` - Move from domain
  - `--task` - Task to use for move
  - `--envvars` - Env Variables TOML file
  - `--envvars_sh` - Env Variables Output sh file
  - `--docker` - docker Kind of the component item
  - `--file` - file Kind of the component item
  - `--compattr` - Component Attributes, use multiple time for each attr
  - `--envs` - Environments to Associate App to, use multiple time for each env
  - `--importfile` - File to Import
  - `--fromdom` - From Domain
  - `--todom` - To Domain
  - `--msname` - New microservice being added to the cluster
  - `--msbranch` - New microservice branch being added to the cluster


  Example Jenkinsfile Snippet:

  stage ('Build') {
  /*********************************/
  /*   Update for your component   */
  /*********************************/
  def DHUrl="https://console.deployhub.com"
  def DHUsername="stella99"
  def DHPassword="XXXXXX"

  def AppName="GLOBAL.Santa Fe Software.Online Store Company.Candy Store"
  def AppVersion="v1.0.0"

  def CompName="GLOBAL.Santa Fe Software.Online Store Company.Store Services.Email Service.emailservice"
  def CompVersion="1.2.0"

  def CustomAction="GLOBAL.HelmChart"

  def HelmChart="chart/emailservice"
  def HelmChartVersion="1.0"
  def HelmNamespace=""
  def HelmRepo=""
  def HelmRepoUrl=""

  def ImageRegistry="quay.io/hipsterstore/emailservice"
  def ImageTag="latest"

  def ServiceOwner="Abraham Ortelius"
  def ServiceOwnerEmail="request-info@ortelius.io"
  def ServiceOwnerPhone="505-559-4455"

  /*********************************/
  /*        Derived Values         */
  /*********************************/
  def GitBranch=eval2var('git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3').trim()
  def GitUrl=eval2var('git config --get remote.origin.url').trim()       // remote url
  def GitRepo=eval2var('git config --local remote.origin.url | sed "s/[:\\/]/\\n/g" | tail -2 | tr "\\n" "/" | sed "s/\\.git\\///"').trim()
  def GitCommit=eval2var('git log -1 --oneline | cut -f1 -d" "').trim()  // get latest commit on the branch
  def BuildDate=eval2var('date').trim()
  def BuildId="${env.BUILD_NUMBER}"
  def BuildUrl="${env.BUILD_URL}"
  def CompVariant="${GitBranch}"
  def CompVersionCommit="v${CompVersion}.${env.BUILD_NUMBER}-g${GitCommit}"
  def CompReadme=eval2var('ls README* 1>/dev/null 2> /dev/null && echo https://github.com/' + GitRepo + '`readme` || echo ""').trim()

  /*********************************/
  /* Override Default Tag Name     */
  /*********************************/
  ImageTag="${GitBranch}-v${CompVersion}.${env.BUILD_NUMBER}-g${GitCommit}"

  /*********************************/
  /* Run Docker Build and Push     */
  /*********************************/
  sh (returnStdout: true, script: "docker build -f Dockerfile --tag ${ImageRegistry}:${ImageTag} . 2>&1")
  sh (returnStdout: true, script: "docker push ${ImageRegistry}:${ImageTag} 2>&1")

  /********************************************/
  /* Derive Disgest (must be done after push) */
  /********************************************/
  def ImageDigest=eval2var("docker inspect --format='{{index .RepoDigests 0}}' ${ImageRegistry}:${ImageTag} | tr -d '\\n'").tokenize(':')[1]

  /*********************************************************************/
  /* Create component version and new application version in DeployHub */
  /*********************************************************************/
  sh "/usr/local/bin/dh updatecomp --dhurl '${DHUrl}' --dhuser '${DHUsername}' --dhpass '${DHPassword}' --appname '${AppName}' --appversion '${AppVersion}' --appautoinc 'Y' --compname '${CompName}' --compvariant '${CompVariant}' --compversion '${CompVersionCommit}' --compattr 'GitCommit:${GitCommit}'    > --compattr 'GitUrl:${GitUrl}' --compattr 'GitRepo:${GitRepo}' --compattr 'GitBranch:${GitBranch}' --compattr 'BuildId:${BuildId}' --compattr 'BuildUrl:${BuildUrl}' --compattr 'Chart:${HelmChart}' --compattr 'ChartVersion:${HelmChartVersion}' --compattr 'ChartNamespace:${HelmNamespace}' --compattr 'ChartRepo:${HelmRepo}' --compattr 'ChartRepoUrl:${HelmRepoUrl}' --compattr 'DockerBuildDate:${BuildDate}' --compattr 'DockerSha:${ImageDigest}' --compattr 'DockerRepo:${ImageRegistry}' --compattr 'DockerTag:${ImageTag}' --compattr 'CustomAction:${CustomAction}' --compattr 'ServiceOwner:${ServiceOwner}' --compattr 'ServiceOwnerEmail:${ServiceOwnerEmail}' --compattr 'ServiceOwnerPhone:${ServiceOwnerPhone}' --compattr 'Readme:${CompReadme}'"
  }
  }

  // Function to disable shell echo and grab output from command
  def eval2var(script) {
  return sh(returnStdout: true, script: '#!/bin/sh -e\n' + script);
  }



