Skip to content

Commit

Permalink
Add abridged sample (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
baoy1 authored Sep 19, 2023
1 parent aefe725 commit 7ca3a34
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 1 deletion.
74 changes: 74 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,81 @@ description: |-



## Example Usage
The following abridged example demonstrates the usage of the provider to create user, user group, filesystem and NFS export.

```terraform
/*
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.
*/
terraform {
required_providers {
powerscale = {
source = "registry.terraform.io/dell/powerscale"
}
}
}
provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}
resource "powerscale_user" "example_user" {
name = "example_user"
enabled = true
}
resource "powerscale_user_group" "example_user_group" {
name = "example_user_group"
users = [powerscale_user.example_user.name]
}
resource "powerscale_filesystem" "example_file_system" {
directory_path = "/ifs/data"
name = "example_file_system"
group = {
id = format("%s:%s", "GID", powerscale_user_group.example_user_group.gid)
name = powerscale_user_group.example_user_group.name
type = "group"
}
owner = {
id = format("%s:%s", "UID", powerscale_user.example_user.uid)
name = powerscale_user.example_user.name,
type = "user"
}
access_control = "public_read_write"
}
resource "powerscale_nfs_export" "example_export" {
paths = [powerscale_filesystem.example_file_system.full_path]
map_all = {
enabled = true,
primary_group = {
id = format("%s:%s", "GROUP", powerscale_user_group.example_user_group.gid)
}
user = {
id = format("%s:%s", "USER", powerscale_user.example_user.uid)
}
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
70 changes: 70 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
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.
*/

terraform {
required_providers {
powerscale = {
source = "registry.terraform.io/dell/powerscale"
}
}
}

provider "powerscale" {
username = var.username
password = var.password
endpoint = var.endpoint
insecure = var.insecure
}

resource "powerscale_user" "example_user" {
name = "example_user"
enabled = true
}

resource "powerscale_user_group" "example_user_group" {
name = "example_user_group"
users = [powerscale_user.example_user.name]
}

resource "powerscale_filesystem" "example_file_system" {
directory_path = "/ifs/data"
name = "example_file_system"
group = {
id = format("%s:%s", "GID", powerscale_user_group.example_user_group.gid)
name = powerscale_user_group.example_user_group.name
type = "group"
}
owner = {
id = format("%s:%s", "UID", powerscale_user.example_user.uid)
name = powerscale_user.example_user.name,
type = "user"
}
access_control = "public_read_write"
}

resource "powerscale_nfs_export" "example_export" {
paths = [powerscale_filesystem.example_file_system.full_path]
map_all = {
enabled = true,
primary_group = {
id = format("%s:%s", "GROUP", powerscale_user_group.example_user_group.gid)
}
user = {
id = format("%s:%s", "USER", powerscale_user.example_user.uid)
}
}
}
34 changes: 34 additions & 0 deletions examples/provider/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
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.
*/

variable "username" {
type = string
}

variable "password" {
type = string
}

variable "endpoint" {
type = string
}

variable "insecure" {
type = bool
}


2 changes: 1 addition & 1 deletion templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ description: |-

{{ if .HasExample -}}
## Example Usage
The following abridged example demonstrates the usage of the provider to create user, user group, filesystem and NFS export.

provider.tf
{{ tffile ( printf "%s" .ExampleFile) }}
{{- end }}

Expand Down

0 comments on commit 7ca3a34

Please sign in to comment.