Closed kke closed 5 years ago
I don't understand the "k8s-style":
describe '#recursive_compact' do
it 'compacts hashes recursively with k8s style' do
hash = YAML.load('
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: web-allow-external
spec:
podSelector:
matchLabels:
app: web
foo: ""
bar: {}
baz: []
ingress:
- from: []
')
expect(described_class.recursive_compact(hash)).to eq({
"apiVersion"=>"networking.k8s.io/v1",
"kind"=>"NetworkPolicy",
"metadata"=>{"name"=>"web-allow-external"},
"spec"=>{
"podSelector"=>{
"matchLabels"=>{
"app"=>"web",
"foo"=>""
}
},
"ingress"=>[{
"from"=>[]
}]
}
})
end
end
Why did spec.podSelector.bar/baz
get dropped but spec.ingress.*.from
was not? Where is this style documented?
I don't think it actually makes much difference. It's only used for storing the last-applied-configuration
for stacks.
Looking at kube docs:
There's an empty hash in there.
Does not matter
It's weird and I don't see how it would go deeper than one level.