controller-tools
controller-tools copied to clipboard
Inconsistent `inline` behaviour for embedded structs depending on pointer/value type
I'm not sure if this is a bug or a feature, but I couldn't find documentation for it so thought I'd raise an issue.
When using controller-gen, and using the inline json tag on an embedded struct pointer, it appears that the generated CRDs come out with a field "inline". If I make the field (TelemetrySpec in the below example) a value type, the CRDs correctly inline the type's fields as expected.
Structs
type TelemetrySpec struct {
Prometheus *PrometheusTelemetrySpec `json:"prometheus,omitempty"`
Vector *VectorSpec `json:"vector,omitempty"`
}
type CassandraTelemetrySpec struct {
*TelemetrySpec `json:",inline"`
Mcac *McacTelemetrySpec `json:"mcac,omitempty"`
Cassandra *CassandraAgentSpec `json:"cassandra,omitempty"`
}
Generated CRD (with pointer)
properties:
cassandra:
properties:
...
inline:
properties:
prometheus:
properties:
commonLabels:
additionalProperties:
type: string
description: CommonLabels are applied to all
serviceMonitors created.
type: object
enabled:
description: Enable the creation of Prometheus
serviceMonitors for this resource (Cassandra
or Stargate).
type: boolean
type: object
vector:
Generated CRD (with value type)
properties:
cassandra:
properties:
...
mcac:
properties:
enabled:
description: enabled sets whether MCAC (legacy metrics
endpoint) is enabled. This is considered true
by default.
type: boolean
metricFilters:
description: 'MetricFilters allows passing filters
to MCAC in order to reduce the amount of extracted
metrics. Not setting this field will result in
the default filters being used: - "deny:org.apache.cassandra.metrics.Table"
- "deny:org.apache.cassandra.metrics.table" -
"allow:org.apache.cassandra.metrics.table.live_ss_table_count"
- "allow:org.apache.cassandra.metrics.Table.LiveSSTableCount"
- "allow:org.apache.cassandra.metrics.table.live_disk_space_used"
- "allow:org.apache.cassandra.metrics.table.LiveDiskSpaceUsed"
- "allow:org.apache.cassandra.metrics.Table.Pending"
- "allow:org.apache.cassandra.metrics.Table.Memtable"
- "allow:org.apache.cassandra.metrics.Table.Compaction"
- "allow:org.apache.cassandra.metrics.table.read"
- "allow:org.apache.cassandra.metrics.table.write"
- "allow:org.apache.cassandra.metrics.table.range"
- "allow:org.apache.cassandra.metrics.table.coordinator"
- "allow:org.apache.cassandra.metrics.table.dropped_mutations"
Setting it to an empty list will result in all