Skip to content

Commit

Permalink
Merge pull request sl1pm4t#69 from sl1pm4t/issue-50
Browse files Browse the repository at this point in the history
Convert colons to underscores
  • Loading branch information
sl1pm4t authored Jul 30, 2020
2 parents 04277d7 + 13765f4 commit 7e02b5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/tfkschema/name_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package tfkschema

import (
"fmt"
"github.com/sl1pm4t/k2tf/pkg/k8sutils"
"os"
"reflect"
"strings"

"github.com/sl1pm4t/k2tf/pkg/k8sutils"

"github.com/jinzhu/inflection"
"k8s.io/apimachinery/pkg/runtime"

Expand Down Expand Up @@ -96,6 +97,9 @@ func NormalizeTerraformName(s string, toSingular bool, path string) string {
}
s = strcase.ToSnake(s)

// colons are not allowed by Terraform
s = strings.ReplaceAll(s, ":", "_")

return s
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/tfkschema/name_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ func Test_NormalizeTerraformName(t *testing.T) {
},
"capabilities",
},
{
"metallb-system:speaker",
args{
"metallb-system:speaker",
true,
"",
},
"metallb_system_speaker",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 7e02b5c

Please sign in to comment.