Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unmarshal(cfg string) to VendorConfigManager #17

Merged
merged 18 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
405a457
Add supermicro.Unmarshal() to config
splaspood May 30, 2024
22ec803
config/supermicro: Add config normalization functions
splaspood Jun 3, 2024
d7c5278
config/supermicro: Enforce ISO-8859-1/UTF-8 XML decoding
splaspood Jun 3, 2024
3400aa0
FS-1123: Enable line numbering for lint in GHA
splaspood Jun 5, 2024
e4d8a1e
FS-1123: Uncuddle my if
splaspood Jun 5, 2024
a070a21
FS-1123: Flesh out generic config options for supermicro a bit
splaspood Jun 5, 2024
cfd9f1a
FS-1123: Add generic configuration functions to interface
splaspood Jun 5, 2024
9b517fc
config/asrockrack.go: Explicitly return err from Unmarshal()
splaspood Jul 18, 2024
bd1910e
config/dell.go: Explicitly return err from Unmarshal()
splaspood Jul 18, 2024
dc11699
config/supermicro.go: Implement Menu/Setting finder functions
splaspood Jul 18, 2024
48975f6
config/asrockrack.go, config/dell.go: Use explict returns
splaspood Jul 18, 2024
1eff505
config/supermicro.go: Describe reasoning for use of for loops in Boot…
splaspood Jul 18, 2024
4150ec4
config/asrockrack.go, config/dell.go: Add dummy Unimplemented BootOrd…
splaspood Jul 18, 2024
a8e48f6
config/asrockrack.go, config/dell.go: Add dummy Unimplemented BootMod…
splaspood Jul 18, 2024
f23f69e
config/asrockrack.go, config/dell.go: Add dummy Unimplemented for rem…
splaspood Jul 18, 2024
fc87035
config/asrockrack.go, config/dell.go: Properly return nil for unimple…
splaspood Jul 18, 2024
e7cce54
config/supermicro.go: Correcting lint
splaspood Jul 18, 2024
bac336d
config/supermicro.go: Refactor FindOrCreateSetting to avoid premature…
splaspood Jul 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend smaller interfaces, so not all vendor implementations are forced to implement all of these

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
Loading