Skip to content

Commit

Permalink
feat(GCPVpcPeering) Delete VPC Peering
Browse files Browse the repository at this point in the history
  • Loading branch information
bru-jer-work committed Aug 2, 2024
1 parent b394223 commit d52c95b
Show file tree
Hide file tree
Showing 37 changed files with 663 additions and 312 deletions.
2 changes: 1 addition & 1 deletion api/cloud-control/v1beta1/vpcpeering_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type VpcPeeringInfo struct {
}

type GcpVpcPeering struct {
PeeringName string `json:"peeringName,omitempty"`
RemotePeeringName string `json:"remotePeeringName,omitempty"`
RemoteProject string `json:"remoteProject,omitempty"`
RemoteVpc string `json:"remoteVpc,omitempty"`
ImportCustomRoutes bool `json:"importCustomRoutes,omitempty"`
Expand Down
16 changes: 12 additions & 4 deletions api/cloud-resources/v1beta1/gcpvpcpeering_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ import (
// Important: Run "make" to regenerate code after modifying this file

type GcpVpcPeeringSpec struct {
ImportCustomRoutes bool `json:"importCustomRoutes,omitempty"`
PeeringName string `json:"peeringName,omitempty"`
RemoteVpc string `json:"remoteVpc,omitempty"`
RemoteProject string `json:"remoteProject,omitempty"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule=(self == oldSelf), message="ImportCustomRoutes is immutable."
ImportCustomRoutes bool `json:"importCustomRoutes,omitempty"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule=(self == oldSelf), message="RemotePeeringName is immutable."
RemotePeeringName string `json:"remotePeeringName,omitempty"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule=(self == oldSelf), message="RemoteVpc is immutable."
RemoteVpc string `json:"remoteVpc,omitempty"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule=(self == oldSelf), message="RemoteNetwork is immutable."
RemoteProject string `json:"remoteProject,omitempty"`
}

type GcpVpcPeeringStatus struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spec:
properties:
importCustomRoutes:
type: boolean
peeringName:
remotePeeringName:
type: string
remoteProject:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@ spec:
properties:
importCustomRoutes:
type: boolean
peeringName:
x-kubernetes-validations:
- message: ImportCustomRoutes is immutable.
rule: (self == oldSelf)
remotePeeringName:
type: string
x-kubernetes-validations:
- message: RemotePeeringName is immutable.
rule: (self == oldSelf)
remoteProject:
type: string
x-kubernetes-validations:
- message: RemoteNetwork is immutable.
rule: (self == oldSelf)
remoteVpc:
type: string
x-kubernetes-validations:
- message: RemoteVpc is immutable.
rule: (self == oldSelf)
type: object
status:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spec:
properties:
importCustomRoutes:
type: boolean
peeringName:
remotePeeringName:
type: string
remoteProject:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@ spec:
properties:
importCustomRoutes:
type: boolean
peeringName:
x-kubernetes-validations:
- message: ImportCustomRoutes is immutable.
rule: (self == oldSelf)
remotePeeringName:
type: string
x-kubernetes-validations:
- message: RemotePeeringName is immutable.
rule: (self == oldSelf)
remoteProject:
type: string
x-kubernetes-validations:
- message: RemoteNetwork is immutable.
rule: (self == oldSelf)
remoteVpc:
type: string
x-kubernetes-validations:
- message: RemoteVpc is immutable.
rule: (self == oldSelf)
type: object
status:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ data:
source: importCustomRoutes
name: spec.importCustomRoutes
- widget: Labels
source: peeringName
name: spec.peeringName
source: remotePeeringName
name: spec.remotePeeringName
- widget: Labels
source: remoteProject
name: spec.remoteProject
Expand All @@ -29,9 +29,9 @@ data:
- path: spec.importCustomRoutes
simple: true
name: spec.importCustomRoutes
- path: spec.peeringName
- path: spec.remotePeeringName
simple: true
name: spec.peeringName
name: spec.remotePeeringName
widget: Text
- path: spec.remoteProject
simple: true
Expand All @@ -57,8 +57,8 @@ data:
- source: spec.importCustomRoutes
name: spec.importCustomRoutes
sort: true
- source: spec.peeringName
name: spec.peeringName
- source: spec.remotePeeringName
name: spec.remotePeeringName
sort: true
- source: spec.remoteProject
name: spec.remoteProject
Expand All @@ -71,7 +71,7 @@ data:
configuration: Configuration
status: Status
spec.importCustomRoutes: Import Custom Routes
spec.peeringName: Peering Name
spec.remotePeeringName: Remote Peering Name
spec.remoteProject: Remote Project
spec.remoteVpc: Remote VPC
status.id: ID
Expand Down
2 changes: 1 addition & 1 deletion config/samples/cloud-resources_v1beta1_gcpvpcpeering.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
app.kubernetes.io/created-by: cloud-manager
name: gcpvpcpeering-sample
spec:
name: "vpcpeering-sap-gcp-skr-dev-cust-00002-sap-sc-learn"
remotePeeringame: "vpcpeering-sap-gcp-skr-dev-cust-00002-sap-sc-learn"
remoteProject: "sap-sc-learn"
remoteVpc: "default"
importCustomRoutes: false
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ data:
source: importCustomRoutes
name: spec.importCustomRoutes
- widget: Labels
source: peeringName
name: spec.peeringName
source: remotePeeringName
name: spec.remotePeeringName
- widget: Labels
source: remoteProject
name: spec.remoteProject
Expand All @@ -29,9 +29,9 @@ data:
- path: spec.importCustomRoutes
simple: true
name: spec.importCustomRoutes
- path: spec.peeringName
- path: spec.remotePeeringName
simple: true
name: spec.peeringName
name: spec.remotePeeringName
widget: Text
- path: spec.remoteProject
simple: true
Expand All @@ -57,8 +57,8 @@ data:
- source: spec.importCustomRoutes
name: spec.importCustomRoutes
sort: true
- source: spec.peeringName
name: spec.peeringName
- source: spec.remotePeeringName
name: spec.remotePeeringName
sort: true
- source: spec.remoteProject
name: spec.remoteProject
Expand All @@ -71,7 +71,7 @@ data:
configuration: Configuration
status: Status
spec.importCustomRoutes: Import Custom Routes
spec.peeringName: Peering Name
spec.remotePeeringName: Remote Peering Name
spec.remoteProject: Remote Project
spec.remoteVpc: Remote VPC
status.id: ID
Expand Down
4 changes: 2 additions & 2 deletions config/ui-extensions/gcpvpcpeerings/details
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ body:
source: importCustomRoutes
name: spec.importCustomRoutes
- widget: Labels
source: peeringName
name: spec.peeringName
source: remotePeeringName
name: spec.remotePeeringName
- widget: Labels
source: remoteProject
name: spec.remoteProject
Expand Down
4 changes: 2 additions & 2 deletions config/ui-extensions/gcpvpcpeerings/form
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- path: spec.importCustomRoutes
simple: true
name: spec.importCustomRoutes
- path: spec.peeringName
- path: spec.remotePeeringName
simple: true
name: spec.peeringName
name: spec.remotePeeringName
widget: Text
- path: spec.remoteProject
simple: true
Expand Down
4 changes: 2 additions & 2 deletions config/ui-extensions/gcpvpcpeerings/list
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- source: spec.importCustomRoutes
name: spec.importCustomRoutes
sort: true
- source: spec.peeringName
name: spec.peeringName
- source: spec.remotePeeringName
name: spec.remotePeeringName
sort: true
- source: spec.remoteProject
name: spec.remoteProject
Expand Down
2 changes: 1 addition & 1 deletion config/ui-extensions/gcpvpcpeerings/translations
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ en:
configuration: Configuration
status: Status
spec.importCustomRoutes: Import Custom Routes
spec.peeringName: Peering Name
spec.remotePeeringName: Remote Peering Name
spec.remoteProject: Remote Project
spec.remoteVpc: Remote VPC
status.id: ID
13 changes: 6 additions & 7 deletions internal/controller/cloud-control/vpcpeering_gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import (
. "github.com/kyma-project/cloud-manager/pkg/testinfra/dsl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"time"
)

var _ = Describe("Feature: KCP VpcPeering", func() {
It("Scenario: KCP GCP VpcPeering is created", func() {
const (
kymaName = "57bc9639-d752-4f67-8b9e-7cd12514575f"
peeringName = "peering-sap-gcp-skr-dev-cust-00002-to-sap-sc-learn"
remotePeeringName = "peering-sap-gcp-skr-dev-cust-00002-to-sap-sc-learn"
remoteVpc = "default"
remoteProject = "sap-sc-learn"
remoteRefNamespace = "kcp-system"
Expand All @@ -37,10 +36,10 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
By("When KCP VpcPeering is created", func() {
Eventually(CreateKcpVpcPeering).
WithArguments(infra.Ctx(), infra.KCP().Client(), vpcpeering,
WithName(peeringName),
WithName(remotePeeringName),
WithKcpVpcPeeringRemoteRef(remoteRefNamespace, remoteRefName),
WithKcpVpcPeeringSpecScope(kymaName),
WithKcpVpcPeeringSpecGCP(remoteVpc, remoteProject, peeringName, importCustomRoutes),
WithKcpVpcPeeringSpecGCP(remoteVpc, remoteProject, remotePeeringName, importCustomRoutes),
).
Should(Succeed())
})
Expand All @@ -59,13 +58,13 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
By("When KCP VpcPeering is deleted", func() {
Eventually(Delete).
WithArguments(infra.Ctx(), infra.KCP().Client(), vpcpeering).
Should(Succeed(), "deleting VpcPeering failed")
Should(Succeed(), "Error deleting VPC Peering")
})

By("Then VpcPeering does not exist", func() {
Eventually(IsDeleted, 5*time.Second).
Eventually(IsDeleted).
WithArguments(infra.Ctx(), infra.KCP().Client(), vpcpeering).
Should(Succeed(), "expected VpcPeering does not to exist (being deleted), but it still exists")
Should(Succeed(), "VPC Peering was not deleted")
})

})
Expand Down
Loading

0 comments on commit d52c95b

Please sign in to comment.