Skip to content

Commit e3685a7

Browse files
Run acceptance tests only when 'acceptance' go:build tag is present (#21)
1 parent 6b74614 commit e3685a7

15 files changed

+156
-50
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ lint-fix: $(GOLANGCI_LINT)
5050

5151
.PHONY: test
5252
test:
53-
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
53+
go test ./... -v -tags=unit $(TESTARGS) -timeout 120m
54+
55+
.PHONY: acctest
56+
acctest:
57+
TF_ACC=1 go test ./... -v -tags=acceptance $(TESTARGS) -timeout 120m
5458

5559
.PHONY: plugin
5660
plugin:

docs/data-sources/type.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ description: |-
1010

1111
Type data source
1212

13+
Enables you to read any type of Cisco Observability Platform. Types are just schemas for the objects.
14+
Type name is the field required to get the type data source.
1315

16+
## Example usage
17+
18+
In this example we want to fetch a type called fmm:namespace.
19+
20+
```terraform
21+
data "observability_type" "ns" {
22+
type_name = "fmm:namespace"
23+
}
24+
```
1425

1526
<!-- schema generated by tfplugindocs -->
1627
## Schema

docs/index.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,50 @@ description: |-
66
77
---
88

9-
# observability Provider
9+
# Observability Provider
1010

11+
Terraform Observability provider enables users to provision objects as resources and read types as data sources
1112

13+
## Authentication
1214

15+
To start using the Observability Terraform Provider you need to authenticate with the Cisco Observability Platform.
1316

17+
You can do this by either using service-principal or oauth as an authentication method:
18+
19+
20+
```terraform
21+
terraform {
22+
required_providers {
23+
observability = {
24+
source = "registry.terraform.io/cisco-open/observability"
25+
}
26+
}
27+
}
28+
29+
provider "observability" {
30+
tenant = "<your cisco observability account>"
31+
auth_method = "service-principal"
32+
url = "https://<your environment/host>"
33+
secrets_file = "<path to your secrets file>"
34+
}
35+
36+
```
37+
38+
```terraform
39+
terraform {
40+
required_providers {
41+
observability = {
42+
source = "registry.terraform.io/cisco-open/observability"
43+
}
44+
}
45+
}
46+
47+
provider "observability" {
48+
tenant = "<your cisco observability account>"
49+
auth_method = "oauth"
50+
url = "https://<your environment/host>"
51+
}
52+
```
1453

1554
<!-- schema generated by tfplugindocs -->
1655
## Schema

docs/resources/object.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,26 @@ description: |-
1010

1111
Object resource
1212

13-
13+
Enables you to create and manage any object of Cisco Observability Platform. Objects are actual populated values of a type. Data is a field which acts like a container for any object payload.
14+
15+
## Example usage
16+
17+
```terraform
18+
resource "observability_object" "conn" {
19+
type_name = "<your type>"
20+
object_id = "<object id of the object>"
21+
layer_type = "TENANT"
22+
layer_id = "<your tenant>"
23+
import_id = "<object type>|<object id>|TENANT|<your tenant>"
24+
data = jsonencode(
25+
{
26+
"field1" : "value1",
27+
"field2" : "value2",
28+
...
29+
}
30+
)
31+
}
32+
```
1433

1534
<!-- schema generated by tfplugindocs -->
1635
## Schema

internal/api/login_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// SPDX-License-Identifier: MPL-2.0
66

7+
//go:build unit
8+
79
package api_test
810

911
import (

internal/api/objectapi_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// SPDX-License-Identifier: MPL-2.0
66

7+
//go:build unit
8+
79
package api_test
810

911
import (

internal/api/pkce_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// SPDX-License-Identifier: MPL-2.0
66

7+
//go:build unit
8+
79
package api_test
810

911
import (

internal/api/typeapi_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// SPDX-License-Identifier: MPL-2.0
66

7+
//go:build unit
8+
79
package api_test
810

911
import (

internal/provider/type_data_source.go renamed to internal/provider/datasource_knowledge_type.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@ import (
1616
)
1717

1818
// Ensure provider defined types fully satisfy framework interfaces.
19-
var _ datasource.DataSource = &TypeDataSource{}
19+
var _ datasource.DataSource = &KnowledgeTypeDataSource{}
2020

21-
func NewTypeDataSource() datasource.DataSource {
22-
return &TypeDataSource{}
21+
func NewKnowledgeTypeDataSource() datasource.DataSource {
22+
return &KnowledgeTypeDataSource{}
2323
}
2424

25-
// TypeDataSource defines the data source implementation.
26-
type TypeDataSource struct {
25+
// KnowledgeTypeDataSource defines the data source implementation.
26+
type KnowledgeTypeDataSource struct {
2727
client *api.AppdClient
2828
}
2929

30-
// TypeDataSourceModel describes the data source data model.
31-
type TypeDataSourceModel struct {
30+
// KnowledgeTypeDataSourceModel describes the data source data model.
31+
type KnowledgeTypeDataSourceModel struct {
3232
Typename types.String `tfsdk:"type_name"`
3333
Data types.Dynamic `tfsdk:"data"`
3434
ID types.String `tfsdk:"id"`
3535
}
3636

37-
func (d *TypeDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
37+
func (d *KnowledgeTypeDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
3838
resp.TypeName = req.ProviderTypeName + "_type"
3939
}
4040

4141
// Schema defines the schema for the data source.
42-
func (d *TypeDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
42+
func (d *KnowledgeTypeDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
4343
resp.Schema = schema.Schema{
4444
// This description is used by the documentation generator and the language server.
4545
MarkdownDescription: "Type data source",
@@ -61,7 +61,7 @@ func (d *TypeDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, r
6161
}
6262
}
6363

64-
func (d *TypeDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
64+
func (d *KnowledgeTypeDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
6565
// Prevent panic if the provider has not been configured.
6666
if req.ProviderData == nil {
6767
return
@@ -80,8 +80,8 @@ func (d *TypeDataSource) Configure(_ context.Context, req datasource.ConfigureRe
8080
}
8181

8282
//nolint:gocritic // Terraform framework requires the method signature to be as is
83-
func (d *TypeDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
84-
var data TypeDataSourceModel
83+
func (d *KnowledgeTypeDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
84+
var data KnowledgeTypeDataSourceModel
8585

8686
// Read Terraform configuration data into the model
8787
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)

internal/provider/type_data_source_test.go renamed to internal/provider/datasource_knowledge_type_acc_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
// SPDX-License-Identifier: MPL-2.0
66

7+
//go:build acceptance
8+
79
package provider
810

911
import (
@@ -13,7 +15,7 @@ import (
1315
)
1416

1517
//lint:ignore U1000 Ignore unused function temporarily for debugging
16-
func _TestAccTypeDataSource(t *testing.T) {
18+
func TestAccKnowledgeTypeDataSource(t *testing.T) {
1719
resource.Test(t, resource.TestCase{
1820
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
1921
Steps: []resource.TestStep{

0 commit comments

Comments
 (0)