Skip to content

Commit

Permalink
#5: Add tag support
Browse files Browse the repository at this point in the history
  • Loading branch information
scastrianni committed Oct 27, 2024
1 parent 971bb93 commit 19c0c52
Show file tree
Hide file tree
Showing 29 changed files with 427 additions and 113 deletions.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ provider "konnect" {
* `region` - **(Optional, String)** The region for accessing region specific resources. Can be specified via env variable `KONNECT_REGION`. Allowed values: `us`, `eu`, `au`. Default: `us`
* `num_retries` - **(Optional, Integer)** Number of retries for each Konnect API call in case of 429-Too Many Requests or any 5XX status code. Can be specified via env variable `KONNECT_NUM_RETRIES`. Default: 3.
* `retry_delay` - **(Optional, Integer)** How long to wait (in seconds) in between retries. Can be specified via env variable `KONNECT_RETRY_DELAY`. Default: 30.
* `default_tags` - **(Optional, List of String)** List of tags to assign to all resources created by this provider, if the resource supports tags.
6 changes: 4 additions & 2 deletions docs/resources/consumer.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ resource "konnect_consumer" "example" {
```
## Argument Reference
* `control_plane_id` - **(Required, String)** The id of the control plane.
* `username` - **(Optional, String)** The unique username of the Consumer.
* `custom_id` - **(Optional, String)** Field for storing an existing unique ID for the Consumer.
* `username` - **(Optional, String)** The unique username of the consumer.
* `custom_id` - **(Optional, String)** Field for storing an existing unique ID for the consumer.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the consumer in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`consumer_id`
* `consumer_id` - **(String)** Id of the consumer alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the consumer, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Consumers can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/consumer_acl.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ resource "konnect_consumer_acl" "example" {
* `control_plane_id` - **(Required, String)** The id of the control plane.
* `consumer_id` - **(Required, String)** The id of the consumer.
* `group` - **(Required, String)** The ACL group value.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the ACL in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`consumer_id`:`acl_id`
* `acl_id` - **(String)** Id of the consumer ACL alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the ACL, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Consumer ACLs can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/consumer_basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ resource "konnect_consumer_basic" "example" {
* `consumer_id` - **(Required, String)** The id of the consumer.
* `username` - **(Required, String)** The username value.
* `password` - **(Required, String)** The password value.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the Basic Auth in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`consumer_id`:`basic_id`
* `password_hash` - **(String)** Hash of the password
* `basic_id` - **(String)** Id of the consumer basic auth alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the Basic Auth, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Consumer basics can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/consumer_hmac.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ resource "konnect_consumer_hmac" "example" {
* `consumer_id` - **(Required, String)** The id of the consumer.
* `username` - **(Required, String)** The username value.
* `secret` - **(Optional/Computed, String)** The secret value. If left out, a secret will be generated for you.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the HMAC in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`consumer_id`:`hmac_id`
* `hmac_id` - **(String)** Id of the consumer HMAC alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the HMAC, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Consumer HMACs can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/consumer_jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ resource "konnect_consumer_jwt" "example" {
* `secret` - **(Optional/Computed, String)** The secret value. If left out, a key will be generated for you.
* `algorithm` - **(Optional, String)** The algorithm for the JWT. Allowed values: `HS256`, `HS384`, `HS512`, `RS256`, `RS384`, `RS512`, `ES256`, `ES384`. Default: `HS256`
* `rsa_public_key` - **(Optional, String)** The RSA public key in PEM format for the JWT. Required if `algorithm` is `RS256`, `RS384`, `RS512`, `ES256`, or `ES384`.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the JWT in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`consumer_id`:`jwt_id`
* `jwt_id` - **(String)** Id of the consumer JWT alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the JWT, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Consumer JWTs can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/consumer_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ resource "konnect_consumer_key" "example" {
* `control_plane_id` - **(Required, String)** The id of the control plane.
* `consumer_id` - **(Required, String)** The id of the consumer.
* `key` - **(Optional/Computed, String)** The API key value. If left out, a key will be generated for you.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the API key in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`consumer_id`:`key_id`
* `key_id` - **(String)** Id of the consumer API key alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the API key, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Consumer keys can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ EOF
* `service_id` - **(Optional, String)** If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified service.
* `route_id` - **(Optional, String)** If set, the plugin will only activate when receiving requests via the specified route.
* `consumer_id` - **(Optional, String)** If set, the plugin will activate only for requests where the specified consumer has been authenticated.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the plugin in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`plugin_id`
* `plugin_id` - **(String)** Id of the plugin alone
* `config_all_json` - **(JSON)** The full configuration properties for the plugin, including all properties with their default values not specified in `config`.
* `all_tags` - **(List of String)** The complete list of tags assigned to the plugin, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Plugins can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/route.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ resource "konnect_route" "example" {
* `request_buffering` - **(Optional, Boolean)** Whether to enable request body buffering. Default: `true`
* `response_buffering` - **(Optional, Boolean)** Whether to enable response body buffering. Default: `true`
* `header` - **(Optional, set{header})** Configuration block for a header. Can be specified multiple times for each header. Each block supports the fields documented below.
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the route in addition to the `default_tags` configured in the provider.
### header
* `name` - **(Required, String)** Name of header this route should require.
* `values` - **(Required, List of String)** Allowed values this header should equal.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`route_id`
* `route_id` - **(String)** Id of the route alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the route, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Routes can be imported using a proper value of `id` as described above
2 changes: 2 additions & 0 deletions docs/resources/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ resource "konnect_service" "example" {
* `read_timeout` - **(Optional, Integer)** The timeout in milliseconds between two successive read operations for transmitting a request to the host. Default: `60000`
* `write_timeout` - **(Optional, Integer)** The timeout in milliseconds between two successive write operations for transmitting a request to the host. Default: `60000`
* `enabled` - **(Optional, Boolean)** Whether the service is active. Default: `true`
* `tags` - **(Optional, List of String)** An extra list of tags to assign to the service in addition to the `default_tags` configured in the provider.
## Attribute Reference
* `id` - **(String)** Same as `control_plane_id`:`service_id`
* `service_id` - **(String)** Id of the service alone
* `all_tags` - **(List of String)** The complete list of tags assigned to the service, including the `tags` defined on this resource and the `default_tags` configured in the provider.
## Import
Services can be imported using a proper value of `id` as described above
12 changes: 6 additions & 6 deletions konnect/client/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ const (
)

type Consumer struct {
ControlPlaneId string `json:"-"`
Id string `json:"id"`
Username string `json:"username"`
CustomId string `json:"custom_id"`
ControlPlaneId string `json:"-"`
Id string `json:"id"`
Username string `json:"username"`
CustomId string `json:"custom_id"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}
type ConsumerCollection struct {
Consumers []Consumer `json:"data"`
Expand All @@ -25,5 +27,3 @@ func ConsumerDecodeId(s string) (string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1]
}

//TAGS
12 changes: 6 additions & 6 deletions konnect/client/consumer_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ const (
)

type ConsumerACL struct {
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Group string `json:"group"`
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Group string `json:"group"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}

func (ca *ConsumerACL) ConsumerACLEncodeId() string {
Expand All @@ -22,5 +24,3 @@ func ConsumerACLDecodeId(s string) (string, string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1], tokens[2]
}

//TAGS
16 changes: 8 additions & 8 deletions konnect/client/consumer_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ const (
)

type ConsumerBasic struct {
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
PasswordHash string `json:"-"`
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
PasswordHash string `json:"-"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}

func (cb *ConsumerBasic) ConsumerBasicEncodeId() string {
Expand All @@ -24,5 +26,3 @@ func ConsumerBasicDecodeId(s string) (string, string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1], tokens[2]
}

//TAGS
14 changes: 7 additions & 7 deletions konnect/client/consumer_hmac.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ const (
)

type ConsumerHMAC struct {
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Username string `json:"username"`
Secret string `json:"secret,omitempty"`
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Username string `json:"username"`
Secret string `json:"secret,omitempty"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}

func (ch *ConsumerHMAC) ConsumerHMACEncodeId() string {
Expand All @@ -23,5 +25,3 @@ func ConsumerHMACDecodeId(s string) (string, string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1], tokens[2]
}

//TAGS
18 changes: 9 additions & 9 deletions konnect/client/consumer_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ const (
)

type ConsumerJWT struct {
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Key string `json:"key,omitempty"`
Algorithm string `json:"algorithm"`
RSAPublicKey string `json:"rsa_public_key,omitempty"`
Secret string `json:"secret,omitempty"`
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Key string `json:"key,omitempty"`
Algorithm string `json:"algorithm"`
RSAPublicKey string `json:"rsa_public_key,omitempty"`
Secret string `json:"secret,omitempty"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}

func (cj *ConsumerJWT) ConsumerJWTEncodeId() string {
Expand All @@ -25,5 +27,3 @@ func ConsumerJWTDecodeId(s string) (string, string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1], tokens[2]
}

//TAGS
12 changes: 6 additions & 6 deletions konnect/client/consumer_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ const (
)

type ConsumerKey struct {
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Key string `json:"key,omitempty"`
ControlPlaneId string `json:"-"`
ConsumerId string `json:"-"`
Id string `json:"id"`
Key string `json:"key,omitempty"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}

func (ck *ConsumerKey) ConsumerKeyEncodeId() string {
Expand All @@ -22,5 +24,3 @@ func ConsumerKeyDecodeId(s string) (string, string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1], tokens[2]
}

//TAGS
4 changes: 2 additions & 2 deletions konnect/client/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type Plugin struct {
Route *EntityId `json:"route,omitempty"`
Service *EntityId `json:"service,omitempty"`
Consumer *EntityId `json:"consumer,omitempty"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}
type PluginCollection struct {
Plugins []Plugin `json:"data"`
Expand All @@ -42,5 +44,3 @@ func PluginDecodeId(s string) (string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1]
}

//TAGS
4 changes: 2 additions & 2 deletions konnect/client/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type Route struct {
RequestBuffering bool `json:"request_buffering"`
ResponseBuffering bool `json:"response_buffering"`
Service *EntityId `json:"service,omitempty"`
AllTags []string `json:"tags"`
Tags []string `json:"-"`
}
type RouteCollection struct {
Routes []Route `json:"data"`
Expand All @@ -37,5 +39,3 @@ func RouteDecodeId(s string) (string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1]
}

//TAGS
2 changes: 0 additions & 2 deletions konnect/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ func ServiceDecodeId(s string) (string, string) {
tokens := strings.Split(s, IdSeparator)
return tokens[0], tokens[1]
}

//TAGS
Loading

0 comments on commit 19c0c52

Please sign in to comment.