Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ website/node_modules
.idea
*.iml
*.test
*.env

website/vendor
vendor/
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ linters:
enable:
- durationcheck
- errcheck
- exportloopref
- copyloopvar
- godot
- gofmt
- gosimple
Expand All @@ -23,4 +23,4 @@ linters:
- unconvert
- unparam
- unused
- vet
- govet
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Changelog for the Cortex terraform provider.

## Unreleased

## 0.4.0
* Deprecate `x-cortex-parents` and use `x-cortex-parents` instead
- Bump Go version 1.20 -> 1.22

## 0.3.1
* Fix serialization for `git` / `sonarqube` / `codecov`
* Make owner type case insensitive
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ HOSTNAME=github.com
NAMESPACE=cortexapps
NAME=cortex
BINARY=terraform-provider-${NAME}
VERSION=0.3.2-dev
VERSION=0.4.1-dev

GOOS?=$(shell go env | grep GOOS | cut -d '=' -f2 | tr -d "'")
GOARCH?=$(shell go env | grep GOARCH | cut -d '=' -f2 | tr -d "'")
Expand Down Expand Up @@ -35,6 +35,9 @@ lint:
docs:
go generate ./...

format:
go fmt ./...

# unit tests
test:
go clean -testcache
Expand Down
18 changes: 9 additions & 9 deletions docs/resources/catalog_entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Catalog Entity
- `definition` (String) Set when the entity is a Resource. These are the properties defined by the Resource Definition, in JSON format in a string (use the `jsonencode` function to convert a JSON object to a string).
- `dependencies` (Attributes List) List of dependencies for the entity. (see [below for nested schema](#nestedatt--dependencies))
- `description` (String) Description of the entity visible in the Service or Resource Catalog. Markdown is supported.
- `domain_parents` (Attributes List) List of parent domains for the entity. The list of parents can only be entities of type `DOMAIN`. (see [below for nested schema](#nestedatt--domain_parents))
- `firehydrant` (Attributes) FireHydrant configuration for the entity. (see [below for nested schema](#nestedatt--firehydrant))
- `git` (Attributes) Git configuration for the entity. (see [below for nested schema](#nestedatt--git))
- `groups` (List of String) List of groups related to the entity.
Expand All @@ -46,6 +45,7 @@ Catalog Entity
- `microsoft_teams` (Attributes List) List of Microsoft Teams channels for the entity. (see [below for nested schema](#nestedatt--microsoft_teams))
- `on_call` (Attributes) On-call configuration for the entity. (see [below for nested schema](#nestedatt--on_call))
- `owners` (Attributes List) List of owners for the entity. Owners can be users, groups, or Slack channels. (see [below for nested schema](#nestedatt--owners))
- `parents` (Attributes List) List of parents for the entity. The list of parents can only be entities of type `DOMAIN`. (see [below for nested schema](#nestedatt--parents))
- `rollbar` (Attributes) Rollbar configuration for the entity. (see [below for nested schema](#nestedatt--rollbar))
- `sentry` (Attributes) Sentry configuration for the entity. (see [below for nested schema](#nestedatt--sentry))
- `service_now` (Attributes) ServiceNow configuration for the entity. (see [below for nested schema](#nestedatt--service_now))
Expand Down Expand Up @@ -228,14 +228,6 @@ Optional:
- `path` (String) The actual endpoint this dependency refers to.


<a id="nestedatt--domain_parents"></a>
### Nested Schema for `domain_parents`

Required:

- `tag` (String) Tag of the parent domain.


<a id="nestedatt--firehydrant"></a>
### Nested Schema for `firehydrant`

Expand Down Expand Up @@ -504,6 +496,14 @@ Optional:
- `provider` (String) Provider of the owner. Only allowed if `type` is `group`.


<a id="nestedatt--parents"></a>
### Nested Schema for `parents`

Required:

- `tag` (String) Tag of the parent domain.


<a id="nestedatt--rollbar"></a>
### Nested Schema for `rollbar`

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cortexapps/terraform-provider-cortex

go 1.20
go 1.22

require (
github.com/dghubble/sling v1.4.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQH
github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o=
github.com/hashicorp/terraform-plugin-docs v0.16.0 h1:UmxFr3AScl6Wged84jndJIfFccGyBZn52KtMNsS12dI=
github.com/hashicorp/terraform-plugin-docs v0.16.0/go.mod h1:M3ZrlKBJAbPMtNOPwHicGi1c+hZUh7/g0ifT/z7TVfA=
github.com/hashicorp/terraform-plugin-framework v1.4.0 h1:WKbtCRtNrjsh10eA7NZvC/Qyr7zp77j+D21aDO5th9c=
github.com/hashicorp/terraform-plugin-framework v1.4.0/go.mod h1:XC0hPcQbBvlbxwmjxuV/8sn8SbZRg4XwGMs22f+kqV0=
github.com/hashicorp/terraform-plugin-framework v1.4.1 h1:ZC29MoB3Nbov6axHdgPbMz7799pT5H8kIrM8YAsaVrs=
github.com/hashicorp/terraform-plugin-framework v1.4.1/go.mod h1:XC0hPcQbBvlbxwmjxuV/8sn8SbZRg4XwGMs22f+kqV0=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc=
Expand Down
10 changes: 5 additions & 5 deletions internal/cortex/catalog_entity_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func (c *CatalogEntityParser) YamlToEntity(yamlEntity map[string]interface{}) (C
c.interpolateChildren(&entity, info["x-cortex-children"].([]interface{}))
}

entity.DomainParents = []CatalogEntityDomainParent{}
if info["x-cortex-domain-parents"] != nil {
c.interpolateDomainParents(&entity, info["x-cortex-domain-parents"].([]interface{}))
entity.Parents = []CatalogEntityParent{}
if info["x-cortex-parents"] != nil {
c.interpolateParents(&entity, info["x-cortex-parents"].([]interface{}))
}

entity.Metadata = map[string]interface{}{}
Expand Down Expand Up @@ -196,10 +196,10 @@ func (c *CatalogEntityParser) interpolateChildren(entity *CatalogEntityData, chi
}
}

func (c *CatalogEntityParser) interpolateDomainParents(entity *CatalogEntityData, parents []interface{}) {
func (c *CatalogEntityParser) interpolateParents(entity *CatalogEntityData, parents []interface{}) {
for _, parent := range parents {
parentMap := parent.(map[string]interface{})
entity.DomainParents = append(entity.DomainParents, CatalogEntityDomainParent{
entity.Parents = append(entity.Parents, CatalogEntityParent{
Tag: MapFetchToString(parentMap, "tag"),
})
}
Expand Down
28 changes: 14 additions & 14 deletions internal/cortex/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ package cortex
// match the structure of the CatalogEntity struct in other responses.
// See: https://github.com/cortexapps/solutions/blob/master/examples/yaml/catalog/resource.yaml
type CatalogEntityData struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Tag string `json:"x-cortex-tag" yaml:"x-cortex-tag"`
Type string `json:"x-cortex-type,omitempty" yaml:"x-cortex-type,omitempty"`
Definition map[string]interface{} `json:"x-cortex-definition,omitempty" yaml:"x-cortex-definition,omitempty"`
Owners []CatalogEntityOwner `json:"x-cortex-owners,omitempty" yaml:"x-cortex-owners,omitempty"`
Children []CatalogEntityChild `json:"x-cortex-children,omitempty" yaml:"x-cortex-children,omitempty"`
DomainParents []CatalogEntityDomainParent `json:"x-cortex-domain-parents,omitempty" yaml:"x-cortex-domain-parents,omitempty"`
Groups []string `json:"x-cortex-groups,omitempty" yaml:"x-cortex-groups,omitempty"` // TODO: is this -groups or -service-groups? docs unclear
Links []CatalogEntityLink `json:"x-cortex-link,omitempty" yaml:"x-cortex-link,omitempty"`
IgnoreMetadata bool `json:"-" yaml:"-"`
Metadata map[string]interface{} `json:"x-cortex-custom-metadata,omitempty" yaml:"x-cortex-custom-metadata,omitempty"`
Dependencies []CatalogEntityDependency `json:"x-cortex-dependency,omitempty" yaml:"x-cortex-dependency,omitempty"`
Title string `json:"title" yaml:"title"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Tag string `json:"x-cortex-tag" yaml:"x-cortex-tag"`
Type string `json:"x-cortex-type,omitempty" yaml:"x-cortex-type,omitempty"`
Definition map[string]interface{} `json:"x-cortex-definition,omitempty" yaml:"x-cortex-definition,omitempty"`
Owners []CatalogEntityOwner `json:"x-cortex-owners,omitempty" yaml:"x-cortex-owners,omitempty"`
Children []CatalogEntityChild `json:"x-cortex-children,omitempty" yaml:"x-cortex-children,omitempty"`
Parents []CatalogEntityParent `json:"x-cortex-parents,omitempty" yaml:"x-cortex-parents,omitempty"`
Groups []string `json:"x-cortex-groups,omitempty" yaml:"x-cortex-groups,omitempty"` // TODO: is this -groups or -service-groups? docs unclear
Links []CatalogEntityLink `json:"x-cortex-link,omitempty" yaml:"x-cortex-link,omitempty"`
IgnoreMetadata bool `json:"-" yaml:"-"`
Metadata map[string]interface{} `json:"x-cortex-custom-metadata,omitempty" yaml:"x-cortex-custom-metadata,omitempty"`
Dependencies []CatalogEntityDependency `json:"x-cortex-dependency,omitempty" yaml:"x-cortex-dependency,omitempty"`

// Various generic integration attributes
Alerts []CatalogEntityAlert `json:"x-cortex-alerts,omitempty" yaml:"x-cortex-alerts,omitempty"`
Expand Down Expand Up @@ -184,7 +184,7 @@ type CatalogEntityChild struct {
Tag string `json:"tag" yaml:"tag"`
}

type CatalogEntityDomainParent struct {
type CatalogEntityParent struct {
Tag string `json:"tag" yaml:"tag"`
}

Expand Down
4 changes: 2 additions & 2 deletions internal/provider/catalog_entity_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ func (r *CatalogEntityResource) Schema(ctx context.Context, req resource.SchemaR
},
},
},
"domain_parents": schema.ListNestedAttribute{
MarkdownDescription: "List of parent domains for the entity. The list of parents can only be entities of type `DOMAIN`.",
"parents": schema.ListNestedAttribute{
MarkdownDescription: "List of parents for the entity. The list of parents can only be entities of type `DOMAIN`.",
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/catalog_entity_resource_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestAccCatalogEntityDomainWithParent(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "description", description),
resource.TestCheckResourceAttr(resourceName, "type", "domain"),
resource.TestCheckResourceAttr(resourceName, "domain_parents.0.tag", "manual-test-domain"),
resource.TestCheckResourceAttr(resourceName, "parents.0.tag", "manual-test-domain"),
),
},
// ImportState testing
Expand All @@ -148,7 +148,7 @@ func TestAccCatalogEntityDomainWithParent(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "description", description+" 2"),
resource.TestCheckResourceAttr(resourceName, "type", "domain"),
resource.TestCheckResourceAttr(resourceName, "domain_parents.0.tag", "manual-test-domain"),
resource.TestCheckResourceAttr(resourceName, "parents.0.tag", "manual-test-domain"),
),
},
// Delete testing automatically occurs in TestCase
Expand All @@ -163,7 +163,7 @@ resource "cortex_catalog_entity" %[1]q {
name = %[2]q
description = %[3]q
type = "domain"
domain_parents = [
parents = [
{
tag = "manual-test-domain"
}
Expand Down
Loading