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

feat: add machine method get-curtin-config #70

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions api/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ type Machine interface {
RestoreDefaultConfiguration(systemID string) error
RestoreNetworkingConfiguration(systemID string) error
RestoreStorageConfiguration(systemID string) error
GetCurtinConfig(systemID string) (map[string]interface{}, error)
}
12 changes: 12 additions & 0 deletions client/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/google/go-querystring/query"
"github.com/maas/gomaasclient/entity"
"gopkg.in/mgo.v2/bson"
"gopkg.in/yaml.v3"
)

// Machine contains functionality for manipulating the Machine entity.
Expand Down Expand Up @@ -278,6 +279,7 @@ func (m *Machine) GetToken(systemID string) (*entity.MachineToken, error) {
return machineToken, err
}

// Details gets the details for a given machine
func (m *Machine) Details(systemID string) (*entity.MachineDetails, error) {
machineDetails := new(entity.MachineDetails)
err := m.client(systemID).Get("details", url.Values{}, func(data []byte) error {
Expand All @@ -301,3 +303,13 @@ func (m *Machine) RestoreNetworkingConfiguration(systemID string) error {
func (m *Machine) RestoreStorageConfiguration(systemID string) error {
return m.client(systemID).Post("restore_storage_configuration", url.Values{}, func(data []byte) error { return nil })
}

// GetCurtinConfig gets the curtin config for a given machine
func (m *Machine) GetCurtinConfig(systemID string) (map[string]interface{}, error) {
curtinConfig := map[string]interface{}{}
err := m.client(systemID).Get("get_curtin_config", url.Values{}, func(data []byte) error {
return yaml.Unmarshal(data, &curtinConfig)
})

return curtinConfig, err
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/juju/gomaasapi/v2 v2.2.0
github.com/stretchr/testify v1.9.0
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -19,5 +20,4 @@ require (
github.com/juju/schema v1.0.1 // indirect
github.com/juju/version v0.0.0-20210303051006-2015802527a8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)