cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Asset Bundles : how to conditionally set content of a template file

GeKo
New Contributor III

Hello,

since Asset Bundles is based on GO templating mechanism, I am wondering how it is possible to use IF-ELSE construct within a template file, to define which file content will be set in the generated file ( I want to have that in my custom template).

Example: I am providing a boolean variable "topic_sourcing" to the bundle init command. The following template file shall be set, depending on that variable:

 

---
version: "1.0"
{{- if .topic_sourcing }}
status: enabled
topics:
  - name: "my-name"
    table_name: "my-tablename"
{{- else }}
status: disabled   
{{- end }}

 

But after the bundle init command, it looks like there is no templating mechanism applied on the file, means the created file contains exactly the text shown above.

How can I populate a file content based on a variable during bundle init ??

1 ACCEPTED SOLUTION

Accepted Solutions

GeKo
New Contributor III

Never mind....I figured out the solution 😄

I just have to prefix my template file with ".tmpl", then it gets rendered correctly

View solution in original post

1 REPLY 1

GeKo
New Contributor III

Never mind....I figured out the solution 😄

I just have to prefix my template file with ".tmpl", then it gets rendered correctly

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group