Skip to content

Commit

Permalink
#297: remove pre-0.5.0 deprecated attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
treywelsh authored and frousselet committed Oct 25, 2022
1 parent 5c45232 commit ae56cf2
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 212 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ FEATURES:

* **New Resource**: `opennebula_cluster` (#227)

DEPRECATION:

* resources/opennebula_group: remove deprecated attribute `delete_on_destruction` (#297)
* resources/opennebula_group: remove deprecated attribute `template` (#297)
* data/opennebula_group: remove deprecated attribute `quotas` (#297)
* data/opennebula_user remove deprecated attribute `quotas` (#297)
* data/opennebula_template: remove deprecated attribute `context` (#297)
* data/opennebula_template: remove deprecated attribute `graphics` (#297)
* data/opennebula_template: remove deprecated attribute `os` (#297)
* data/opennebula_virtual_network: remove deprecated attribute `description` (#297)

# 1.0.1 (October 3rd, 2022)

BUG FIXES:
Expand All @@ -23,6 +34,7 @@ ENHANCEMENTS:
BUG FIXES:

* resource/opennebula_virtual_machine: Fix diff on template inherited attributes `sched_requirements` and `sched_ds_requirements` (#330)
*

FEATURES:

Expand Down
32 changes: 0 additions & 32 deletions opennebula/data_opennebula_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ func dataOpennebulaGroup() *schema.Resource {
Type: schema.TypeInt,
},
},
"quotas": func() *schema.Schema {
s := quotasSchema()
s.Deprecated = "use 'tags' for selection instead"
return s
}(),
"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -80,9 +75,6 @@ func groupFilter(d *schema.ResourceData, meta interface{}) (*groupSc.GroupShort,

func datasourceOpennebulaGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {

config := meta.(*Configuration)
controller := config.Controller

var diags diag.Diagnostics

group, err := groupFilter(d, meta)
Expand Down Expand Up @@ -150,29 +142,5 @@ func datasourceOpennebulaGroupRead(ctx context.Context, d *schema.ResourceData,
return diags
}

// TODO: Remove this part in release 0.6.0, this additional request is only
// here to retrieve the quotas information
groupInfo, err := controller.Group(group.ID).Info(false)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "group info error",
Detail: fmt.Sprintf("Group (ID: %d): %s", group.ID, err),
})
return diags
}

if _, ok := d.GetOk("quotas"); ok {
err = flattenQuotasMapFromStructs(d, &groupInfo.QuotasList)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "failed to flatten quotas",
Detail: fmt.Sprintf("Group (ID: %d): %s", group.ID, err),
})
return diags
}
}

return nil
}
15 changes: 0 additions & 15 deletions opennebula/data_opennebula_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,18 @@ func dataOpennebulaTemplate() *schema.Resource {
}
return s
}(),
"context": func() *schema.Schema {
s := contextSchema()
s.Deprecated = "use 'tags' for selection instead"
return s
}(),
"disk": func() *schema.Schema {
s := diskSchema()
s.Computed = true
s.Optional = false
return s
}(),
"graphics": func() *schema.Schema {
s := graphicsSchema()
s.Deprecated = "use 'tags' for selection instead"
return s
}(),
"nic": func() *schema.Schema {
s := nicSchema()
s.Computed = true
s.Optional = false
return s
}(),
"os": func() *schema.Schema {
s := osSchema()
s.Deprecated = "use 'tags' for selection instead"
return s
}(),
"vmgroup": func() *schema.Schema {
s := vmGroupSchema()
s.Computed = true
Expand Down
49 changes: 0 additions & 49 deletions opennebula/data_opennebula_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"strconv"
"strings"

userSc "github.com/OpenNebula/one/src/oca/go/src/goca/schemas/user"

Expand All @@ -22,22 +21,6 @@ func dataOpennebulaUser() *schema.Resource {
Optional: true,
Description: "Name of the User",
},
"auth_driver": {
Type: schema.TypeString,
Optional: true,
Default: "core",
Deprecated: "use 'tags' for selection instead",
Description: "Authentication driver. Select between: core, public, ssh, x509, ldap, server_cipher, server_x509 and custom. Defaults to 'core'.",
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)

if inArray(value, authTypes) < 0 {
errors = append(errors, fmt.Errorf("Auth driver %q must be one of: %s", k, strings.Join(locktypes, ",")))
}

return
},
},
"primary_group": {
Type: schema.TypeInt,
Optional: true,
Expand All @@ -51,11 +34,6 @@ func dataOpennebulaUser() *schema.Resource {
Type: schema.TypeInt,
},
},
"quotas": func() *schema.Schema {
s := quotasSchema()
s.Deprecated = "use 'tags' for selection instead"
return s
}(),
"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -125,9 +103,6 @@ userLoop:

func datasourceOpennebulaUserRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {

config := meta.(*Configuration)
controller := config.Controller

var diags diag.Diagnostics

user, err := userFilter(d, meta)
Expand Down Expand Up @@ -169,29 +144,5 @@ func datasourceOpennebulaUserRead(ctx context.Context, d *schema.ResourceData, m
}
}

// TODO: Remove this part in release 0.6.0, this additional request is only
// here to retrieve the quotas information
userInfo, err := controller.User(user.ID).Info(false)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "user info error",
Detail: fmt.Sprintf("User (ID: %d): %s", user.ID, err),
})
return diags
}

if _, ok := d.GetOk("quotas"); ok {
err = flattenQuotasMapFromStructs(d, &userInfo.QuotasList)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "failed to flatten quotas",
Detail: fmt.Sprintf("User (ID: %d): %s", user.ID, err),
})
return diags
}
}

return nil
}
6 changes: 0 additions & 6 deletions opennebula/data_opennebula_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ func dataOpennebulaVirtualNetwork() *schema.Resource {
Required: true,
Description: "Name of the Virtual Network",
},
"description": {
Type: schema.TypeString,
Optional: true,
Deprecated: "use 'tags' for selection instead",
Description: "Description of the vnet, in OpenNebula's XML or String format",
},
"mtu": {
Type: schema.TypeInt,
Computed: true,
Expand Down
72 changes: 9 additions & 63 deletions opennebula/resource_opennebula_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ func resourceOpennebulaGroup() *schema.Resource {
ForceNew: true,
Description: "Name of the Group",
},
"template": {
Type: schema.TypeString,
Optional: true,
Description: "Group template content, in OpenNebula XML or String format",
Deprecated: "use other schema sections",
ConflictsWith: []string{"sunstone", "tags"},
},
"delete_on_destruction": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Deprecated: "use Terraform lifcycle Meta-Argument instead.",
Description: "Flag to delete group on destruction, by default it is set to true",
},
"users": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -95,13 +81,8 @@ func resourceOpennebulaGroup() *schema.Resource {
},
},
},
ConflictsWith: []string{"template"},
},
"tags": func() *schema.Schema {
s := tagsSchema()
s.ConflictsWith = []string{"template"}
return s
}(),
"tags": tagsSchema(),
"default_tags": defaultTagsSchemaComputed(),
"tags_all": tagsSchemaComputed(),
},
Expand Down Expand Up @@ -209,20 +190,6 @@ func resourceOpennebulaGroupCreate(ctx context.Context, d *schema.ResourceData,

// template management

// add template description
if d.Get("template") != "" {
// Erase previous template
err = gc.Update(d.Get("template").(string), 0)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Failed to update the group content",
Detail: fmt.Sprintf("group (ID: %d): %s", groupID, err),
})
return diags
}
}

tpl := dyn.NewTemplate()

sunstone := d.Get("sunstone").(*schema.Set).List()
Expand Down Expand Up @@ -326,11 +293,6 @@ func resourceOpennebulaGroupRead(ctx context.Context, d *schema.ResourceData, me

d.SetId(strconv.FormatUint(uint64(group.ID), 10))
d.Set("name", group.Name)
d.Set("template", group.Template.String())
deleteOnDestruction, ok := d.Get("delete_on_destruction").(bool)
if ok {
d.Set("delete_on_destruction", deleteOnDestruction)
}

// read only configured users in current group resource
appliedUserIDs := make([]int, 0)
Expand Down Expand Up @@ -514,20 +476,6 @@ func resourceOpennebulaGroupUpdate(ctx context.Context, d *schema.ResourceData,
return diags
}

if d.HasChange("template") {
// Erase previous template
err = gc.Update(d.Get("template").(string), 0)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Failed to update group content",
Detail: fmt.Sprintf("group (ID: %s): %s", d.Id(), err),
})
return diags
}

}

update := false
newTpl := group.Template

Expand Down Expand Up @@ -679,16 +627,14 @@ func resourceOpennebulaGroupDelete(ctx context.Context, d *schema.ResourceData,
}
}

if d.Get("delete_on_destruction") == true {
err = gc.Delete()
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Failed to delete",
Detail: fmt.Sprintf("group (ID: %s): %s", d.Id(), err),
})
return diags
}
err = gc.Delete()
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Failed to delete",
Detail: fmt.Sprintf("group (ID: %s): %s", d.Id(), err),
})
return diags
}

return nil
Expand Down
Loading

0 comments on commit ae56cf2

Please sign in to comment.