-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
condition: Add biosControl condition
Add the basic biosControl condition kind with task parameters struct and functions.
- Loading branch information
1 parent
2ba0f73
commit f6074af
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package condition | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
type ( | ||
BiosControlAction string | ||
) | ||
|
||
const ( | ||
// BiosControl identifies the Condition kind to configure the BIOS. | ||
BiosControl Kind = "biosControl" | ||
|
||
// ResetSettings will reset the BIOS to default settings. | ||
ResetSettings BiosControlAction = "reset_settings" | ||
) | ||
|
||
// BiosControlTaskParameters are the parameters that are passed for the BiosControl condition. | ||
type BiosControlTaskParameters struct { | ||
// Identifier for the Asset in the Asset store. | ||
// | ||
// Required: true | ||
AssetID uuid.UUID `json:"asset_id"` | ||
|
||
// The bios control action to be performed | ||
// | ||
// Required: true | ||
Action BiosControlAction `json:"action"` | ||
} | ||
|
||
func NewBiosControlTaskParameters(assetID uuid.UUID, action BiosControlAction) *BiosControlTaskParameters { | ||
return &BiosControlTaskParameters{ | ||
AssetID: assetID, | ||
Action: action, | ||
} | ||
} | ||
|
||
func NewBiosControlParametersFromCondition(condition *Condition) (*BiosControlTaskParameters, error) { | ||
b := &BiosControlTaskParameters{} | ||
err := json.Unmarshal(condition.Parameters, b) | ||
|
||
return b, err | ||
} |