Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ require (
github.com/docker/docker v20.10.9+incompatible
github.com/docker/go-connections v0.4.0
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
github.com/fatih/camelcase v1.0.0
github.com/fatih/color v1.12.0
github.com/fatih/structs v1.1.0
github.com/gitchander/permutation v0.0.0-20210302120832-6ab79d7de174
github.com/gitchander/permutation v0.0.0-20210517125447-a5d73722e1b1
github.com/go-logr/logr v0.4.0
github.com/go-logr/zapr v0.4.0
github.com/google/uuid v1.1.2
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ github.com/evanphx/json-patch/v5 v5.5.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2Vvl
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM=
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4=
github.com/fasthttp/websocket v1.4.2/go.mod h1:smsv/h4PBEBaU0XDTY5UwJTpZv69fQ0FfcLJr21mA6Y=
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
Expand Down Expand Up @@ -512,8 +513,8 @@ github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebK
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
github.com/gitchander/permutation v0.0.0-20210302120832-6ab79d7de174 h1:jDzjvDor5f0IMUz63ghkFrki7erEOJ4GqU9IUUA+tDg=
github.com/gitchander/permutation v0.0.0-20210302120832-6ab79d7de174/go.mod h1:HMJdsfdGgnh5ncvocKE6H8ATmoIQDmBFAgjY+6u/dm0=
github.com/gitchander/permutation v0.0.0-20210517125447-a5d73722e1b1 h1:FUKJibWQu771xr/AwLn2/PbVp9AsgqfkObByTf8kJnI=
github.com/gitchander/permutation v0.0.0-20210517125447-a5d73722e1b1/go.mod h1:HMJdsfdGgnh5ncvocKE6H8ATmoIQDmBFAgjY+6u/dm0=
github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
Expand Down
6 changes: 6 additions & 0 deletions internal/cli/alpha/manifestgen/manifestgen_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Package manifestgen_test is based on golden file pattern.
// If the `-test.update-golden` flag is set then the actual content is written
// to the golden file.
//
// To update golden files, run:
// go test ./internal/cli/alpha/manifestgen/... -test.update-golden
package manifestgen_test

import (
Expand Down
7 changes: 6 additions & 1 deletion internal/cli/alpha/manifestgen/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"strings"

"github.com/alecthomas/jsonschema"
"github.com/fatih/camelcase"
"github.com/hashicorp/terraform-config-inspect/tfconfig"
"github.com/iancoleman/orderedmap"
"github.com/iancoleman/strcase"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -138,10 +140,13 @@ func getTerraformInputTypeJSONSchema(variables map[string]*tfconfig.Variable) ([
}

for _, value := range variables {
title := strcase.ToCamel(value.Name) // from snake to camel
title = strings.Join(camelcase.Split(title), " ") // separate with spaces
propSchema := &jsonschema.Type{
Title: value.Name,
Title: title,
Type: getTypeFromTerraformType(value.Type),
Description: value.Description,
Default: value.Default,
}
schema.Properties.Set(value.Name, propSchema)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ spec:
"properties": {
"count": {
"type": "number",
"title": "count",
"description": "Number of instances"
"title": "Count",
"description": "Number of instances",
"default": 3
},
"name": {
"type": "string",
"title": "name",
"description": "Name of environment"
"title": "Name",
"description": "Name of environment",
"default": "test"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ spec:
"properties": {
"count": {
"type": "number",
"title": "count",
"description": "Number of instances"
"title": "Count",
"description": "Number of instances",
"default": 3
},
"name": {
"type": "string",
"title": "name",
"description": "Name of environment"
"title": "Name",
"description": "Name of environment",
"default": "test"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ spec:
"properties": {
"count": {
"type": "number",
"title": "count",
"description": "Number of instances"
"title": "Count",
"description": "Number of instances",
"default": 3
},
"name": {
"type": "string",
"title": "name",
"description": "Name of environment"
"title": "Name",
"description": "Name of environment",
"default": "test"
}
}
}