Skip to content

Commit

Permalink
Remove last_update fields
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Lo-A-Foe <[email protected]>
  • Loading branch information
loafoe committed Feb 11, 2021
1 parent 5d7a6a8 commit c7aec86
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## v0.12.2
- Fix STL cert update issue
- Remove last_update fields as it produced inconsistent state

## v0.12.1
- Improve Proposition and Application resource lifecycle and error handling
Expand Down
1 change: 0 additions & 1 deletion docs/resources/stl_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ resource "hsdp_stl_app" "myapp" {

## Attribute reference
* `id` - The resource ID
* `last_update` - RFC3339 timestamp of last update. Can be used to trigger `hsdp_stl_sync`

## Importing

Expand Down
3 changes: 0 additions & 3 deletions docs/resources/stl_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,3 @@ resource "hsdp_stl_config" "sme100" {
* `hsdp_ingestor_host` - (Optional) The HSDP logging endpoint
* `sync` (Optional, boolean) - When set to true syncs the config after mutations. Default is true.
Set this to false if you want to batch sync to your device using `hsdp_stl_sync`

## Attribute reference
* `last_update` - RFC3339 timestamp of last update. Can be used to trigger `hsdp_stl_sync`
1 change: 0 additions & 1 deletion docs/resources/stl_custom_cert.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ resource "hsdp_stl_custom_cert" "cert" {

## Attribute reference
* `id` - The id of the custom certificate
* `last_update` - RFC3339 timestamp of last update. Can be used to trigger `hsdp_stl_sync`

## Importing
Importing a custom certificate is supported but not recommended.
5 changes: 1 addition & 4 deletions docs/resources/stl_sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ per resource to batch syncs down to a single one as part of the `apply` stage.

## Argument reference
* `serial_number` - (Required) Serial number of the device to sync
* `triggers` - (Required, Hashmap) Create dependencies on other resources

## Argument reference
* `last_update` - The time the sync was performed by this resource
* `triggers` - (Required, Hashmap) Create dependencies on other resources
7 changes: 0 additions & 7 deletions hsdp/resource_stl_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ func resourceSTLApp() *schema.Resource {
Optional: true,
Default: true,
},
"last_update": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -77,7 +73,6 @@ func resourceSTLAppUpdate(ctx context.Context, d *schema.ResourceData, m interfa
if err != nil {
return diag.FromErr(fmt.Errorf("stl_app: update STL app: %w", err))
}
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
return diags
}
Expand All @@ -104,7 +99,6 @@ func resourceSTLAppDelete(ctx context.Context, d *schema.ResourceData, m interfa
if err != nil {
return diag.FromErr(fmt.Errorf("stl_app: delete STL resource: %w", err))
}
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
d.SetId("")
return diags
Expand Down Expand Up @@ -171,7 +165,6 @@ func resourceSTLAppCreate(ctx context.Context, d *schema.ResourceData, m interfa
return diag.FromErr(fmt.Errorf("stl_app: create STL app: %w", err))
}
d.SetId(fmt.Sprintf("%d", resource.ID))
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
return diags
}
6 changes: 0 additions & 6 deletions hsdp/resource_stl_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ func resourceSTLConfig() *schema.Resource {
Optional: true,
Default: true,
},
"last_update": {
Type: schema.TypeString,
Computed: true,
},
"firewall_exceptions": {
Type: schema.TypeSet,
MaxItems: 1,
Expand Down Expand Up @@ -129,7 +125,6 @@ func resourceSTLConfigDelete(ctx context.Context, d *schema.ResourceData, m inte
if err != nil {
return diag.FromErr(fmt.Errorf("hsdp_stl_config: UpdateAppFirewallExceptions: %w", err))
}
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
d.SetId("")
return diags
Expand Down Expand Up @@ -295,7 +290,6 @@ func resourceSTLConfigCreate(ctx context.Context, d *schema.ResourceData, m inte
if d.IsNewResource() {
d.SetId(loggingRef.SerialNumber)
}
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
return diags
}
9 changes: 1 addition & 8 deletions hsdp/resource_stl_custom_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ func resourceSTLCustomCert() *schema.Resource {
Optional: true,
Default: true,
},
"last_update": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand All @@ -69,7 +65,6 @@ func resourceSTLCustomCertDelete(ctx context.Context, d *schema.ResourceData, m
if err != nil {
return diag.FromErr(fmt.Errorf("stl_custom_cert delete: %w", err))
}
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
d.SetId("")
return diags
Expand Down Expand Up @@ -100,7 +95,6 @@ func resourceSTLCustomCertUpdate(ctx context.Context, d *schema.ResourceData, m
if err != nil {
return diag.FromErr(fmt.Errorf("stl_custom_cert update: %w", err))
}
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
return diags
}
Expand Down Expand Up @@ -157,7 +151,6 @@ func resourceSTLCustomCertCreate(ctx context.Context, d *schema.ResourceData, m
return diag.FromErr(err)
}
d.SetId(fmt.Sprintf("%d", created.ID))
setLastUpdate(d)
syncSTLIfNeeded(ctx, client, d, m)
return diags
}
Expand All @@ -168,7 +161,7 @@ func syncSTLIfNeeded(ctx context.Context, c *stl.Client, d *schema.ResourceData,
if !sync {
return
}
serialNumber := d.Get("name").(string)
serialNumber := d.Get("serial_number").(string)
_, _ = config.Debug("Syncing %s\n", serialNumber)
_ = c.Devices.SyncDeviceConfig(ctx, serialNumber)
return
Expand Down
7 changes: 1 addition & 6 deletions hsdp/resource_stl_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ func resourceSTLSync() *schema.Resource {
Required: true,
ForceNew: true,
},
"last_update": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

func resourceSTLSyncDelete(_ context.Context, d *schema.ResourceData, _m interface{}) diag.Diagnostics {
func resourceSTLSyncDelete(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
d.SetId("")
return diag.Diagnostics{}
}
Expand Down Expand Up @@ -63,7 +59,6 @@ func resourceSTLSyncCreate(ctx context.Context, d *schema.ResourceData, m interf
if err != nil {
return diag.FromErr(fmt.Errorf("hsdp_stl_sync: %w", err))
}
setLastUpdate(d)
d.SetId(serialNumber)
return diags
}
9 changes: 0 additions & 9 deletions hsdp/tools.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package hsdp

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"time"
)

// difference returns the elements in a that aren't in b
func difference(a, b []string) []string {
mb := map[string]bool{}
Expand All @@ -19,7 +14,3 @@ func difference(a, b []string) []string {
}
return ab
}

func setLastUpdate(d *schema.ResourceData) {
_ = d.Set("last_update", time.Now().Format(time.RFC3339))
}

0 comments on commit c7aec86

Please sign in to comment.