Closed dkulchinsky closed 5 months ago
@dkulchinsky does it changes something ? what is the go type for protocol
?
Ok, i think this is where terraform really is a pain. Basically there's no way to know if a specific value was provided in the config or not.
IIRC that's why i created the nullable
helper. Can you try with:
generate(kops.GossipConfigSecondary{},
nullable("Protocol"),
),
generate(kops.DNSControllerGossipConfigSecondary{},
nullable("Protocol"),
),
IIRC that's why i created the
nullable
helper. Can you try with:generate(kops.GossipConfigSecondary{}, nullable("Protocol"), ), generate(kops.DNSControllerGossipConfigSecondary{}, nullable("Protocol"), ),
ohh!! that looks promising ๐๐ผ
I'll give it a go ๐ค๐ผ
@eddycharly so I'm testing this out with the change in #70
now the produced kops config is:
dnsControllerGossipConfig:
listen: 0.0.0.0:3993
protocol: memberlist
secondary:
protocol: "false"
seed: 127.0.0.1:4000
gossipConfig:
listen: 0.0.0.0:4000
protocol: memberlist
secondary:
protocol: "false"
so it renders as protocol: "false"
instead of protocol: ""
๐
The terraform code I used:
gossip_config {
protocol = "memberlist"
listen = "0.0.0.0:4000"
secondary {
protocol {
value = false
}
}
}
dns_controller_gossip_config {
protocol = "memberlist"
listen = "0.0.0.0:3993"
seed = "127.0.0.1:4000"
secondary {
protocol {
value = false
}
}
}
@dkulchinsky does it changes something ? what is the go type for
protocol
?
it's a string
@dkulchinsky nope, it's a string pointer ;-)
The tf config should be something like this:
gossip_config {
protocol = "memberlist"
listen = "0.0.0.0:4000"
secondary {
protocol {
value = ""
}
}
}
nullable
you can now do: gossip_config {
protocol = "memberlist"
listen = "0.0.0.0:4000"
secondary {
protocol {
value = ""
}
}
}
Should produce:
gossipConfig:
listen: 0.0.0.0:4000
protocol: memberlist
secondary:
protocol: ""
gossip_config {
protocol = "memberlist"
listen = "0.0.0.0:4000"
secondary {}
}
Should produce:
gossipConfig:
listen: 0.0.0.0:4000
protocol: memberlist
secondary: {}
That is, we can differentiate a value that is not set at all from a default value (which is not possible natively in a plugin).
@eddycharly thank you! this makes total sense!
and of course, it's a string pointer ๐คฆ๐ผโโ๏ธ
will report back once I had a chance to test it out as suggested.
@eddycharly thanks again for your help! can confirm with value = ""
the correct kops config is now produced!
gossip_config {
protocol = "memberlist"
listen = "0.0.0.0:4000"
secondary {
protocol {
value = ""
}
}
}
dns_controller_gossip_config {
protocol = "memberlist"
listen = "0.0.0.0:3993"
seed = "127.0.0.1:4000"
secondary {
protocol {
value = ""
}
}
}
produces:
dnsControllerGossipConfig:
listen: 0.0.0.0:3993
protocol: memberlist
secondary:
protocol: ""
seed: 127.0.0.1:4000
gossipConfig:
listen: 0.0.0.0:4000
protocol: memberlist
secondary:
protocol: ""
Awesome, thanks for checking it out!
Hey folks ๐๐ผ
This is a follow-up on #46, I was able to swap the gossip protocols and it worked as expected.
Now, I'm trying to disable the secondary protocol, for this the generated kops config should look like this:
notice the
secondary
empty string value for theprotocol
key.with the current provider code, if I set the config to this:
The terraform plan diff looks correct:
However, the produced kops config is rendered with an empty
secondary
block:while I was expecting:
Any suggestion on how to handle this case?