Skip to content

Commit 7922ec6

Browse files
authored
Merge pull request #313 from vmware/vmware/otaylor/aks-kubeconfig
Vmware/otaylor/aks kubeconfig
2 parents 740fc83 + 409c833 commit 7922ec6

29 files changed

+684
-28
lines changed

docs/data-sources/akscluster.md

+2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ output "location" {
5656
- `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta))
5757
- `ready_wait_timeout` (String) Wait timeout duration until cluster resource reaches READY state. Accepted timeout duration values like 5s, 45m, or 3h, higher than zero. The default duration is 30m
5858
- `spec` (Block List, Max: 1) Spec for the cluster (see [below for nested schema](#nestedblock--spec))
59+
- `wait_for_kubeconfig` (Boolean) Wait until pinniped extension is ready to provide kubeconfig
5960

6061
### Read-Only
6162

6263
- `id` (String) The ID of this resource.
64+
- `kubeconfig` (String) Kubeconfig for connecting to newly created cluster base64 encoded. This will only be returned if you have elected to wait for kubeconfig.
6365

6466
<a id="nestedblock--meta"></a>
6567
### Nested Schema for `meta`

docs/resources/akscluster.md

+2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ resource "tanzu-mission-control_akscluster" "demo_AKS_cluster" {
9292

9393
- `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta))
9494
- `ready_wait_timeout` (String) Wait timeout duration until cluster resource reaches READY state. Accepted timeout duration values like 5s, 45m, or 3h, higher than zero. The default duration is 30m
95+
- `wait_for_kubeconfig` (Boolean) Wait until pinniped extension is ready to provide kubeconfig
9596

9697
### Read-Only
9798

9899
- `id` (String) The ID of this resource.
100+
- `kubeconfig` (String) Kubeconfig for connecting to newly created cluster base64 encoded. This will only be returned if you have elected to wait for kubeconfig.
99101

100102
<a id="nestedblock--spec"></a>
101103
### Nested Schema for `spec`

examples/resources/mutation_policy/resource_cluster_group_scoped_annotation_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "tanzu-mission-control_mutation_policy" "cluster_group_annotation_mutat
3030
{
3131
key = "component"
3232
operator = "NotIn"
33-
values = [
33+
values = [
3434
"api-server",
3535
"agent-gateway"
3636
]

examples/resources/mutation_policy/resource_cluster_group_scoped_label_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "tanzu-mission-control_mutation_policy" "cluster_group_label_mutation_p
3030
{
3131
key = "component"
3232
operator = "NotIn"
33-
values = [
33+
values = [
3434
"api-server",
3535
"agent-gateway"
3636
]

examples/resources/mutation_policy/resource_cluster_group_scoped_pod_security_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ resource "tanzu-mission-control_mutation_policy" "cluster_group_pod_security_mut
6464
{
6565
key = "component"
6666
operator = "NotIn"
67-
values = [
67+
values = [
6868
"api-server",
6969
"agent-gateway"
7070
]

examples/resources/mutation_policy/resource_cluster_scoped_annotation_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ resource "tanzu-mission-control_mutation_policy" "cluster_annotation_mutation_po
3131
{
3232
key = "component"
3333
operator = "NotIn"
34-
values = [
34+
values = [
3535
"api-server",
3636
"agent-gateway"
3737
]

examples/resources/mutation_policy/resource_cluster_scoped_label_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resource "tanzu-mission-control_mutation_policy" "cluster_label_mutation_policy"
3232
{
3333
key = "component"
3434
operator = "NotIn"
35-
values = [
35+
values = [
3636
"api-server",
3737
"agent-gateway"
3838
]

examples/resources/mutation_policy/resource_cluster_scoped_pod_security_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ resource "tanzu-mission-control_mutation_policy" "cluster_pod_security_mutation_
6666
{
6767
key = "component"
6868
operator = "NotIn"
69-
values = [
69+
values = [
7070
"api-server",
7171
"agent-gateway"
7272
]

examples/resources/mutation_policy/resource_organization_scoped_annotation_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "tanzu-mission-control_mutation_policy" "org_annotation_mutation_policy
3030
{
3131
key = "component"
3232
operator = "NotIn"
33-
values = [
33+
values = [
3434
"api-server",
3535
"agent-gateway"
3636
]

examples/resources/mutation_policy/resource_organization_scoped_label_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "tanzu-mission-control_mutation_policy" "org_label_mutation_policy" {
3030
{
3131
key = "component"
3232
operator = "NotIn"
33-
values = [
33+
values = [
3434
"api-server",
3535
"agent-gateway"
3636
]

examples/resources/mutation_policy/resource_organization_scoped_pod_security_mutation_policy.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ resource "tanzu-mission-control_mutation_policy" "org_pod_security_mutation_poli
6464
{
6565
key = "component"
6666
operator = "NotIn"
67-
values = [
67+
values = [
6868
"api-server",
6969
"agent-gateway"
7070
]

internal/client/http_client.go

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
eksclusterclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/ekscluster"
3939
eksnodepoolclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/ekscluster/nodepool"
4040
integrationclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/integration"
41+
kubeconfigclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/kubeconfig"
4142
secretclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/kubernetessecret"
4243
secretexportclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/kubernetessecret/secretexport"
4344
namespaceclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/namespace"
@@ -128,6 +129,7 @@ func newHTTPClient(httpClient *transport.Client) *TanzuMissionControl {
128129
OrganizationHelmChartsResourceService: helmchartsorgclient.New(httpClient),
129130
ClusterGroupSecretResourceService: secretclustergroupclient.New(httpClient),
130131
ClusterGroupSecretExportResourceService: secretexportclustergroupclient.New(httpClient),
132+
KubeConfigResourceService: kubeconfigclient.New(httpClient),
131133
}
132134
}
133135

@@ -178,4 +180,5 @@ type TanzuMissionControl struct {
178180
OrganizationHelmChartsResourceService helmchartsorgclient.ClientService
179181
ClusterGroupSecretResourceService secretclustergroupclient.ClientService
180182
ClusterGroupSecretExportResourceService secretexportclustergroupclient.ClientService
183+
KubeConfigResourceService kubeconfigclient.ClientService
181184
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package kubeconfig
7+
8+
import (
9+
"net/url"
10+
11+
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/transport"
12+
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper"
13+
models "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/kubeconfig"
14+
)
15+
16+
const (
17+
apiVersionAndGroup = "/v1alpha1/clusters"
18+
apiKubeconfigPath = "kubeconfig"
19+
queryParamKeyFullNameManagementClusterName = "full_name.managementClusterName"
20+
queryParamKeyFullNameProvisionerName = "full_name.provisionerName"
21+
)
22+
23+
// New creates a new kubeconfig service API client.
24+
func New(transport *transport.Client) ClientService {
25+
return &Client{Client: transport}
26+
}
27+
28+
/*
29+
Client for kubeconfig service API.
30+
*/
31+
type Client struct {
32+
*transport.Client
33+
}
34+
35+
// ClientService is the interface for Client methods.
36+
type ClientService interface {
37+
KubeconfigServiceGet(fn *models.VmwareTanzuManageV1alpha1ClusterFullName) (*models.VmwareTanzuManageV1alpha1ClusterKubeconfigGetKubeconfigResponse, error)
38+
}
39+
40+
/*
41+
KubeconfigServiceGet gets cluster kubeconfig.
42+
*/
43+
func (c *Client) KubeconfigServiceGet(fn *models.VmwareTanzuManageV1alpha1ClusterFullName) (*models.VmwareTanzuManageV1alpha1ClusterKubeconfigGetKubeconfigResponse, error) {
44+
queryParams := url.Values{}
45+
if fn.ManagementClusterName != "" {
46+
queryParams.Add(queryParamKeyFullNameManagementClusterName, fn.ManagementClusterName)
47+
}
48+
49+
if fn.ProvisionerName != "" {
50+
queryParams.Add(queryParamKeyFullNameProvisionerName, fn.ProvisionerName)
51+
}
52+
53+
queryParams.Add("cli", string(models.VmwareTanzuManageV1alpha1ClusterKubeconfigCliTypeTANZUCLI))
54+
55+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.Name, apiKubeconfigPath).AppendQueryParams(queryParams).String()
56+
clusterResponse := &models.VmwareTanzuManageV1alpha1ClusterKubeconfigGetKubeconfigResponse{}
57+
58+
err := c.Get(requestURL, clusterResponse)
59+
60+
return clusterResponse, err
61+
}

internal/models/credential/spec.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/models/credential/spec_data.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/models/credential/status.go

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package models
7+
8+
import (
9+
"github.com/go-openapi/strfmt"
10+
"github.com/go-openapi/swag"
11+
)
12+
13+
// GoogleProtobufAny google protobuf any
14+
//
15+
// swagger:model google.protobuf.Any
16+
type GoogleProtobufAny struct {
17+
18+
// type Url
19+
TypeURL string `json:"typeUrl,omitempty"`
20+
21+
// value
22+
// Format: byte
23+
Value strfmt.Base64 `json:"value,omitempty"`
24+
}
25+
26+
// MarshalBinary interface implementation.
27+
func (m *GoogleProtobufAny) MarshalBinary() ([]byte, error) {
28+
if m == nil {
29+
return nil, nil
30+
}
31+
32+
return swag.WriteJSON(m)
33+
}
34+
35+
// UnmarshalBinary interface implementation.
36+
func (m *GoogleProtobufAny) UnmarshalBinary(b []byte) error {
37+
var res GoogleProtobufAny
38+
if err := swag.ReadJSON(b, &res); err != nil {
39+
return err
40+
}
41+
42+
*m = res
43+
44+
return nil
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package models
7+
8+
import (
9+
"github.com/go-openapi/swag"
10+
)
11+
12+
// GrpcGatewayRuntimeError grpc gateway runtime error
13+
//
14+
// swagger:model grpc.gateway.runtime.Error
15+
type GrpcGatewayRuntimeError struct {
16+
17+
// code
18+
Code int32 `json:"code,omitempty"`
19+
20+
// details
21+
Details []*GoogleProtobufAny `json:"details"`
22+
23+
// error
24+
Error string `json:"error,omitempty"`
25+
26+
// message
27+
Message string `json:"message,omitempty"`
28+
}
29+
30+
// MarshalBinary interface implementation.
31+
func (m *GrpcGatewayRuntimeError) MarshalBinary() ([]byte, error) {
32+
if m == nil {
33+
return nil, nil
34+
}
35+
36+
return swag.WriteJSON(m)
37+
}
38+
39+
// UnmarshalBinary interface implementation.
40+
func (m *GrpcGatewayRuntimeError) UnmarshalBinary(b []byte) error {
41+
var res GrpcGatewayRuntimeError
42+
if err := swag.ReadJSON(b, &res); err != nil {
43+
return err
44+
}
45+
46+
*m = res
47+
48+
return nil
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package models
7+
8+
import (
9+
"github.com/go-openapi/swag"
10+
)
11+
12+
// VmwareTanzuManageV1alpha1ClusterFullName Full name of the cluster. This includes the object name along
13+
// with any parents or further identifiers.
14+
//
15+
// swagger:model vmware.tanzu.manage.v1alpha1.cluster.FullName
16+
type VmwareTanzuManageV1alpha1ClusterFullName struct {
17+
18+
// Name of the management cluster.
19+
ManagementClusterName string `json:"managementClusterName,omitempty"`
20+
21+
// Name of this cluster.
22+
Name string `json:"name,omitempty"`
23+
24+
// ID of Organization.
25+
OrgID string `json:"orgId,omitempty"`
26+
27+
// Provisioner of the cluster.
28+
ProvisionerName string `json:"provisionerName,omitempty"`
29+
}
30+
31+
// MarshalBinary interface implementation.
32+
func (m *VmwareTanzuManageV1alpha1ClusterFullName) MarshalBinary() ([]byte, error) {
33+
if m == nil {
34+
return nil, nil
35+
}
36+
37+
return swag.WriteJSON(m)
38+
}
39+
40+
// UnmarshalBinary interface implementation.
41+
func (m *VmwareTanzuManageV1alpha1ClusterFullName) UnmarshalBinary(b []byte) error {
42+
var res VmwareTanzuManageV1alpha1ClusterFullName
43+
if err := swag.ReadJSON(b, &res); err != nil {
44+
return err
45+
}
46+
47+
*m = res
48+
49+
return nil
50+
}

0 commit comments

Comments
 (0)