Skip to content

Commit

Permalink
Backport of Update multicluster v2beta1 to v2 into release/1.4.x (#3587)
Browse files Browse the repository at this point in the history
* Update multicluster v2beta1 to v2 (#3560)

Co-authored-by: skpratt <sarah.pratt@hashicorp.com>
(cherry picked from commit fdfb762)

* Fix temp replace directives

* Remove PeerName references

* Use commit from consul@release/1.18.x

---------

Co-authored-by: Chris S. Kim <ckim@hashicorp.com>
  • Loading branch information
hc-github-team-consul-core and Chris S. Kim authored Feb 8, 2024
1 parent 93c66cb commit 7e6f4f7
Show file tree
Hide file tree
Showing 37 changed files with 69 additions and 213 deletions.
4 changes: 2 additions & 2 deletions acceptance/tests/vault/vault_wan_fed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ func TestVault_WANFederationViaGateways(t *testing.T) {
}
srvCAAuthRoleConfigSecondary.ConfigureK8SAuthRole(t, vaultClient)

// // Move Vault CA secret from primary to secondary so that we can mount it to pods in the
// // secondary cluster.
// Move Vault CA secret from primary to secondary so that we can mount it to pods in the
// secondary cluster.
vaultCASecretName := vault.CASecretName(vaultReleaseName)
logger.Logf(t, "retrieving Vault CA secret %s from the primary cluster and applying to the secondary", vaultCASecretName)
vaultCASecret, err := primaryCtx.KubernetesClient(t).CoreV1().Secrets(ns).Get(context.Background(), vaultCASecretName, metav1.GetOptions{})
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/crd-exportedservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v2beta1
name: v2
schema:
openAPIV3Schema:
description: ExportedServices is the Schema for the Exported Services API
Expand Down
5 changes: 0 additions & 5 deletions control-plane/api/auth/v2beta1/traffic_permissions_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -62,10 +61,6 @@ func (in *TrafficPermissions) ResourceID(namespace, partition string) *pbresourc
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ func TestTrafficPermissions_MatchesConsul(t *testing.T) {
Tenancy: &pbresource.Tenancy{
Partition: constants.DefaultConsulNS,
Namespace: constants.DefaultConsulPartition,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
},
Data: inject.ToProtoAny(&pbmesh.ProxyConfiguration{}),
Expand Down Expand Up @@ -608,7 +604,7 @@ func TestTrafficPermissions_ObjectMeta(t *testing.T) {

// Test defaulting behavior when namespaces are enabled as well as disabled.
// TODO: add when implemented
//func TestTrafficPermissions_DefaultNamespaceFields(t *testing.T)
// func TestTrafficPermissions_DefaultNamespaceFields(t *testing.T)

func TestTrafficPermissions_Validate(t *testing.T) {
cases := []struct {
Expand Down Expand Up @@ -1021,10 +1017,6 @@ func constructTrafficPermissionResource(tp *pbauth.TrafficPermissions, name, nam
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
Uid: "ABCD", // We add this to show it does not factor into the comparison
}
Expand Down
9 changes: 2 additions & 7 deletions control-plane/api/mesh/v2beta1/api_gateway_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
Expand All @@ -15,7 +15,6 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -58,10 +57,6 @@ func (in *APIGateway) ResourceID(namespace, partition string) *pbresource.ID {
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/mesh/v2beta1/gateway_class_config_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package v2beta1

Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/mesh/v2beta1/gateway_class_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
Expand Down
9 changes: 2 additions & 7 deletions control-plane/api/mesh/v2beta1/grpc_route_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
Expand All @@ -18,7 +18,6 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -61,10 +60,6 @@ func (in *GRPCRoute) ResourceID(namespace, partition string) *pbresource.ID {
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
10 changes: 1 addition & 9 deletions control-plane/api/mesh/v2beta1/grpc_route_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,6 @@ func TestGRPCRoute_MatchesConsul(t *testing.T) {
Tenancy: &pbresource.Tenancy{
Partition: constants.DefaultConsulNS,
Namespace: constants.DefaultConsulPartition,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
},
Data: inject.ToProtoAny(&pbmesh.ProxyConfiguration{}),
Expand Down Expand Up @@ -601,7 +597,7 @@ func TestGRPCRoute_ObjectMeta(t *testing.T) {

// Test defaulting behavior when namespaces are enabled as well as disabled.
// TODO: add when implemented
//func TestGRPCRoute_DefaultNamespaceFields(t *testing.T)
// func TestGRPCRoute_DefaultNamespaceFields(t *testing.T)

func TestGRPCRoute_Validate(t *testing.T) {
cases := []struct {
Expand Down Expand Up @@ -1174,10 +1170,6 @@ func constructGRPCRouteResource(tp *pbmesh.GRPCRoute, name, namespace, partition
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
Uid: "ABCD", // We add this to show it does not factor into the comparison
}
Expand Down
9 changes: 2 additions & 7 deletions control-plane/api/mesh/v2beta1/http_route_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
Expand All @@ -20,7 +20,6 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -63,10 +62,6 @@ func (in *HTTPRoute) ResourceID(namespace, partition string) *pbresource.ID {
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
10 changes: 1 addition & 9 deletions control-plane/api/mesh/v2beta1/http_route_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,6 @@ func TestHTTPRoute_MatchesConsul(t *testing.T) {
Tenancy: &pbresource.Tenancy{
Partition: constants.DefaultConsulNS,
Namespace: constants.DefaultConsulPartition,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
},
Data: inject.ToProtoAny(&pbmesh.ProxyConfiguration{}),
Expand Down Expand Up @@ -807,7 +803,7 @@ func TestHTTPRoute_ObjectMeta(t *testing.T) {

// Test defaulting behavior when namespaces are enabled as well as disabled.
// TODO: add when implemented
//func TestHTTPRoute_DefaultNamespaceFields(t *testing.T)
// func TestHTTPRoute_DefaultNamespaceFields(t *testing.T)

func TestHTTPRoute_Validate(t *testing.T) {
cases := []struct {
Expand Down Expand Up @@ -1311,10 +1307,6 @@ func constructHTTPRouteResource(tp *pbmesh.HTTPRoute, name, namespace, partition
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
Uid: "ABCD", // We add this to show it does not factor into the comparison
}
Expand Down
14 changes: 5 additions & 9 deletions control-plane/api/mesh/v2beta1/mesh_configuration_types.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
"fmt"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v2beta1"
"github.com/hashicorp/consul/proto-public/pbresource"
"google.golang.org/protobuf/testing/protocmp"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
)

const (
Expand Down Expand Up @@ -57,10 +57,6 @@ func (in *MeshConfiguration) ResourceID(_, partition string) *pbresource.ID {
Tenancy: &pbresource.Tenancy{
// we don't pass a namespace here because MeshConfiguration is partition-scoped
Partition: partition,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
8 changes: 2 additions & 6 deletions control-plane/api/mesh/v2beta1/mesh_gateway_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
Expand All @@ -15,7 +15,6 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -59,9 +58,6 @@ func (in *MeshGateway) ResourceID(_, partition string) *pbresource.ID {
Partition: partition,
Namespace: "", // Namespace is always unset because MeshGateway is partition-scoped

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
9 changes: 2 additions & 7 deletions control-plane/api/mesh/v2beta1/proxy_configuration_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
Expand All @@ -18,7 +18,6 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -61,10 +60,6 @@ func (in *ProxyConfiguration) ResourceID(namespace, partition string) *pbresourc
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ func TestProxyConfiguration_MatchesConsul(t *testing.T) {
Tenancy: &pbresource.Tenancy{
Partition: constants.DefaultConsulNS,
Namespace: constants.DefaultConsulPartition,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
},
Data: inject.ToProtoAny(&pbmesh.ProxyConfiguration{}),
Expand Down Expand Up @@ -513,7 +509,7 @@ func TestProxyConfiguration_ObjectMeta(t *testing.T) {

// Test defaulting behavior when namespaces are enabled as well as disabled.
// TODO: add when implemented
//func TestProxyConfiguration_DefaultNamespaceFields(t *testing.T)
// func TestProxyConfiguration_DefaultNamespaceFields(t *testing.T)

func constructProxyConfigurationResource(tp *pbmesh.ProxyConfiguration, name, namespace, partition string) *pbresource.Resource {
data := inject.ToProtoAny(tp)
Expand All @@ -524,10 +520,6 @@ func constructProxyConfigurationResource(tp *pbmesh.ProxyConfiguration, name, na
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
Uid: "ABCD", // We add this to show it does not factor into the comparison
}
Expand Down
9 changes: 2 additions & 7 deletions control-plane/api/mesh/v2beta1/tcp_route_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) HashiCorp, Inc.
// // SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package v2beta1

import (
Expand All @@ -18,7 +18,6 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api/common"
inject "github.com/hashicorp/consul-k8s/control-plane/connect-inject/common"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -61,10 +60,6 @@ func (in *TCPRoute) ResourceID(namespace, partition string) *pbresource.ID {
Tenancy: &pbresource.Tenancy{
Partition: partition,
Namespace: namespace,

// Because we are explicitly defining NS/partition, this will not default and must be explicit.
// At a future point, this will move out of the Tenancy block.
PeerName: constants.DefaultConsulPeer,
},
}
}
Expand Down
Loading

0 comments on commit 7e6f4f7

Please sign in to comment.