Skip to content

Commit

Permalink
Remove GoPowerScale
Browse files Browse the repository at this point in the history
  • Loading branch information
doriac11 committed Aug 3, 2023
1 parent b4bdf08 commit 8585916
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 192 deletions.
33 changes: 4 additions & 29 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,61 +29,36 @@ import (
"net/http/cookiejar"
"time"

"github.com/dell/goisilon"
"github.com/hashicorp/terraform-plugin-log/tflog"
)

// Client type is to hold powerscale client.
type Client struct {
PscaleOpenAPIClient *powerscale.APIClient
PscaleClient *goisilon.Client
}

// NewClient returns the gopowerscale client.
// NewClient returns the client.
func NewClient(endpoint string,
insecure bool, verboseLogging uint,
user, group, pass, volumePath string, volumePathPermissions string, ignoreUnresolvableHosts bool, authType uint8) (*Client, error) {
pscaleClient, err := goisilon.NewClientWithArgs(
context.Background(),
endpoint,
insecure,
verboseLogging,
user,
group,
pass,
volumePath,
volumePathPermissions,
ignoreUnresolvableHosts,
authType,
)
if err != nil {
return nil, err
}
insecure bool,
user string, pass string) (*Client, error) {
openAPIClient, err := NewOpenAPIClient(
context.Background(),
endpoint,
insecure,
verboseLogging,
user,
group,
pass,
volumePath,
volumePathPermissions,
ignoreUnresolvableHosts,
authType,
)
if err != nil {
return nil, err
}
client := Client{
PscaleClient: pscaleClient,
PscaleOpenAPIClient: openAPIClient,
}
return &client, nil
}

// NewOpenAPIClient returns the OpenApi Client.
func NewOpenAPIClient(ctx context.Context, endpoint string, insecure bool, verboseLogging uint, user, group, pass, volumePath string, volumePathPermissions string, ignoreUnresolvableHosts bool, authType uint8) (*powerscale.APIClient, error) {
func NewOpenAPIClient(ctx context.Context, endpoint string, insecure bool, user string, pass string) (*powerscale.APIClient, error) {
// Setup a User-Agent for your API client (replace the provider name for yours):
userAgent := "terraform-powermax-provider/1.0.0"
jar, err := cookiejar.New(nil)
Expand Down
11 changes: 1 addition & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@ description: |-

### Required

- `auth_type` (Number) what should be the auth type, 0 for basic and 1 for session-based
- `endpoint` (String) The API endpoint, ex. https://172.17.177.230:8080
- `insecure` (Boolean) whether to skip SSL validation
- `password` (String, Sensitive) The password
- `username` (String) The username

### Optional

- `group` (String) The user's group
- `ignore_unresolvable_hosts` (Boolean) whether to ignore unresolvable hosts
- `verbose_logging` (Number) what verbose level should be used for logging, high(0), medium(1) or low(2)
- `volume_path` (String) which base path to use when looking for volume directories
- `volume_path_permissions` (String) permissions for new volume directory
- `username` (String) The username
14 changes: 4 additions & 10 deletions examples/data-sources/powerscale_access_zone/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ terraform {
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
group = var.group
volume_path = var.volume_path
volume_path_permissions = var.volume_path_permissions
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts
auth_type = var.auth_type
verbose_logging = var.verbose_logging
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
14 changes: 4 additions & 10 deletions examples/data-sources/powerscale_file_system/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ terraform {
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
group = var.group
volumes_path = var.volumes_path
volumes_path_permissions = var.volumes_path_permissions
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts
auth_type = var.auth_type
verbose_logging = var.verbose_logging
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
14 changes: 4 additions & 10 deletions examples/data-sources/powerscale_smb_share/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ terraform {
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
group = var.group
volume_path = var.volume_path
volume_path_permissions = var.volume_path_permissions
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts
auth_type = var.auth_type
verbose_logging = var.verbose_logging
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
14 changes: 4 additions & 10 deletions examples/data-sources/powerscale_user/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ terraform {
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
group = var.group
volume_path = var.volume_path
volume_path_permissions = var.volume_path_permissions
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts
auth_type = var.auth_type
verbose_logging = var.verbose_logging
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
14 changes: 4 additions & 10 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,8 @@ variable "verbose_logging" {
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
group = var.group
volume_path = var.volume_path
volume_path_permissions = var.volume_path_permissions
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts
auth_type = var.auth_type
verbose_logging = var.verbose_logging
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
14 changes: 4 additions & 10 deletions examples/resources/powerscale_smb_share/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ terraform {
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
group = var.group
volume_path = var.volume_path
volume_path_permissions = var.volume_path_permissions
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts
auth_type = var.auth_type
verbose_logging = var.verbose_logging
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
20 changes: 20 additions & 0 deletions examples/resources/powescale_access_zone/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

# Licensed under the Mozilla Public License Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://mozilla.org/MPL/2.0/


# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# The command is
# terraform import powerscale_accesszone.zone <id>
# Example:
terraform import powerscale_accesszone.zone access_zone
# after running this command, populate the name field in the config file to start managing this resource
14 changes: 4 additions & 10 deletions examples/resources/powescale_access_zone/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ terraform {
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
group = var.group
volume_path = var.volumes_path
volume_path_permissions = var.volumes_path_permissions
ignore_unresolvable_hosts = var.ignore_unresolvable_hosts
auth_type = var.auth_type
verbose_logging = var.verbose_logging
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
6 changes: 3 additions & 3 deletions powerscale/helper/resource_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

// CopyFieldsToNonNestedModel copy OpenAPI struct source to destination of struct with terraform types.
// use this function when model struct contains only types.List/Object
// use this function when model struct contains only types.List/Object.
func CopyFieldsToNonNestedModel(ctx context.Context, source, destination interface{}) error {
tflog.Debug(ctx, "Copy fields", map[string]interface{}{
"source": source,
Expand Down Expand Up @@ -305,7 +305,7 @@ func getSliceAttrValue(ctx context.Context, sliceObject interface{}) (attr.Value
}
}

// ReadFromState read from model to openapi struct, model should not contain nested struct
// ReadFromState read from model to openapi struct, model should not contain nested struct.
func ReadFromState(ctx context.Context, source, destination interface{}) error {
sourceValue := reflect.ValueOf(source)
destinationValue := reflect.ValueOf(destination)
Expand Down Expand Up @@ -533,7 +533,7 @@ func assignListToField(ctx context.Context, source basetypes.ListValue, destinat
return nil
}

// getFieldByJSONTag get field by tag, input destination is pointer
// getFieldByJSONTag get field by tag, input destination is pointer.
func getFieldByJSONTag(destination interface{}, tag string) (reflect.Value, error) {
destElemVal := reflect.ValueOf(destination).Elem()
destElemType := destElemVal.Type()
Expand Down
8 changes: 4 additions & 4 deletions powerscale/helper/smb_share_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ import (
"terraform-provider-powerscale/client"
)

// DeleteSmbShare delete smb share
// DeleteSmbShare delete smb share.
func DeleteSmbShare(ctx context.Context, client *client.Client, shareID string) error {
_, err := client.PscaleOpenAPIClient.ProtocolsApi.DeleteProtocolsv7SmbShare(ctx, shareID).Execute()
return err
}

// CreateSmbShare create smb share
// CreateSmbShare create smb share.
func CreateSmbShare(ctx context.Context, client *client.Client, share powerscale.V7SmbShare) (*powerscale.Createv12SmbShareResponse, error) {
shareID, _, err := client.PscaleOpenAPIClient.ProtocolsApi.CreateProtocolsv7SmbShare(ctx).V7SmbShare(share).Execute()
return shareID, err
}

// GetSmbShare get smb share
// GetSmbShare get smb share.
func GetSmbShare(ctx context.Context, client *client.Client, shareID string) (*powerscale.V7SmbSharesExtended, error) {
response, _, err := client.PscaleOpenAPIClient.ProtocolsApi.GetProtocolsv7SmbShare(ctx, shareID).Execute()
return response, err
}

// UpdateSmbShare update smb share
// UpdateSmbShare update smb share.
func UpdateSmbShare(ctx context.Context, client *client.Client, shareID string, shareToUpdate powerscale.V7SmbShareExtendedExtended) error {
updateParam := client.PscaleOpenAPIClient.ProtocolsApi.UpdateProtocolsv7SmbShare(ctx, shareID)
_, err := updateParam.V7SmbShare(shareToUpdate).Execute()
Expand Down
4 changes: 2 additions & 2 deletions powerscale/models/smb_share.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type SmbShareDatasource struct {
SmbSharesFilter *SmbShareDatasourceFilter `tfsdk:"filter"`
}

// SmbShareDatasourceFilter holds filter conditions
// SmbShareDatasourceFilter holds filter conditions.
type SmbShareDatasourceFilter struct {
// supported by api
Sort types.String `tfsdk:"sort"`
Expand All @@ -141,7 +141,7 @@ type SmbShareDatasourceFilter struct {
Names []types.String `tfsdk:"names"`
}

// SmbShareDatasourceEntity struct for SmbShareDatasource
// SmbShareDatasourceEntity struct for SmbShareDatasource.
type SmbShareDatasourceEntity struct {
// Only enumerate files and folders the requesting user has access to.
AccessBasedEnumeration types.Bool `tfsdk:"access_based_enumeration"`
Expand Down
8 changes: 1 addition & 7 deletions powerscale/provider/powerscale.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ TF_ACC=1
POWERSCALE_ENDPOINT=https://<ip>:8080
POWERSCALE_USERNAME=
POWERSCALE_PASSWORD=
POWERSCALE_INSECURE=
POWERSCALE_GROUP=
POWERSCALE_VOLUME_PATH=
POWERSCALE_VOLUME_PATH_PERMISSIONS=
POWERSCALE_IGNORE_UNRESOLVABLE_HOSTS=
POWERSCALE_AUTH_TYPE=
POWERSCALE_VERBOSE_LOGGING=
POWERSCALE_INSECURE=
Loading

0 comments on commit 8585916

Please sign in to comment.