-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using https://github.com/dikhan/terraform-provider-openapi, building a Terraform provider. The built-in gRPC-gateway openapi support has some differences from what the provider expects. Build our own for now. List of known additions that have to be added: - required Get method for Terraform resources. - added Apply (PUT) method for updating resources (could probably be replaced with json merge-patch). - Addition of an "id" field, since the provider generator does not have a first-class understanding of path fields. Expected follow-up work includes: - figuring out how to require the "id" parameter during resource create. - especially nested resources: probably have to use the resource model to extract parent information and pass that via reference, constructing resource paths by reading the parents.
- Loading branch information
1 parent
fd73f48
commit 125b45c
Showing
27 changed files
with
1,875 additions
and
1,427 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.idea | ||
main | ||
terraform-provider-bookstore |
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
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
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,29 +1,33 @@ | ||
name: "bookstore.example.com" | ||
resources: | ||
- kind: "Book" | ||
plural: "books" | ||
properties: | ||
isbn: | ||
type: STRING | ||
number: 1 | ||
parents: | ||
- "bookstore.example.com/Publisher" | ||
required: true | ||
# parents: | ||
# - "bookstore.example.com/Publisher" | ||
methods: | ||
create: {} | ||
read: {} | ||
update: {} | ||
delete: {} | ||
list: {} | ||
global_list: {} | ||
- kind: "Publisher" | ||
methods: | ||
read: {} | ||
list: {} | ||
- kind: "Author" | ||
properties: | ||
name: | ||
type: STRING | ||
number: 1 | ||
parents: | ||
- "Publisher" | ||
methods: | ||
read: {} | ||
apply: {} | ||
# - kind: "Publisher" | ||
# plural: "publishers" | ||
# methods: | ||
# read: {} | ||
# list: {} | ||
# - kind: "Author" | ||
# plural: "authors" | ||
# properties: | ||
# name: | ||
# type: STRING | ||
# number: 1 | ||
# parents: | ||
# - "Publisher" | ||
# methods: | ||
# read: {} |
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,131 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"title": "bookstore.example.com", | ||
"version": "version not set" | ||
}, | ||
"schemes": [ | ||
"http" | ||
], | ||
"paths": { | ||
"/books": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"schema": { | ||
"items": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
} | ||
}, | ||
"parameters": null | ||
}, | ||
"post": { | ||
"responses": { | ||
"200": { | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"in": "body", | ||
"name": "body", | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
}, | ||
{ | ||
"in": "path", | ||
"name": "id", | ||
"schema": {}, | ||
"required": true, | ||
"type": "string" | ||
} | ||
] | ||
} | ||
}, | ||
"/books/{id}": { | ||
"delete": { | ||
"responses": { | ||
"200": { | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
}, | ||
"parameters": null | ||
}, | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
}, | ||
"parameters": null | ||
}, | ||
"patch": { | ||
"responses": { | ||
"200": { | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"in": "body", | ||
"name": "body", | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
] | ||
}, | ||
"put": { | ||
"responses": { | ||
"200": { | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"in": "body", | ||
"name": "body", | ||
"schema": { | ||
"$ref": "#/definitions/Book" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"Book": { | ||
"type": "object", | ||
"required": [ | ||
"isbn" | ||
], | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"readOnly": true, | ||
"x-terraform-id": true | ||
}, | ||
"isbn": { | ||
"type": "string" | ||
}, | ||
"path": { | ||
"type": "string", | ||
"readOnly": true | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.