Skip to content

Commit

Permalink
Update generated example library content (#104)
Browse files Browse the repository at this point in the history
Co-authored-by: TobiasBabin <[email protected]>
  • Loading branch information
HumanitecBot and TobiasBabin authored Nov 7, 2024
1 parent 3591e84 commit 1cdab17
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions resource-definitions/template-driver/endpoint/endpoint-def.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
resource "humanitec_resource_definition" "endpoint-example-endpoint" {
driver_type = "humanitec/template"
id = "endpoint-example-endpoint"
name = "endpoint-example-endpoint"
type = "endpoint"
driver_inputs = {
values_string = jsonencode({
"host" = "example.com"
"port" = 8080
"templates" = {
"init" = <<END_OF_TEXT
{{- $username := .driver.secrets.username | default "" }}
{{- $password := .driver.secrets.password | default "" }}
username: {{ $username | toRawJson }}
password: {{ $password | toRawJson }}
userinfo: {{ if $username }}
{{- $username }}:
{{- end }}
{{- $password }}
hostport: {{ .driver.values.host }}
{{- if .driver.values.port -}}
:{{ .driver.values.port }}
{{- end }}
END_OF_TEXT
"outputs" = <<END_OF_TEXT
scheme: {{ .driver.values.scheme | default "http" }}
host: {{ .driver.values.host }}
port: {{ .driver.values.port }}
path: {{ .driver.values.path | default "" | toRawJson }}
query: {{ .driver.values.query | default "" | toRawJson }}
fragment: {{ .driver.values.fragment | default "" | toRawJson }}
END_OF_TEXT
"secrets" = <<END_OF_TEXT
username: {{ .init.username | toRawJson }}
password: {{ .init.password | toRawJson }}
url: {{ .outputs.values | merge (dict "userinfo" (.init.userinfo | default "") "host" .init.hostport) | urlJoin | toRawJson }}
END_OF_TEXT
}
})
}
}

0 comments on commit 1cdab17

Please sign in to comment.