generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(GCPVpcPeering) Delete VPC Peering
- Loading branch information
1 parent
4ee1913
commit b394223
Showing
17 changed files
with
258 additions
and
37 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
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,27 @@ | ||
package vpcpeering | ||
|
||
import ( | ||
"context" | ||
"github.com/kyma-project/cloud-manager/pkg/composed" | ||
) | ||
|
||
func deleteVpcPeering(ctx context.Context, st composed.State) (error, context.Context) { | ||
state := st.(*State) | ||
obj := state.ObjAsVpcPeering() | ||
logger := composed.LoggerFromCtx(ctx) | ||
|
||
logger.Info("Deleting GCP VPC Peering " + obj.Spec.VpcPeering.Gcp.PeeringName) | ||
|
||
_, err := state.client.DeleteVpcPeering( | ||
ctx, | ||
&obj.Spec.VpcPeering.Gcp.PeeringName, | ||
&state.Scope().Spec.Scope.Gcp.Project, | ||
&state.Scope().Spec.Scope.Gcp.VpcNetwork, | ||
) | ||
|
||
if err != nil { | ||
return err, ctx | ||
} | ||
|
||
return nil, 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
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,27 @@ | ||
package vpcpeering | ||
|
||
import ( | ||
"context" | ||
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1" | ||
"github.com/kyma-project/cloud-manager/pkg/composed" | ||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
) | ||
|
||
func removeFinalizer(ctx context.Context, st composed.State) (error, context.Context) { | ||
state := st.(*State) | ||
logger := composed.LoggerFromCtx(ctx) | ||
|
||
isUpdated := controllerutil.RemoveFinalizer(state.ObjAsVpcPeering(), cloudcontrolv1beta1.FinalizerName) | ||
if !isUpdated { | ||
return nil, nil | ||
} | ||
|
||
logger.Info("Removing finalizer") | ||
|
||
err := state.UpdateObj(ctx) | ||
if err != nil { | ||
return composed.LogErrorAndReturn(err, "Error updating KCP VpcPeering after finalizer removed", composed.StopWithRequeue, ctx) | ||
} | ||
|
||
return composed.StopAndForget, 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,29 @@ | ||
package vpcpeering | ||
|
||
import ( | ||
"context" | ||
|
||
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1" | ||
"github.com/kyma-project/cloud-manager/pkg/composed" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
) | ||
|
||
func removeReadyCondition(ctx context.Context, st composed.State) (error, context.Context) { | ||
state := st.(*State) | ||
logger := composed.LoggerFromCtx(ctx) | ||
|
||
readyCondition := meta.FindStatusCondition(*state.ObjAsVpcPeering().Conditions(), cloudcontrolv1beta1.ConditionTypeReady) | ||
if readyCondition == nil { | ||
return nil, nil | ||
} | ||
|
||
logger.Info("Removing Ready condition") | ||
|
||
meta.RemoveStatusCondition(state.ObjAsVpcPeering().Conditions(), cloudcontrolv1beta1.ConditionTypeReady) | ||
err := state.UpdateObjStatus(ctx) | ||
if err != nil { | ||
return composed.LogErrorAndReturn(err, "Error updating KCP VpcPeering status after removing Ready condition", composed.StopWithRequeue, ctx) | ||
} | ||
|
||
return composed.StopWithRequeue, 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
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.