Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dots are not allowed in Terraform names #101

Merged
merged 1 commit into from
May 3, 2022

Conversation

sbellone
Copy link
Contributor

@sbellone sbellone commented Apr 29, 2022

Hi, thanks for this very useful tool!
Today I've tried to convert Google's Custom Metrics Adapter and I got invalid names in the final result.
Indeed, dots are not valid in resource names and their yaml file contains metadata names such as v1beta1.custom.metrics.k8s.io.

Before:

resource "kubernetes_api_service" "v_1_beta_1_.custom.metrics.k_8_s.io" {
  metadata {
    name = "v1beta1.custom.metrics.k8s.io"
  }

After:

resource "kubernetes_api_service" "v_1_beta_1__custom_metrics_k_8_s_io" {
  metadata {
    name = "v1beta1.custom.metrics.k8s.io"
  }

@sbellone
Copy link
Contributor Author

sbellone commented Apr 29, 2022

Unrelated but I'm using the occasion to ask:
When looking at the tests, it seems that the toSingular parameter doesn't seem to work:

{
	"labels",
	args{
		"labels",
		true,
		"",
	},
	"labels",
},

Did I miss something?

@sl1pm4t
Copy link
Owner

sl1pm4t commented May 3, 2022

Thanks @sbellone.
As for toSingular - there are a few exceptions setup to prevent it from singularizing certain words to match the TF Kubernetes provider schema.
See - https://github.com/sl1pm4t/k2tf/blob/master/pkg/tfkschema/name_mapper.go#L20

@sl1pm4t sl1pm4t merged commit e1de284 into sl1pm4t:master May 3, 2022
@sl1pm4t sl1pm4t mentioned this pull request May 3, 2022
@sbellone
Copy link
Contributor Author

sbellone commented May 3, 2022

Oh I see, I had missed that, thanks 👍

@sbellone sbellone deleted the fix/normalize-terraform-name branch May 3, 2022 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants