Skip to content

Commit e5c2d5d

Browse files
authored
added spec (#27)
1 parent dcdf1ba commit e5c2d5d

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

port/cli/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type (
3939
Blueprint string `json:"blueprint,omitempty"`
4040
Pattern string `json:"pattern,omitempty"`
4141
Enum []string `json:"enum,omitempty"`
42+
Spec string `json:"spec,omitempty"`
4243
EnumColors map[string]string `json:"enumColors,omitempty"`
4344
}
4445

port/resource_port_blueprint.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ func newBlueprintResource() *schema.Resource {
133133
Optional: true,
134134
Description: "The format of the Property",
135135
},
136+
"spec": {
137+
Type: schema.TypeString,
138+
Optional: true,
139+
ValidateFunc: validation.StringInSlice([]string{"async-api", "open-api", "embedded-url"}, false),
140+
Description: "The specification of the property, one of \"async-api\", \"open-api\", \"embedded-url\"",
141+
},
136142
"enum": {
137143
Elem: &schema.Schema{
138144
Type: schema.TypeString,
@@ -331,6 +337,7 @@ func writeBlueprintFieldsToResource(d *schema.ResourceData, b *cli.Blueprint) {
331337
p["description"] = v.Description
332338
p["format"] = v.Format
333339
p["icon"] = v.Icon
340+
p["spec"] = v.Spec
334341
p["enum"] = v.Enum
335342
p["enum_colors"] = v.EnumColors
336343
if lo.Contains(b.Schema.Required, k) {
@@ -470,6 +477,11 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) {
470477
if i, ok := p["icon"]; ok && i != "" {
471478
propFields.Icon = i.(string)
472479
}
480+
481+
if s, ok := p["spec"]; ok && s != "" {
482+
propFields.Spec = s.(string)
483+
}
484+
473485
if r, ok := p["required"]; ok && r.(bool) {
474486
required = append(required, p["identifier"].(string))
475487
}

port/resource_port_blueprint_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,37 @@ func TestAccPortBlueprint(t *testing.T) {
8585
})
8686
}
8787

88+
func TestAccBlueprintWithSpecification(t *testing.T) {
89+
identifier := genID()
90+
var testAccActionConfigCreate = fmt.Sprintf(`
91+
resource "port-labs_blueprint" "microservice" {
92+
title = "TF Provider Test BP0"
93+
icon = "Terraform"
94+
identifier = "%s"
95+
properties {
96+
title = "text"
97+
identifier = "text"
98+
type = "string"
99+
format = "url"
100+
spec = "embedded-url"
101+
}
102+
}
103+
`, identifier)
104+
resource.Test(t, resource.TestCase{
105+
Providers: map[string]*schema.Provider{
106+
"port-labs": Provider(),
107+
},
108+
Steps: []resource.TestStep{
109+
{
110+
Config: testAccActionConfigCreate,
111+
Check: resource.ComposeTestCheckFunc(
112+
resource.TestCheckResourceAttr("port-labs_blueprint.microservice", "properties.0.spec", "embedded-url"),
113+
),
114+
},
115+
},
116+
})
117+
}
118+
88119
func TestAccBlueprintWithChangelogDestination(t *testing.T) {
89120
identifier := genID()
90121
var testAccActionConfigCreate = fmt.Sprintf(`

0 commit comments

Comments
 (0)