fierce-dinner-20116
05/03/2019, 9:09 PM// Make the 'frontend' Service public by setting it to be of type
// LoadBalancer
if (obj.kind == "Service" && obj.metadata.name == "frontend") {
if (obj.spec) {
obj.spec.type = "LoadBalancer"
}
}
Is there a way to just tell the compiler that obj
is a k8s Service
, and just assign obj.spec.type=Loadbalancer directly without needing to check to see if spec
is a field on obj
at all?white-balloon-205
if (Service.isInstance(obj)) {
...
}
and get strong typing of obj
inside the if
- which is a nice thing TypeScript supports.
But that wouldn't help a ton in this particular case. You'd still need to check whether metadata.name
was "frontend"
separately. And then you'd still have the possibility that obj.spec
was undefined, so you'd need to guard against that (unless you were willing to trust that anything with the name
you are expecting has a non-undefined obj.spec
? In that case, you could leave off the other if
and just use obj.spec!.type = "LoadBalancer"
)fierce-dinner-20116
05/03/2019, 10:37 PMif
statement would be a huge help to me. Not having ide-support when writing transformations really is like flying blindwhite-balloon-205
fierce-dinner-20116
05/03/2019, 10:48 PMk8s.yaml.ConfigGroup
that points that entire folderif
statements would make it really easy to be able to target modifications to a specific file since I’ve already split them out by type