Skip to content

Commit

Permalink
lxc: Update fields of api entities
Browse files Browse the repository at this point in the history
Signed-off-by: Din Music <din.music@canonical.com>
  • Loading branch information
MusicDin committed Mar 6, 2024
1 parent 5c1b82c commit 0631dd4
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 26 deletions.
20 changes: 10 additions & 10 deletions lxc/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func (c *cmdGroupPermissionAdd) run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Group %q already has entitlement %q on entity %q", resource.name, permission.Entitlement, permission.EntityReference)
}

return resource.server.UpdateAuthGroup(resource.name, group.AuthGroupPut, eTag)
return resource.server.UpdateAuthGroup(resource.name, group.Writable(), eTag)
}

type cmdGroupPermissionRemove struct {
Expand Down Expand Up @@ -628,8 +628,8 @@ func (c *cmdGroupPermissionRemove) run(cmd *cobra.Command, args []string) error
return fmt.Errorf("Group %q does not have entitlement %q on entity %q", resource.name, permission.Entitlement, permission.EntityReference)
}

group.AuthGroupPut.Permissions = permissions
return resource.server.UpdateAuthGroup(resource.name, group.AuthGroupPut, eTag)
group.Permissions = permissions
return resource.server.UpdateAuthGroup(resource.name, group.Writable(), eTag)
}

// parsePermissionArgs parses the `<entity_type> [<entity_name>] <entitlement> [<key>=<value>...]` arguments of
Expand Down Expand Up @@ -832,7 +832,7 @@ func (c *cmdIdentityShow) command() *cobra.Command {
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Show identity configurations
The argument must be a concatenation of the authentication method and either the
The argument must be a concatenation of the authentication method and either the
name or identifier of the identity, delimited by a forward slash. This command
will fail if an identity name is used that is not unique within the authentication
method. Use the identifier instead if this occurs.
Expand Down Expand Up @@ -1151,7 +1151,7 @@ func (c *cmdIdentityGroupAdd) run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Identity %q is already a member of group %q", resource.name, args[1])
}

return resource.server.UpdateIdentity(authenticationMethod, nameOrID, identity.IdentityPut, eTag)
return resource.server.UpdateIdentity(authenticationMethod, nameOrID, identity.Writable(), eTag)
}

type cmdIdentityGroupRemove struct {
Expand Down Expand Up @@ -1218,8 +1218,8 @@ func (c *cmdIdentityGroupRemove) run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Identity %q is not a member of group %q", resource.name, args[0])
}

identity.IdentityPut.Groups = groups
return resource.server.UpdateIdentity(authenticationMethod, nameOrID, identity.IdentityPut, eTag)
identity.Groups = groups
return resource.server.UpdateIdentity(authenticationMethod, nameOrID, identity.Writable(), eTag)
}

type cmdPermission struct {
Expand Down Expand Up @@ -1912,7 +1912,7 @@ func (c *cmdIdentityProviderGroupGroupAdd) run(cmd *cobra.Command, args []string
return fmt.Errorf("Identity group %q is already mapped to group %q", resource.name, args[1])
}

return resource.server.UpdateIdentityProviderGroup(resource.name, idpGroup.IdentityProviderGroupPut, eTag)
return resource.server.UpdateIdentityProviderGroup(resource.name, idpGroup.Writable(), eTag)
}

type cmdIdentityProviderGroupGroupRemove struct {
Expand Down Expand Up @@ -1974,6 +1974,6 @@ func (c *cmdIdentityProviderGroupGroupRemove) run(cmd *cobra.Command, args []str
return fmt.Errorf("Identity provider group %q is not mapped to group %q", resource.name, args[1])
}

idpGroup.IdentityProviderGroupPut.Groups = groups
return resource.server.UpdateIdentityProviderGroup(resource.name, idpGroup.IdentityProviderGroupPut, eTag)
idpGroup.Groups = groups
return resource.server.UpdateIdentityProviderGroup(resource.name, idpGroup.Writable(), eTag)
}
2 changes: 1 addition & 1 deletion lxc/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (c *cmdClusterList) Run(cmd *cobra.Command, args []string) error {
// Render the table
data := [][]string{}
for _, member := range members {
roles := member.ClusterMemberPut.Roles
roles := member.Roles
rolesDelimiter := "\n"
if c.flagFormat == "csv" {
rolesDelimiter = ","
Expand Down
2 changes: 1 addition & 1 deletion lxc/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ func (c *cmdList) matchByStatus(cInfo *api.Instance, cState *api.InstanceState,
}

func (c *cmdList) matchByArchitecture(cInfo *api.Instance, cState *api.InstanceState, query string) bool {
return strings.EqualFold(cInfo.InstancePut.Architecture, query)
return strings.EqualFold(cInfo.Architecture, query)
}

func (c *cmdList) matchByLocation(cInfo *api.Instance, cState *api.InstanceState, query string) bool {
Expand Down
14 changes: 6 additions & 8 deletions lxc/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ func TestDotPrefixMatch(t *testing.T) {
func TestShouldShow(t *testing.T) {
list := cmdList{}
inst := &api.Instance{
Name: "foo",
Name: "foo",
Type: "Container",
Status: "Running",
Location: "mem-brain",
Architecture: "potato",
Description: "Something which does something",
ExpandedConfig: map[string]string{
"security.privileged": "1",
"user.blah": "abc",
"image.os": "Debian",
"image.description": "Debian buster amd64 (20200429_05:24)",
},
Status: "Running",
Location: "mem-brain",
Type: "Container",
ExpandedDevices: map[string]map[string]string{
"eth0": {
"name": "eth0",
Expand All @@ -45,10 +47,6 @@ func TestShouldShow(t *testing.T) {
"nictype": "bridged",
},
},
InstancePut: api.InstancePut{
Architecture: "potato",
Description: "Something which does something",
},
}

state := &api.InstanceState{
Expand Down
2 changes: 1 addition & 1 deletion lxc/network_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func (c *cmdNetworkACLEdit) Run(cmd *cobra.Command, args []string) error {
return err
}

return resource.server.UpdateNetworkACL(resource.name, newdata.NetworkACLPut, "")
return resource.server.UpdateNetworkACL(resource.name, newdata.Writable(), "")
}

// Get the current config.
Expand Down
2 changes: 1 addition & 1 deletion lxc/network_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ func (c *cmdNetworkForwardEdit) Run(cmd *cobra.Command, args []string) error {

newData.Normalise()

return client.UpdateNetworkForward(resource.name, args[1], newData.NetworkForwardPut, "")
return client.UpdateNetworkForward(resource.name, args[1], newData.Writable(), "")
}

// Get the current config.
Expand Down
2 changes: 1 addition & 1 deletion lxc/network_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ func (c *cmdNetworkLoadBalancerEdit) Run(cmd *cobra.Command, args []string) erro

newData.Normalise()

return client.UpdateNetworkLoadBalancer(resource.name, args[1], newData.NetworkLoadBalancerPut, "")
return client.UpdateNetworkLoadBalancer(resource.name, args[1], newData.Writable(), "")
}

// Get the current config.
Expand Down
2 changes: 1 addition & 1 deletion lxc/network_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func (c *cmdNetworkPeerEdit) Run(cmd *cobra.Command, args []string) error {
return err
}

return client.UpdateNetworkPeer(resource.name, args[1], newData.NetworkPeerPut, "")
return client.UpdateNetworkPeer(resource.name, args[1], newData.Writable(), "")
}

// Get the current config.
Expand Down
4 changes: 2 additions & 2 deletions lxc/network_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (c *cmdNetworkZoneEdit) Run(cmd *cobra.Command, args []string) error {
return err
}

return resource.server.UpdateNetworkZone(resource.name, newdata.NetworkZonePut, "")
return resource.server.UpdateNetworkZone(resource.name, newdata.Writable(), "")
}

// Get the current config.
Expand Down Expand Up @@ -1110,7 +1110,7 @@ func (c *cmdNetworkZoneRecordEdit) Run(cmd *cobra.Command, args []string) error
return err
}

return resource.server.UpdateNetworkZoneRecord(resource.name, args[1], newdata.NetworkZoneRecordPut, "")
return resource.server.UpdateNetworkZoneRecord(resource.name, args[1], newdata.Writable(), "")
}

// Get the current config.
Expand Down

0 comments on commit 0631dd4

Please sign in to comment.