-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa13e7c
commit 8e6e5a3
Showing
12 changed files
with
217 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "bitwarden_folder Data Source - terraform-provider-bitwarden" | ||
subcategory: "" | ||
description: |- | ||
Use this data source to get information on an existing Folder. | ||
--- | ||
|
||
# bitwarden_folder (Data Source) | ||
|
||
Use this data source to get information on an existing Folder. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `filter_collection_id` (String) Filter search results by collection ID | ||
- `filter_organization_id` (String) Filter search results by organization ID | ||
- `id` (String) Identifier. | ||
- `search` (String) Search items matching the search string. Can be combined with filters to narrow down the search. | ||
|
||
### Read-Only | ||
|
||
- `name` (String) Name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package provider | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceFolder() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Use this data source to get information on an existing Folder.", | ||
ReadContext: readDataSourceFolder(), | ||
Schema: folderSchema(DataSource), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceFolderAttributes(t *testing.T) { | ||
ensureVaultwardenConfigured(t) | ||
|
||
resourceName := "bitwarden_folder.foo" | ||
|
||
resource.UnitTest(t, resource.TestCase{ | ||
ProviderFactories: providerFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: tfConfigProvider() + tfConfigResourceFolder(), | ||
}, | ||
{ | ||
Config: tfConfigProvider() + tfConfigResourceFolder() + tfConfigDataFolder(), | ||
Check: checkObject(resourceName), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func tfConfigDataFolder() string { | ||
return ` | ||
data "bitwarden_folder" "foo_data" { | ||
provider = bitwarden | ||
search = "folder-bar" | ||
} | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package provider | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func folderSchema(schemaType schemaTypeEnum) map[string]*schema.Schema { | ||
base := map[string]*schema.Schema{ | ||
attributeID: { | ||
Description: descriptionIdentifier, | ||
Type: schema.TypeString, | ||
Computed: schemaType == Resource, | ||
Optional: true, | ||
}, | ||
attributeName: { | ||
Description: descriptionName, | ||
Type: schema.TypeString, | ||
Computed: schemaType == DataSource, | ||
Required: schemaType == Resource, | ||
}, | ||
attributeObject: { | ||
Description: descriptionInternal, | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
} | ||
|
||
if schemaType == DataSource { | ||
base[attributeFilterCollectionId] = &schema.Schema{ | ||
Description: descriptionFilterCollectionID, | ||
Type: schema.TypeString, | ||
Optional: true, | ||
} | ||
|
||
base[attributeFilterOrganizationID] = &schema.Schema{ | ||
Description: descriptionFilterOrganizationID, | ||
Type: schema.TypeString, | ||
Optional: true, | ||
} | ||
|
||
base[attributeFilterSearch] = &schema.Schema{ | ||
Description: descriptionFilterSearch, | ||
Type: schema.TypeString, | ||
Optional: true, | ||
AtLeastOneOf: []string{attributeFilterSearch, attributeID}, | ||
} | ||
} | ||
|
||
return base | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package provider | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
) | ||
|
||
func loginSchema(schemaType schemaTypeEnum) map[string]*schema.Schema { | ||
base := map[string]*schema.Schema{ | ||
attributeLoginPassword: { | ||
Description: descriptionLoginPassword, | ||
Type: schema.TypeString, | ||
Computed: schemaType == DataSource, | ||
Optional: schemaType == Resource, | ||
Sensitive: true, | ||
}, | ||
attributeLoginUsername: { | ||
Description: descriptionLoginUsername, | ||
Type: schema.TypeString, | ||
Computed: schemaType == DataSource, | ||
Optional: schemaType == Resource, | ||
Sensitive: true, | ||
}, | ||
attributeLoginTotp: { | ||
Description: descriptionLoginTotp, | ||
Type: schema.TypeString, | ||
Computed: schemaType == DataSource, | ||
Optional: schemaType == Resource, | ||
Sensitive: true, | ||
}, | ||
attributeLoginURIs: { | ||
Description: descriptionLoginUri, | ||
Type: schema.TypeList, | ||
Elem: uriElem(), | ||
Computed: schemaType == DataSource, | ||
Optional: schemaType == Resource, | ||
Sensitive: false, | ||
}, | ||
} | ||
|
||
if schemaType == DataSource { | ||
base[attributeFilterURL] = &schema.Schema{ | ||
Description: descriptionFilterURL, | ||
Type: schema.TypeString, | ||
Optional: true, | ||
} | ||
} | ||
return base | ||
} | ||
|
||
func uriElem() *schema.Resource { | ||
validMatchStr := []string{"default", "base_domain", "host", "start_with", "exact", "regexp", "never"} | ||
|
||
return &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
attributeLoginURIsMatch: { | ||
Description: descriptionLoginUriMatch, | ||
Type: schema.TypeString, | ||
Default: validMatchStr[0], | ||
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(validMatchStr, false)), | ||
Optional: true, | ||
}, | ||
attributeLoginURIsValue: { | ||
Description: descriptionLoginUriValue, | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
}, | ||
} | ||
} |