Skip to content

Commit

Permalink
Merge branch 'main' into readme_update
Browse files Browse the repository at this point in the history
  • Loading branch information
rounak-adhikary authored Nov 21, 2024
2 parents 6ffaf11 + cd5bba7 commit 78b74a3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ generate:
cover:
rm -f coverage.*
go test -coverprofile=coverage.out ./...
go tool cover -html coverage.out -o coverage.html
go tool cover -html coverage.out -o coverage.html

sweep :
go test -v ./powerscale/provider -timeout 20m -sweep=all
2 changes: 1 addition & 1 deletion docs/data-sources/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ Read-Only:
- `shadow_bytes` (Number) The amount of shadow bytes referred to by this snapshot.
- `size` (Number) The amount of storage in bytes used to store this snapshot.
- `state` (String) Snapshot state.
- `target_id` (Number) The ID of the snapshot pointed to if this is an alias. 18446744073709551615 (max uint64) is returned for an alias to the live filesystem.
- `target_id` (Number) The ID of the snapshot pointed to if this is an alias. An alias to the live filesystem is represented by the value -1.
- `target_name` (String) The name of the snapshot pointed to if this is an alias.
3 changes: 2 additions & 1 deletion goClientZip/PowerScale_API_9.5.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -58825,7 +58825,8 @@
"description": "The ID of the snapshot pointed to if this is an alias. 18446744073709551615 (max uint64) is returned for an alias to the live filesystem.",
"maximum": 2147483646,
"minimum": 0,
"type": "integer"
"type": "integer",
"format": "unsigned64"
},
"target_name": {
"description": "The name of the snapshot pointed to if this is an alias.",
Expand Down
Binary file modified goClientZip/powerscale-go-client.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions powerscale/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ import (
powerscale "dell/powerscale-go-client"
"encoding/json"
"fmt"
"golang.org/x/net/html"
"math/big"
"net/http"
"reflect"
"strings"

"golang.org/x/net/html"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
)

// CopyFields copy the source of a struct to destination of struct with terraform types.
// Unsigned integers are not properly handled.
func CopyFields(ctx context.Context, source, destination interface{}) error {
tflog.Debug(ctx, "Copy fields", map[string]interface{}{
"source": source,
Expand Down Expand Up @@ -94,7 +96,7 @@ func CopyFields(ctx context.Context, source, destination interface{}) error {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
destinationFieldValue = types.Int64Value(sourceField.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
destinationFieldValue = types.Int64Value(sourceField.Int())
destinationFieldValue = types.Int64Value(int64(sourceField.Uint()))
case reflect.Float32, reflect.Float64:
// destinationFieldValue = types.Float64Value(sourceField.Float())
destinationFieldValue = types.NumberValue(big.NewFloat(sourceField.Float()))
Expand Down
8 changes: 8 additions & 0 deletions powerscale/helper/snapshot_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ func SnapshotDetailMapper(ctx context.Context, snap powerscale.V1SnapshotSnapsho
return model, err
}
model.ID = types.StringValue(fmt.Sprint(snap.Id))
// Max uint64 is returned when aliasing to live filesystem
// Other than that, valid targetIDs have a max value of max int64
// In Terraform, we shall represent by -1 live system alias by -1
if snap.TargetId == 18446744073709551615 {
model.TargetID = types.Int64Value(-1)
} else {
model.TargetID = types.Int64Value(int64(snap.TargetId))
}
model.TargetID = types.Int64Value(int64(snap.TargetId))
model.SetExpires = types.StringNull()
return model, nil
Expand Down
4 changes: 2 additions & 2 deletions powerscale/provider/snapshot_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func (d *SnapshotDataSource) Schema(ctx context.Context, req datasource.SchemaRe
Computed: true,
},
"target_id": schema.Int64Attribute{
Description: "The ID of the snapshot pointed to if this is an alias. 18446744073709551615 (max uint64) is returned for an alias to the live filesystem.",
MarkdownDescription: "The ID of the snapshot pointed to if this is an alias. 18446744073709551615 (max uint64) is returned for an alias to the live filesystem.",
Description: "The ID of the snapshot pointed to if this is an alias. An alias to the live filesystem is represented by the value -1.",
MarkdownDescription: "The ID of the snapshot pointed to if this is an alias. An alias to the live filesystem is represented by the value -1.",
Computed: true,
},
"target_name": schema.StringAttribute{
Expand Down

0 comments on commit 78b74a3

Please sign in to comment.