Skip to content

Commit

Permalink
admin/init: use api.InitProfileProjectPost
Browse files Browse the repository at this point in the history
Signed-off-by: Meghea Iulian <[email protected]>
  • Loading branch information
megheaiulian committed Jan 26, 2025
1 parent b126b0a commit 5d43fed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
38 changes: 22 additions & 16 deletions cmd/incus/admin_init_auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,20 @@ func (c *cmdAdminInit) RunAuto(cmd *cobra.Command, args []string, d incus.Instan
config.StoragePools = []api.StoragePoolsPost{pool}

// Profile entry
config.Profiles = []api.ProfilesPost{{
Name: "default",
ProfilePut: api.ProfilePut{
Devices: map[string]map[string]string{
"root": {
"type": "disk",
"path": "/",
"pool": pool.Name,
config.Profiles = []api.InitProfileProjectPost{{
ProfilesPost: api.ProfilesPost{
Name: "default",
ProfilePut: api.ProfilePut{
Devices: map[string]map[string]string{
"root": {
"type": "disk",
"path": "/",
"pool": pool.Name,
},
},
},
},
Project: api.ProjectDefaultName,
}}
}

Expand Down Expand Up @@ -170,17 +173,20 @@ func (c *cmdAdminInit) RunAuto(cmd *cobra.Command, args []string, d incus.Instan

// Add it to the profile
if config.Profiles == nil {
config.Profiles = []api.ProfilesPost{{
Name: "default",
ProfilePut: api.ProfilePut{
Devices: map[string]map[string]string{
"eth0": {
"type": "nic",
"network": network.Name,
"name": "eth0",
config.Profiles = []api.InitProfileProjectPost{{
ProfilesPost: api.ProfilesPost{
Name: "default",
ProfilePut: api.ProfilePut{
Devices: map[string]map[string]string{
"eth0": {
"type": "nic",
"network": network.Name,
"name": "eth0",
},
},
},
},
Project: api.ProjectDefaultName,
}}
} else {
config.Profiles[0].Devices["eth0"] = map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion cmd/incus/admin_init_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *cmdAdminInit) RunDump(d incus.InstanceServer) error {
}

for _, profile := range profiles {
profilesPost := api.ProfilesPost{}
profilesPost := api.InitProfileProjectPost{}
profilesPost.Config = profile.Config
profilesPost.Description = profile.Description
profilesPost.Devices = profile.Devices
Expand Down
13 changes: 8 additions & 5 deletions cmd/incus/admin_init_interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ func (c *cmdAdminInit) RunInteractive(cmd *cobra.Command, args []string, d incus
config.Server.Config = map[string]string{}
config.Server.Networks = []api.InitNetworksProjectPost{}
config.Server.StoragePools = []api.StoragePoolsPost{}
config.Server.Profiles = []api.ProfilesPost{
config.Server.Profiles = []api.InitProfileProjectPost{
{
Name: "default",
ProfilePut: api.ProfilePut{
Config: map[string]string{},
Devices: map[string]map[string]string{},
ProfilesPost: api.ProfilesPost{
Name: "default",
ProfilePut: api.ProfilePut{
Config: map[string]string{},
Devices: map[string]map[string]string{},
},
},
Project: api.ProjectDefaultName,
},
}

Expand Down

0 comments on commit 5d43fed

Please sign in to comment.