Skip to content

Commit

Permalink
🌱 Rename DeviceState to PowerState.
Browse files Browse the repository at this point in the history
  • Loading branch information
guettli committed Nov 9, 2023
1 parent b33b89c commit 8793e7d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions api/v1alpha1/hivelocitymachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ type HivelocityMachineStatus struct {
// Region contains the name of the Hivelocity location the device is running.
Region Region `json:"region,omitempty"`

// DeviceState is the state of the device for this machine.
// PowerState is the power state of the device for this machine (ON|OFF).
// +optional
DeviceState string `json:"deviceState,omitempty"`
PowerState string `json:"powerState,omitempty"`

// FailureReason will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a succinct value suitable
Expand All @@ -159,7 +159,7 @@ type HivelocityMachineStatus struct {
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this HivelocityMachine belongs"
// +kubebuilder:printcolumn:name="Image",type="string",JSONPath=".spec.imageName",description="Image name"
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type",description="Device type"
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.deviceState",description="Hivelocity device state"
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.powerState",description="Hivelocity device state"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Machine ready status"
// +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="ProviderID of machine object"
// +kubebuilder:printcolumn:name="Machine",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Machine\")].name",description="Machine object which owns with this HivelocityMachine"
Expand Down Expand Up @@ -220,7 +220,7 @@ func (r *HivelocityMachine) SetMachineStatus(device hv.BareMetalDevice) {
Address: device.PrimaryIp,
},
}
r.Status.DeviceState = device.PowerStatus
r.Status.PowerState = device.PowerStatus
r.Status.Region = Region(device.LocationName)
}

Expand Down
16 changes: 8 additions & 8 deletions api/v1alpha1/hivelocitymachine_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ var _ = Describe("Test SetMachineStatus", func() {
Address: "hostname",
},
},
Region: Region("testregion"),
DeviceState: "on",
Region: Region("testregion"),
PowerState: "ON",
},
device: hv.BareMetalDevice{
Hostname: "device-hostname",
PrimaryIp: "127.0.0.1",
LocationName: "LAX2",
PowerStatus: "off",
PowerStatus: "OFF",
},
expectStatus: HivelocityMachineStatus{
Addresses: []clusterv1.MachineAddress{
Expand All @@ -178,8 +178,8 @@ var _ = Describe("Test SetMachineStatus", func() {
Address: "127.0.0.1",
},
},
Region: Region("LAX2"),
DeviceState: "off",
Region: Region("LAX2"),
PowerState: "OFF",
},
}),
Entry("no existing status", testCaseSetMachineStatus{
Expand All @@ -188,7 +188,7 @@ var _ = Describe("Test SetMachineStatus", func() {
Hostname: "device-hostname",
PrimaryIp: "127.0.0.1",
LocationName: "LAX2",
PowerStatus: "off",
PowerStatus: "OFF",
},
expectStatus: HivelocityMachineStatus{
Addresses: []clusterv1.MachineAddress{
Expand All @@ -205,8 +205,8 @@ var _ = Describe("Test SetMachineStatus", func() {
Address: "127.0.0.1",
},
},
Region: Region("LAX2"),
DeviceState: "off",
Region: Region("LAX2"),
PowerState: "OFF",
},
}),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
name: Type
type: string
- description: Hivelocity device state
jsonPath: .status.deviceState
jsonPath: .status.powerState
name: State
type: string
- description: Machine ready status
Expand Down Expand Up @@ -177,9 +177,6 @@ spec:
- type
type: object
type: array
deviceState:
description: DeviceState is the state of the device for this machine.
type: string
failureMessage:
description: FailureMessage will be set in the event that there is
a terminal problem reconciling the Machine and will contain a more
Expand All @@ -190,6 +187,10 @@ spec:
a terminal problem reconciling the Machine and will contain a succinct
value suitable for machine interpretation.
type: string
powerState:
description: PowerState is the power state of the device for this
machine (ON|OFF).
type: string
ready:
description: Ready is true when the provider resource is ready.
type: boolean
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/crd/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,14 @@ Region
</tr>
<tr>
<td>
<code>deviceState</code><br/>
<code>powerState</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>DeviceState is the state of the device for this machine.</p>
<p>PowerState is the state of the device for this machine.</p>
</td>
</tr>
<tr>
Expand Down

0 comments on commit 8793e7d

Please sign in to comment.