PreviewHQ
  • Introduction
  • Basics
    • What is Continuous Product Review?
    • What is a Preview Environment?
    • Use Cases
      • Product and Stakeholder Review
      • QA Environments
      • Automated End-to-End Testing
      • Sales Demo Environments
      • Support Training
  • Getting Started
    • Installation
    • Add Configuration
    • Add a Cluster
    • Create a Deployment
      • with a Pull Request
      • with the Dashboard
      • with the CLI
      • with the API
  • Technical Stuff
    • Defining Deployments
      • Helm Charts
      • Kubernetes Manifests
      • [UNRELEASED] Terraform
    • Configuration File
      • Branches
      • Services
      • Chart Repositories
      • Chart Values
      • Docker Registries
      • Images
      • Webhooks
    • Template Strings
    • Using Seed Data
      • Using Shared Data Sources
    • Access Control
      • Preview Application Access
      • Preview Environment Access
    • Using Third-Party Integrations
    • Debugging
    • Current Limitations
  • Sample Applications
    • Emojivoto
    • Guestbook - Helm
    • Guestbook - Manifests
  • misc
    • FAQ
    • Changelog
    • Telemetry Data
    • Links
      • Homepace
      • Dashboard
Powered by GitBook
On this page

Was this helpful?

  1. Technical Stuff

Template Strings

Template Strings are strings which are dynamically replaced by Preview during a deploy, allowing you to inject environment-specific values into your deployment.

Preview supports the use of Template Strings in both for all chart values and Kubernetes manifest files under the ./preview directory.

For example, it is recommended to use the PREVIEWHQ_HOSTNAME as part of your application's Ingress specification:

# .preview/chart-values/
ingress:
  enabled: true
  annotations:
    kubernetes.io/tls-acme: "true"
  path: /
  hosts:
    - host: ${PREVIEWHQ_HOSTNAME}
      paths:
        - /
  tls:
   - secretName: tls-secret
     hosts:
       - ${PREVIEWHQ_CLUSTER_HOSTNAME}
       - ${PREVIEWHQ_HOSTNAME}

There are 2 sets of Template Strings which can be utilized: one static set across all builds, and one set that is dynamically build based on image builds.

Static Template Strings

Template String

Description

Example

PREVIEWHQ_HOSTNAME

The hostname of the deployment, which will point to the root

my-pr-branch.nrmitchi.envs.dev

PREVIEWHQ_CLUSTER_HOSTNAME

The hostname of the cluster which the deployment is deployed on

nrmitchi.envs.dev

PREVIEWHQ_NAMESPACE

The namespace which the deployment is deployed in to

my-pr-branch

PREVIEWHQ_REVISION

The git hash being deployed

PREVIEWHQ_IMAGE_REPOSITORY

The URL of the Preview-provided Docker image repository that

Dynamic Template Strings

For each addition image specified in the images block of the configuration, Preview injects a PREVIEWHQ_CUSTOM_IMAGE_TAG_{} string, which is the Docker tag which was used for that custom build within the Docker image registry.

For example, if images is as follows:

images:
  - name: frontend
    dockerfile: ./src/react/Dockerfile
    context: ./src/react
  - name: backend
    dockerfile: ./src/flask/Dockerfile
    context: ./src/flask

The the following additional Templates Strings are available:

  • PREVIEWHQ_CUSTOM_IMAGE_TAG_FRONTEND

  • PREVIEWHQ_CUSTOM_IMAGE_TAG_BACKEND

PreviousWebhooksNextUsing Seed Data

Last updated 4 years ago

Was this helpful?