-
Notifications
You must be signed in to change notification settings - Fork 0
/
gotf.proto
126 lines (116 loc) · 4.89 KB
/
gotf.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
syntax = "proto3";
package gotf;
import "google/protobuf/descriptor.proto";
option go_package = "github.com/travix/gotf";
/* Extend MessageOptions to add (gotf.block) option. */
extend google.protobuf.MessageOptions {
// define provider for this package, should be set only once per package.
optional Provider provider = 82848;
// define this message as a resource
optional Block resource = 82849;
// define this message as a datasource
optional Block datasource = 82850;
}
/* Extend FieldOptions to add (gotf.attribute) option. */
extend google.protobuf.FieldOptions {
// define this field's terraform attribute on this resource and/ or datasource.
optional Attribute attribute = 82851;
}
/* GoIdentity to indicate user defined go types such as structs, interfaces, etc.
* for terraform provider and block attribute type. */
message GoIdentity {
// name of the user defined go type.
string name = 1;
// import_path (go mod name) of the user defined go type.
// defaults to current proto files go_package name.
string import_path = 2;
// if set to true, this type will be generated as pointer type.
// *should not be set for interfaces.*
bool ptr = 3;
}
/* Block allows to generate terraform resource or datasource from proto message */
message Block {
// name for terraform resource or datasource, defaults to message name.
// defaults to snake_case of message name.
optional string name = 1;
// explicit_fields if set to `false` (default), all fields will be generated as
// attributes in this terraform block.
//
// If set to `true`, only fields with `gotf.Attribute` will be generated
// as an attributes in this terraform block.
//
// Check gotf.Attribute for default attribute properties.
bool explicit_fields = 2;
// client (names) used by this block. Generated terraform go code expects these
// clients to be generated by grpc in same go_package as other protobufs.
// Should be complete go type name
//
// This calls exec with `Set<ClientName>(client)`
// The provider exec needs to implement github.com/travix/gotf/prvdr.CanConfigureGrpc interface.
repeated string client = 3;
// description is used to set terraform block's description.
string description = 4;
}
/* Must is used to set terraform block attribute's required, optional or computed
* values */
enum MustBe {
Computed = 0; // field will be computed by provider, user can't set it in terraform script (default).
Optional = 1; // field is optional, user can set it in terraform script.
OptionalAndComputed = 2; // field is optional, but will be computed or overriden by provider.
Required = 3; // field is required, user must set it in terraform script.
}
/* Attribute to set kind properties of terraform attribute & schema for terraform block.*/
message Attribute {
// skip this field from from this terraform block.
bool skip = 1;
// attribute must_be computed, optional, required or optional and computed.
//
// If attribute is optional and `optional` keyword is not set on the fields gotf
// will try to generate default for field such as
// string -> ""
// int32 -> 0
// int64 -> 0
// float -> 0.0
// bool -> false
//
// If you want to receive nil value set `optional` keyword on field.
MustBe must_be = 2;
// name of terraform attribute, check [attribute-names] documentation for more details.
// defaults to snake_case of message field name.
//
// [attribute-names]: https://developer.hashicorp.com/terraform/plugin/best-practices/naming#attribute-names
optional string name = 3;
// sensitive if set to true field will be marked as sensitive.
optional bool sensitive = 4;
// description is used to set terraform attribute's description. Defaults to
// field comment.
optional string description = 5;
// md_description is used to set terraform attribute's markdown description of
// field. Defaults to field comment.
optional string md_description = 6;
// deprecation is used to set terraform attribute's deprecation message.
optional string deprecation = 7;
}
// Option to create provider for this package.
message Provider {
// name is used to set terraform provider type name, all resources and datasources
// will be generated under this provider.
//
// Example:
// name = "xyz";
// This will produce terraform blocks will be
// resource "xyz_resource_name" { ... }
// data "xyz_datasource_name" { ... }
string name = 1;
// package where generated terraform go code should be placed
//
// If not set files will be placed in providerpb package.
string provider_package = 2;
// description is used to set terraform provider's description.
string description = 3;
// exec_package use generate go scaffold for executors.
// if this option is set, gotf will generate scaffold for block executors.
// if the file already exists, it will be skipped.
// it should not be same as provider_package.
optional string exec_package = 4;
}