-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
199 additions
and
41 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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package consul | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/hashicorp/consul/api" | ||
"github.com/hashicorp/consul/proto-public/pbresource" | ||
) | ||
|
||
type GVK struct { | ||
Group string | ||
Version string | ||
Kind string | ||
} | ||
|
||
type V2WriteRequest struct { | ||
Metadata map[string]string `json:"metadata"` | ||
Data map[string]any `json:"data"` | ||
Owner *pbresource.ID `json:"owner"` | ||
} | ||
|
||
type V2WriteResponse struct { | ||
Metadata map[string]string `json:"metadata"` | ||
Data map[string]any `json:"data"` | ||
Owner *pbresource.ID `json:"owner,omitempty"` | ||
ID *pbresource.ID `json:"id"` | ||
Version string `json:"version"` | ||
Generation string `json:"generation"` | ||
Status map[string]any `json:"status"` | ||
} | ||
|
||
func v2MulticlusterRead(client *api.Client, gvk *GVK, resourceName string, q *api.QueryOptions) (map[string]interface{}, error) { | ||
endpoint := strings.ToLower(fmt.Sprintf("/api/%s/%s/%s/%s", gvk.Group, gvk.Version, gvk.Kind, resourceName)) | ||
var out map[string]interface{} | ||
_, err := client.Raw().Query(endpoint, &out, q) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return out, nil | ||
} | ||
|
||
func v2MulticlusterDelete(client *api.Client, gvk *GVK, resourceName string, q *api.QueryOptions) error { | ||
endpoint := strings.ToLower(fmt.Sprintf("/api/%s/%s/%s/%s", gvk.Group, gvk.Version, gvk.Kind, resourceName)) | ||
_, err := client.Raw().Delete(endpoint, q) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func v2MulticlusterApply(client *api.Client, gvk *GVK, resourceName string, w *api.WriteOptions, payload *V2WriteRequest) (*V2WriteResponse, *api.WriteMeta, error) { | ||
endpoint := strings.ToLower(fmt.Sprintf("/api/%s/%s/%s/%s", gvk.Group, gvk.Version, gvk.Kind, resourceName)) | ||
out := &V2WriteResponse{} | ||
wm, err := client.Raw().Write(endpoint, payload, out, w) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
return out, wm, nil | ||
} |
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,34 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "consul_config_entry_v2_exported_services Data Source - terraform-provider-consul" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# consul_config_entry_v2_exported_services (Data Source) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `kind` (String) The kind of exported services config (ExportedServices, NamespaceExportedServices, PartitionExportedServices). | ||
- `name` (String) The name of the config entry to read. | ||
|
||
### Optional | ||
|
||
- `namespace` (String) The namespace the config entry is associated with. | ||
- `partition` (String) The partition the config entry is associated with. | ||
- `partition_consumers` (List of String) The exported service partition consumers. | ||
- `peer_consumers` (List of String) The exported service peer consumers. | ||
- `sameness_group_consumers` (List of String) The exported service sameness group consumers. | ||
- `services` (List of String) The exported services. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. |
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,34 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "consul_config_entry_v2_exported_services Resource - terraform-provider-consul" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# consul_config_entry_v2_exported_services (Resource) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `kind` (String) The kind of exported services config (ExportedServices, NamespaceExportedServices, PartitionExportedServices). | ||
- `name` (String) The name of the config entry to read. | ||
- `partition` (String) The partition the config entry is associated with. | ||
|
||
### Optional | ||
|
||
- `namespace` (String) The namespace the config entry is associated with. | ||
- `partition_consumers` (List of String) The exported service partition consumers. | ||
- `peer_consumers` (List of String) The exported service peer consumers. | ||
- `sameness_group_consumers` (List of String) The exported service sameness group consumers. | ||
- `services` (List of String) The exported services. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. |
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
Oops, something went wrong.