Skip to content

Commit

Permalink
Added missing 'description' field to 'ovirt_affinity_group'
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Bonic committed Jun 4, 2022
1 parent d4d1bd2 commit 31d4296
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/resources/affinity_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ resource "ovirt_affinity_group" "test" {

### Optional

- `description` (String) The description of the affinity group
- `enforcing` (Boolean) If set to true, VMs will fail to start if the affinity group cannot be observed.
- `hosts_rule` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--hosts_rule))
- `priority` (Number) Order in which the affinity group should be applied.
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ require (
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/ovirt/go-ovirt-client v1.0.0-beta1
github.com/ovirt/go-ovirt v0.0.0-20220427092237-114c47f2835c // indirect
github.com/ovirt/go-ovirt-client v1.0.0-beta2
github.com/ovirt/go-ovirt-client-log/v2 v2.2.0 // indirect
github.com/ovirt/go-ovirt-client-log/v3 v3.0.0
github.com/vmihailenco/tagparser v0.1.2 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,19 @@ github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/ovirt/go-ovirt v0.0.0-20210809163552-d4276e35d3db/go.mod h1:Zkdj9/rW6eyuw0uOeEns6O3pP5G2ak+bI/tgkQ/tEZI=
github.com/ovirt/go-ovirt v0.0.0-20220427092237-114c47f2835c h1:jXRFpl7+W0YZj/fghoYuE4vJWW/KeQGvdrhnRwRGtAY=
github.com/ovirt/go-ovirt v0.0.0-20220427092237-114c47f2835c/go.mod h1:Zkdj9/rW6eyuw0uOeEns6O3pP5G2ak+bI/tgkQ/tEZI=
github.com/ovirt/go-ovirt-client v1.0.0-alpha2 h1:XMCaoZStCoZcK5gkRexc5Xi4T4IWFDyWSeW1nooOsz4=
github.com/ovirt/go-ovirt-client v1.0.0-alpha2/go.mod h1:OkR+/CC42lprXXzml/nTDPYzWTiYePvuaN2Kb2xeLr0=
github.com/ovirt/go-ovirt-client v1.0.0-alpha9.0.20220604095900-963732759f6f h1:LKaHlmEdg8cJWX8V0SS4HcDnb10xHBiotSgHTvD4CSs=
github.com/ovirt/go-ovirt-client v1.0.0-alpha9.0.20220604095900-963732759f6f/go.mod h1:tv8E2pxUkggayDAgMLuQHzcNtzt8RFvnhO5V5b/5X4U=
github.com/ovirt/go-ovirt-client v1.0.0-beta1 h1:sjZncrFAMMFj4gDW2q50q2gm9dyKHUMKWLmbqYnVAU0=
github.com/ovirt/go-ovirt-client v1.0.0-beta1/go.mod h1:tv8E2pxUkggayDAgMLuQHzcNtzt8RFvnhO5V5b/5X4U=
github.com/ovirt/go-ovirt-client v1.0.0-beta2 h1:GszjqWO9he3h1Y4SUUAxz/5Wgev/p1A6MVIf7Z8eQXg=
github.com/ovirt/go-ovirt-client v1.0.0-beta2/go.mod h1:tv8E2pxUkggayDAgMLuQHzcNtzt8RFvnhO5V5b/5X4U=
github.com/ovirt/go-ovirt-client-log/v2 v2.2.0 h1:7iZQs+8moX7aopeAdNU1b12mF/yWWBVA/Pey55F9PTQ=
github.com/ovirt/go-ovirt-client-log/v2 v2.2.0/go.mod h1:mDoU3KIwftpsgZGzXGk5d2UEJYTY0bYMfg/GwPapXL0=
github.com/ovirt/go-ovirt-client-log/v3 v3.0.0 h1:uvACVHYhYPMkNJrrgWiABcfELB6qoFfsDDUTbpb4Jv4=
github.com/ovirt/go-ovirt-client-log/v3 v3.0.0/go.mod h1:chKKxCv4lRjxezrTG+EIhkWXGhDAWByglPVXh/iYdnQ=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
16 changes: 16 additions & 0 deletions internal/ovirt/resource_ovirt_affinity_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ var affinityGroupSchema = map[string]*schema.Schema{
ForceNew: true,
ValidateDiagFunc: validateNonEmpty,
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: "The description of the affinity group",
ForceNew: true,
},
"priority": {
Type: schema.TypeFloat,
Optional: true,
Expand Down Expand Up @@ -129,6 +135,13 @@ func (p *provider) affinityGroupCreate(ctx context.Context, data *schema.Resourc

clusterID := ovirtclient.ClusterID(data.Get("cluster_id").(string))
name := data.Get("name").(string)
if description, ok := data.GetOk("description"); ok {
var err error
params, err = params.WithDescription(description.(string))
if err != nil {
return errorToDiags("add description to affinity group", err)
}
}

ag, err := client.CreateAffinityGroup(clusterID, name, params)
if err != nil {
Expand All @@ -144,6 +157,9 @@ func affinityGroupToData(ag ovirtclient.AffinityGroup, data *schema.ResourceData
if err := data.Set("name", ag.Name()); err != nil {
diags = append(diags, errorToDiag("set name", err))
}
if err := data.Set("description", ag.Description()); err != nil {
diags = append(diags, errorToDiag("set description", err))
}

if err := data.Set("enforcing", ag.Enforcing()); err != nil {
diags = append(diags, errorToDiag("set enforcing", err))
Expand Down

0 comments on commit 31d4296

Please sign in to comment.