I was generating the rust code for this CRD and noticed that the code generated is using Array
instead of Vec for some fields.
Here's the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.2
installer.open-cluster-management.io/last-applied-configuration: ce84b11fb18eb5436f84845f6c462e1f6773cc46
creationTimestamp: "2022-02-14T14:03:43Z"
generation: 1
labels:
installer.name: multiclusterhub
installer.namespace: open-cluster-management
name: agents.agent-install.openshift.io
resourceVersion: "270891"
uid: 741e93d1-2f89-4945-8975-09a90983ba8f
spec:
conversion:
strategy: None
group: agent-install.openshift.io
names:
kind: Agent
listKind: AgentList
plural: agents
singular: agent
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: The name of the cluster the Agent registered to.
jsonPath: .spec.clusterDeploymentName.name
name: Cluster
type: string
- description: The
Approve
state of the Agent.
jsonPath: .spec.approved
name: Approved
type: boolean
- description: The role (master/worker) of the Agent.
jsonPath: .status.role
name: Role
type: string
- description: The HostStage of the Agent.
jsonPath: .status.progress.currentStage
name: Stage
type: string
- description: The hostname of the Agent.
jsonPath: .status.inventory.hostname
name: Hostname
priority: 1
type: string
- description: The requested hostname for the Agent.
jsonPath: .spec.hostname
name: Requested Hostname
priority: 1
type: string
name: v1beta1
schema:
openAPIV3Schema:
description: Agent is the Schema for the hosts API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: AgentSpec defines the desired state of Agent
properties:
approved:
type: boolean
clusterDeploymentName:
description: ClusterReference represents a Cluster Reference. It has
enough information to retrieve cluster in any namespace
properties:
name:
description: Name is unique within a namespace to reference a
cluster resource.
type: string
namespace:
description: Namespace defines the space within which the cluster
name must be unique.
type: string
type: object
hostname:
type: string
ignitionConfigOverrides:
description: Json formatted string containing the user overrides for
the host's ignition config
type: string
installation_disk_id:
description: InstallationDiskID defines the installation destination
disk (must be equal to the inventory disk id).
type: string
installerArgs:
description: Json formatted string containing the user overrides for
the host's coreos installer args
type: string
machineConfigPool:
type: string
role:
description: "HostRole host role \n swagger:model host-role"
type: string
required:
- approved
- role
type: object
status:
description: AgentStatus defines the observed state of Agent
properties:
bootstrap:
type: boolean
conditions:
items:
description: Condition represents the state of the operator's reconciliation
functionality.
properties:
lastHeartbeatTime:
format: date-time
type: string
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
description: ConditionType is the state of the operator's reconciliation
functionality.
type: string
required:
- status
- type
type: object
type: array
debugInfo:
description: DebugInfo includes information for debugging the installation
process.
properties:
eventsURL:
description: EventsURL specifies an HTTP/S URL that contains events
which occured during the cluster installation process
type: string
state:
description: Current state of the Agent
type: string
stateInfo:
description: Additional information pertaining to the status of
the Agent
type: string
type: object
hostname:
type: string
inventory:
properties:
bmcAddress:
type: string
bmcV6Address:
type: string
boot:
properties:
currentBootMode:
type: string
pxeInterface:
type: string
type: object
cpu:
properties:
architecture:
type: string
clockMegahertz:
description: 'Name in REST API: frequency'
format: int64
type: integer
count:
format: int64
type: integer
flags:
items:
type: string
type: array
modelName:
type: string
type: object
disks:
items:
properties:
bootable:
type: boolean
byID:
type: string
byPath:
type: string
driveType:
type: string
hctl:
type: string
id:
type: string
installationEligibility:
properties:
eligible:
type: boolean
notEligibleReasons:
items:
type: string
type: array
required:
- notEligibleReasons
type: object
ioPerf:
properties:
syncDurationMilliseconds:
description: 99th percentile of fsync duration in milliseconds
format: int64
type: integer
type: object
model:
type: string
name:
type: string
path:
type: string
serial:
type: string
sizeBytes:
format: int64
type: integer
smart:
type: string
vendor:
type: string
wwn:
type: string
required:
- id
type: object
type: array
hostname:
type: string
interfaces:
items:
properties:
biosDevName:
type: string
clientID:
type: string
flags:
items:
type: string
type: array
hasCarrier:
type: boolean
ipV4Addresses:
items:
type: string
type: array
ipV6Addresses:
items:
type: string
type: array
macAddress:
type: string
mtu:
format: int64
type: integer
name:
type: string
product:
type: string
speedMbps:
format: int64
type: integer
vendor:
type: string
required:
- flags
- ipV4Addresses
- ipV6Addresses
type: object
type: array
memory:
properties:
physicalBytes:
format: int64
type: integer
usableBytes:
format: int64
type: integer
type: object
reportTime:
description: 'Name in REST API: timestamp'
format: date-time
type: string
systemVendor:
properties:
manufacturer:
type: string
productName:
type: string
serialNumber:
type: string
virtual:
type: boolean
type: object
type: object
ntpSources:
items:
properties:
sourceName:
type: string
sourceState:
description: "SourceState source state \n swagger:model source_state"
type: string
type: object
type: array
progress:
properties:
currentStage:
description: "HostStage host stage \n swagger:model host-stage"
type: string
progressInfo:
type: string
stageStartTime:
description: 'Name in REST API: stage_started_at'
format: date-time
type: string
stageUpdateTime:
description: 'Name in REST API: stage_updated_at'
format: date-time
type: string
type: object
role:
description: "HostRole host role \n swagger:model host-role"
type: string
validationsInfo:
additionalProperties:
items:
properties:
id:
type: string
message:
type: string
status:
type: string
required:
- id
- message
- status
type: object
type: array
description: ValidationsInfo is a JSON-formatted string containing
the validation results for each validation id grouped by category
(network, hosts-data, etc.)
type: object
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: Agent
listKind: AgentList
plural: agents
singular: agent
conditions:
- lastTransitionTime: "2022-02-14T14:03:43Z"
message: no conflicts found
reason: NoConflicts
status: "True"
type: NamesAccepted
- lastTransitionTime: "2022-02-14T14:03:43Z"
message: the initial names have been accepted
reason: InitialNamesAccepted
status: "True"
type: Established
storedVersions:
- v1beta1
use kube::CustomResource;
use serde::{Serialize, Deserialize};
use std::collections::BTreeMap;
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug)]
#[kube(group = "agent-install.openshift.io", version = "v1beta1", kind = "Agent", plural = "agents")]
#[kube(namespaced)]
#[kube(schema = "disabled")]
pub struct AgentSpec {
pub approved: bool,
pub clusterDeploymentName: Option<AgentClusterDeploymentName>,
pub hostname: Option<String>,
pub ignitionConfigOverrides: Option<String>,
pub installation_disk_id: Option<String>,
pub installerArgs: Option<String>,
pub machineConfigPool: Option<String>,
pub role: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentClusterDeploymentName {
pub name: Option<String>,
pub namespace: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatus {
pub bootstrap: Option<bool>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub conditions: Vec<AgentStatusConditions>,
pub debugInfo: Option<AgentStatusDebugInfo>,
pub hostname: Option<String>,
pub inventory: Option<AgentStatusInventory>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub ntpSources: Vec<AgentStatusNtpSources>,
pub progress: Option<AgentStatusProgress>,
pub role: Option<String>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub validationsInfo: BTreeMap<String, Array>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusConditions {
pub lastHeartbeatTime: Option<String>,
pub lastTransitionTime: Option<String>,
pub message: Option<String>,
pub reason: Option<String>,
pub status: String,
pub r#type: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusDebugInfo {
pub eventsURL: Option<String>,
pub state: Option<String>,
pub stateInfo: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventory {
pub bmcAddress: Option<String>,
pub bmcV6Address: Option<String>,
pub boot: Option<AgentStatusInventoryBoot>,
pub cpu: Option<AgentStatusInventoryCpu>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub disks: Vec<AgentStatusInventoryDisks>,
pub hostname: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub interfaces: Vec<AgentStatusInventoryInterfaces>,
pub memory: Option<AgentStatusInventoryMemory>,
pub reportTime: Option<String>,
pub systemVendor: Option<AgentStatusInventorySystemVendor>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventoryBoot {
pub currentBootMode: Option<String>,
pub pxeInterface: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventoryCpu {
pub architecture: Option<String>,
pub clockMegahertz: Option<i64>,
pub count: Option<i64>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub flags: Vec<String>,
pub modelName: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventoryDisks {
pub bootable: Option<bool>,
pub byID: Option<String>,
pub byPath: Option<String>,
pub driveType: Option<String>,
pub hctl: Option<String>,
pub id: String,
pub installationEligibility: Option<AgentStatusInventoryDisksInstallationEligibility>,
pub ioPerf: Option<AgentStatusInventoryDisksIoPerf>,
pub model: Option<String>,
pub name: Option<String>,
pub path: Option<String>,
pub serial: Option<String>,
pub sizeBytes: Option<i64>,
pub smart: Option<String>,
pub vendor: Option<String>,
pub wwn: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventoryDisksInstallationEligibility {
pub eligible: Option<bool>,
pub notEligibleReasons: Vec<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventoryDisksIoPerf {
pub syncDurationMilliseconds: Option<i64>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventoryInterfaces {
pub biosDevName: Option<String>,
pub clientID: Option<String>,
pub flags: Vec<String>,
pub hasCarrier: Option<bool>,
pub ipV4Addresses: Vec<String>,
pub ipV6Addresses: Vec<String>,
pub macAddress: Option<String>,
pub mtu: Option<i64>,
pub name: Option<String>,
pub product: Option<String>,
pub speedMbps: Option<i64>,
pub vendor: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventoryMemory {
pub physicalBytes: Option<i64>,
pub usableBytes: Option<i64>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusInventorySystemVendor {
pub manufacturer: Option<String>,
pub productName: Option<String>,
pub serialNumber: Option<String>,
pub virtual: Option<bool>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusNtpSources {
pub sourceName: Option<String>,
pub sourceState: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AgentStatusProgress {
pub currentStage: Option<String>,
pub progressInfo: Option<String>,
pub stageStartTime: Option<String>,
pub stageUpdateTime: Option<String>,
}