Skip to content

Commit

Permalink
Merge pull request #17 from bmc-toolbox/vcm-unmarshal-0
Browse files Browse the repository at this point in the history
Add Unmarshal(cfg string) to VendorConfigManager
  • Loading branch information
splaspood authored Jul 23, 2024
2 parents 3db7cec + bac336d commit 8256ba7
Show file tree
Hide file tree
Showing 8 changed files with 369 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: -v --config .golangci.yml --timeout=5m
args: -v --config .golangci.yml --timeout=5m --out-format=colored-line-number
version: latest
43 changes: 43 additions & 0 deletions config/asrockrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,51 @@ func (cm *asrockrackVendorConfig) Marshal() (string, error) {
}
}

func (cm *asrockrackVendorConfig) Unmarshal(cfgData string) error {
return xml.Unmarshal([]byte(cfgData), cm.ConfigData)
}

func (cm *asrockrackVendorConfig) StandardConfig() (biosConfig map[string]string, err error) {
return biosConfig, err
}

// Generic config options

func (cm *asrockrackVendorConfig) BootOrder(mode string) error {
// Unimplemented
return nil
}

func (cm *asrockrackVendorConfig) BootMode(mode string) error {
// Unimplemented
return nil
}

func (cm *asrockrackVendorConfig) IntelSGX(mode string) error {
// Unimplemented
return nil
}

func (cm *asrockrackVendorConfig) SecureBoot(enable bool) error {
// Unimplemented
return nil
}

func (cm *asrockrackVendorConfig) TPM(enable bool) error {
// Unimplemented
return nil
}

func (cm *asrockrackVendorConfig) SMT(enable bool) error {
// Unimplemented
return nil
}

func (cm *asrockrackVendorConfig) SRIOV(enable bool) error {
// Unimplemented
return nil
}

func (cm *asrockrackVendorConfig) EnableTPM() {
// Unimplemented
}
Expand Down
43 changes: 43 additions & 0 deletions config/dell.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,51 @@ func (cm *dellVendorConfig) Marshal() (string, error) {
}
}

func (cm *dellVendorConfig) Unmarshal(cfgData string) error {
return xml.Unmarshal([]byte(cfgData), cm.ConfigData)
}

func (cm *dellVendorConfig) StandardConfig() (biosConfig map[string]string, err error) {
return biosConfig, err
}

// Generic config options

func (cm *dellVendorConfig) BootOrder(mode string) error {
// Unimplemented
return nil
}

func (cm *dellVendorConfig) BootMode(mode string) error {
// Unimplemented
return nil
}

func (cm *dellVendorConfig) IntelSGX(mode string) error {
// Unimplemented
return nil
}

func (cm *dellVendorConfig) SecureBoot(enable bool) error {
// Unimplemented
return nil
}

func (cm *dellVendorConfig) TPM(enable bool) error {
// Unimplemented
return nil
}

func (cm *dellVendorConfig) SMT(enable bool) error {
// Unimplemented
return nil
}

func (cm *dellVendorConfig) SRIOV(enable bool) error {
// Unimplemented
return nil
}

func (cm *dellVendorConfig) EnableTPM() {
cm.Raw("EnableTPM", "Enabled", []string{"BIOS.Setup.1-1"})
}
Expand Down
16 changes: 16 additions & 0 deletions config/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,27 @@ import (

var errUnknownConfigFormat = errors.New("unknown config format")
var errUnknownVendor = errors.New("unknown/unsupported vendor")
var errUnknownSettingType = errors.New("unknown setting type")

var errInvalidBootModeOption = errors.New("invalid BootMode option <LEGACY|UEFI|DUAL>")
var errInvalidSGXOption = errors.New("invalid SGX option <Enabled|Disabled|Software Controlled>")

func UnknownConfigFormatError(format string) error {
return fmt.Errorf("unknown config format %w : %s", errUnknownConfigFormat, format)
}

func UnknownSettingType(t string) error {
return fmt.Errorf("unknown setting type %w : %s", errUnknownSettingType, t)
}

func UnknownVendorError(vendorName string) error {
return fmt.Errorf("unknown/unsupported vendor %w : %s", errUnknownVendor, vendorName)
}

func InvalidBootModeOption(mode string) error {
return fmt.Errorf("%w : %s", errInvalidBootModeOption, mode)
}

func InvalidSGXOption(mode string) error {
return fmt.Errorf("%w : %s", errInvalidSGXOption, mode)
}
13 changes: 10 additions & 3 deletions config/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ import (
)

type VendorConfigManager interface {
EnableTPM()
EnableSRIOV()

Raw(name, value string, menuPath []string)
Marshal() (string, error)
Unmarshal(cfgData string) (err error)
StandardConfig() (biosConfig map[string]string, err error)

BootMode(mode string) error
BootOrder(mode string) error
IntelSGX(mode string) error
SecureBoot(enable bool) error
TPM(enable bool) error
SMT(enable bool) error
SRIOV(enable bool) error
}

func NewVendorConfigManager(configFormat, vendorName string, vendorOptions map[string]string) (VendorConfigManager, error) {
Expand Down
Loading

0 comments on commit 8256ba7

Please sign in to comment.