Skip to content

Commit

Permalink
feat: Add MoveAZChaos
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolaj-krzyzanowski-f3 committed Jan 10, 2025
1 parent 6a30e2e commit 729b4f4
Show file tree
Hide file tree
Showing 32 changed files with 1,919 additions and 13 deletions.
40 changes: 40 additions & 0 deletions api/v1alpha1/moveazchaos_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var (
_ InnerObject = (*MoveAZChaos)(nil)
_ InnerObjectWithSelector = (*MoveAZChaos)(nil)
)

// +kubebuilder:object:root=true
// +chaos-mesh:experiment
type MoveAZChaos struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MoveAZChaosSpec `json:"spec"`
Status MoveAZChaosStatus `json:"status"`
}

type MoveAZChaosSpec struct {
DeploymentSelectorSpec `json:"selector"`
Zone string `json:"zone"`
// Duration represents the duration of the chaos
// +optional
Duration *string `json:"duration,omitempty"`
// RemoteCluster represents the remote cluster where the chaos will be deployed
// +optional
RemoteCluster string `json:"remoteCluster,omitempty"`
}
type MoveAZChaosStatus struct {
ChaosStatus `json:",inline"`
}

func (obj *MoveAZChaos) GetSelectorSpecs() map[string]interface{} {
return map[string]interface{}{
".": &obj.Spec.DeploymentSelector,
}
}
9 changes: 9 additions & 0 deletions api/v1alpha1/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,12 @@ type NodeSelectorSpec struct {
// +optional
ExpressionSelectors LabelSelectorRequirements `json:"expressionSelectors,omitempty" swaggerignore:"true"`
}

type DeploymentSelector struct {
// Map of namespace names to a list of deployments in that namespace.
Deployments map[string][]string `json:"deployments,omitempty"`
}

type DeploymentSelectorSpec struct {
DeploymentSelector `json:",inline"`
}
153 changes: 153 additions & 0 deletions api/v1alpha1/zz_generated.chaosmesh.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions api/v1alpha1/zz_generated.chaosmesh_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 729b4f4

Please sign in to comment.