search

package
v2.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SearchDataSourceMarkdownDescription = `

# Search Data Source

The search data source allows you to search for entities in Port.

See the [Port documentation](https://docs.getport.io/search-and-query/) for more information about the search capabilities in Port.

## Example Usage

### Search for all entities in a specific blueprint:

` + "```hcl" + `

data "port_search" "all_service" {
  query = jsonencode({
    "combinator" : "and", "rules" : [
      { "operator" : "=", "property" : "$blueprint", "value" : "Service" },
    ]
  })
}

` + "\n```" + `

### Search for entity with specific identifier in a specific blueprint to create another resource based on the values of the entity:


` + "```hcl" + `

data "port_search" "ads_service" {
  query = jsonencode({
    "combinator" : "and", "rules" : [
      { "operator" : "=", "property" : "$blueprint", "value" : "Service" },
      { "operator" : "=", "property" : "$identifier", "value" : "Ads" },
    ]
  })
}

` + "\n```" + `

### Scorecards automation example
In this example we are creating a jira task for each service that its Ownership Scorecard hasn't reached Gold level : 

` + "```hcl" + `

data "port_search" "all_services" {
  query = jsonencode({
    "combinator" : "and", "rules" : [
      { "operator" : "=", "property" : "$blueprint", "value" : "microservice" },
    ]
  })
}

locals {
  // Count the number of services that are not owned by a team with a Gold level
  microservice_ownership_without_gold_level = length([
    for entity in data.port_search.all_services.entities : entity.scorecards["ownership"].level
    if entity.scorecards["ownership"].level != "Gold"
  ])
}

// create jira issue per service that is not owned by a team with a Gold level
resource "jira_issue" "microservice_ownership_without_gold_level" {
  count      = local.microservice_ownership_without_gold_level
  issue_type = "Task"

  project_key = "PORT"

  summary     = "Service ${data.port_search.backend_services.entities[count.index].title} hasn't reached Gold level in Ownership Scorecard"
  description = "[Service](https://app.getport.io/${port_blueprint.microservice.identifier}Entity/${data.port_search.backend_services.entities[count.index].identifier}) is not owned by a team with a Gold level, please assign a team with a Gold level to the service"
}

` + "\n```" + ``

Functions

func EntitySchema

func EntitySchema() map[string]schema.Attribute

func NewSearchDataSource

func NewSearchDataSource() datasource.DataSource

func Schema

func Schema() map[string]schema.Attribute

Types

type ArrayPropsModel

type ArrayPropsModel struct {
	StringItems  types.Map `tfsdk:"string_items"`
	NumberItems  types.Map `tfsdk:"number_items"`
	BooleanItems types.Map `tfsdk:"boolean_items"`
	ObjectItems  types.Map `tfsdk:"object_items"`
}

type EntityModel

type EntityModel struct {
	Identifier types.String               `tfsdk:"identifier"`
	Blueprint  types.String               `tfsdk:"blueprint"`
	Title      types.String               `tfsdk:"title"`
	Icon       types.String               `tfsdk:"icon"`
	RunID      types.String               `tfsdk:"run_id"`
	CreatedAt  types.String               `tfsdk:"created_at"`
	CreatedBy  types.String               `tfsdk:"created_by"`
	UpdatedAt  types.String               `tfsdk:"updated_at"`
	UpdatedBy  types.String               `tfsdk:"updated_by"`
	Properties *EntityPropertiesModel     `tfsdk:"properties"`
	Teams      []types.String             `tfsdk:"teams"`
	Scorecards *map[string]ScorecardModel `tfsdk:"scorecards"`
	Relations  *RelationModel             `tfsdk:"relations"`
}

type EntityPropertiesModel

type EntityPropertiesModel struct {
	StringProps  map[string]types.String  `tfsdk:"string_props"`
	NumberProps  map[string]types.Float64 `tfsdk:"number_props"`
	BooleanProps map[string]types.Bool    `tfsdk:"boolean_props"`
	ObjectProps  map[string]types.String  `tfsdk:"object_props"`
	ArrayProps   *ArrayPropsModel         `tfsdk:"array_props"`
}

type RelationModel

type RelationModel struct {
	SingleRelation map[string]*string  `tfsdk:"single_relations"`
	ManyRelations  map[string][]string `tfsdk:"many_relations"`
}

type ScorecardModel

type ScorecardModel struct {
	Rules []ScorecardRulesModel `tfsdk:"rules"`
	Level types.String          `tfsdk:"level"`
}

type ScorecardRulesModel

type ScorecardRulesModel struct {
	Identifier types.String `tfsdk:"identifier"`
	Status     types.String `tfsdk:"status"`
	Level      types.String `tfsdk:"level"`
}

type SearchDataModel

type SearchDataModel struct {
	ID                          types.String   `tfsdk:"id"`
	Query                       types.String   `tfsdk:"query"`
	ExcludeCalculatedProperties types.Bool     `tfsdk:"exclude_calculated_properties"`
	Include                     []types.String `tfsdk:"include"`
	Exclude                     []types.String `tfsdk:"exclude"`
	AttachTitleToRelation       types.Bool     `tfsdk:"attach_title_to_relation"`
	MatchingBlueprints          []types.String `tfsdk:"matching_blueprints"`
	Entities                    []EntityModel  `tfsdk:"entities"`
}

func (*SearchDataModel) GenerateID

func (m *SearchDataModel) GenerateID() string

type SearchDataSource

type SearchDataSource struct {
	// contains filtered or unexported fields
}

func (*SearchDataSource) Configure

func (*SearchDataSource) Metadata

func (*SearchDataSource) Read

func (*SearchDataSource) Schema

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL