-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
16 changed files
with
1,327 additions
and
2 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
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,38 @@ | ||
TEST?=$$(go list ./... | grep -v 'vendor') | ||
HOSTNAME=trendmicro.com | ||
NAMESPACE=cloudone | ||
NAME=conformity | ||
BINARY=terraform-provider-${NAME} | ||
VERSION=0.3 | ||
OS_ARCH=darwin_amd64 | ||
|
||
default: install | ||
|
||
build: | ||
go build -o ${BINARY} | ||
|
||
release: | ||
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 | ||
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 | ||
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 | ||
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm | ||
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 | ||
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 | ||
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm | ||
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 | ||
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 | ||
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 | ||
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386 | ||
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 | ||
|
||
install: build | ||
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} | ||
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} | ||
sed -i -e '/hashes/,/]/d' examples/.terraform.lock.hcl | ||
|
||
test: | ||
go test -i $(TEST) || exit 1 | ||
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 | ||
|
||
testacc: | ||
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m |
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 |
---|---|---|
@@ -1,2 +1,21 @@ | ||
# conformity-tf-provider | ||
Terraform provider for conformity | ||
# Terraform Provider Hashicups | ||
|
||
Run the following command to build the provider | ||
|
||
```shell | ||
go build -o terraform-provider-hashicups | ||
``` | ||
|
||
## Test sample configuration | ||
|
||
First, build and install the provider. | ||
|
||
```shell | ||
make install | ||
``` | ||
|
||
Then, run the following command to initialize the workspace and apply the sample configuration. | ||
|
||
```shell | ||
terraform init && terraform apply | ||
``` |
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,101 @@ | ||
package groups | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"strconv" | ||
"terraform-provider-conformity/conformity/models" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func DataSourceGroups() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: dataSourceGroupsRead, | ||
Schema: map[string]*schema.Schema{ | ||
"groups": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"type": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"attributes_tags": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
"attributes_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"attributes_created_date": { | ||
Type: schema.TypeFloat, | ||
Computed: true, | ||
}, | ||
"attributes_last_modified_date": { | ||
Type: schema.TypeFloat, | ||
Computed: true, | ||
}, | ||
"relationships_organisation_data_type": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"relationships_organisation_data_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"relationships_accounts_data": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"type": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
log.Println("[DEBUG] Something happened twice!") | ||
provider := m.(models.ProviderClient) | ||
client := provider.Client | ||
var diags diag.Diagnostics | ||
gs := GetGroupService(client) | ||
groups, err := gs.DoGetGroups(client.BaseUrl.String()) | ||
log.Printf("Raw output2: %v\n", groups) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
if err := d.Set("groups", groups); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
// always run | ||
d.SetId(strconv.FormatInt(time.Now().Unix(), 10)) | ||
|
||
return diags | ||
} |
Oops, something went wrong.