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(RedisCluster): add azure boilerplate
- Loading branch information
1 parent
6c965bd
commit 9fd67e0
Showing
4 changed files
with
92 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package rediscluster | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/kyma-project/cloud-manager/pkg/common/actions" | ||
"github.com/kyma-project/cloud-manager/pkg/kcp/rediscluster/types" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1" | ||
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1" | ||
"github.com/kyma-project/cloud-manager/pkg/composed" | ||
) | ||
|
||
func New(stateFactory StateFactory) composed.Action { | ||
return func(ctx context.Context, st composed.State) (error, context.Context) { | ||
|
||
state, err := stateFactory.NewState(ctx, st.(types.State)) | ||
if err != nil { | ||
composed.LoggerFromCtx(ctx).Error(err, "Failed to bootstrap Azure RedisCluster state") | ||
redisCluster := st.Obj().(*v1beta1.RedisCluster) | ||
redisCluster.Status.State = cloudcontrolv1beta1.StateError | ||
return composed.UpdateStatus(redisCluster). | ||
SetExclusiveConditions(metav1.Condition{ | ||
Type: v1beta1.ConditionTypeError, | ||
Status: metav1.ConditionTrue, | ||
Reason: v1beta1.ReasonCloudProviderError, | ||
Message: "Failed to create RedisCluster state", | ||
}). | ||
SuccessError(composed.StopAndForget). | ||
SuccessLogMsg(fmt.Sprintf("Error creating new Azure RedisCluster state: %s", err)). | ||
Run(ctx, st) | ||
} | ||
|
||
return composed.ComposeActions( | ||
"redisCluster", | ||
actions.AddFinalizer, | ||
Check failure on line 38 in pkg/kcp/provider/azure/rediscluster/new.go
|
||
composed.IfElse(composed.Not(composed.MarkedForDeletionPredicate), | ||
composed.ComposeActions( | ||
"redisCluster-create", | ||
), | ||
composed.ComposeActions( | ||
"redisCluster-delete", | ||
actions.RemoveFinalizer, | ||
Check failure on line 45 in pkg/kcp/provider/azure/rediscluster/new.go
|
||
), | ||
), | ||
composed.StopAndForgetAction, | ||
)(ctx, state) | ||
} | ||
} |
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,32 @@ | ||
package rediscluster | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/kyma-project/cloud-manager/pkg/kcp/rediscluster/types" | ||
) | ||
|
||
type State struct { | ||
types.State | ||
} | ||
|
||
type StateFactory interface { | ||
NewState(ctx context.Context, redisClusterState types.State) (*State, error) | ||
} | ||
|
||
type stateFactory struct{} | ||
|
||
func NewStateFactory() StateFactory { | ||
return &stateFactory{} | ||
} | ||
|
||
func (statefactory *stateFactory) NewState(ctx context.Context, redisClusterState types.State) (*State, error) { | ||
|
||
return newState(redisClusterState), nil | ||
} | ||
|
||
func newState(redisClusterState types.State) *State { | ||
return &State{ | ||
State: redisClusterState, | ||
} | ||
} |
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