Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ISM issues #609

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Removed

### Fixed
- Fix ISM Transition to omitempty Conditions field ([#609](https://github.com/opensearch-project/opensearch-go/pull/609))
- Fix ISM Allocation field types ([#609](https://github.com/opensearch-project/opensearch-go/pull/609))

### Security

Expand Down
10 changes: 5 additions & 5 deletions plugins/ism/api_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ type PolicyStateIndexPriority struct {

// PolicyStateAllocation represents the allocation action
type PolicyStateAllocation struct {
Require string `json:"require,omitempty"`
Include string `json:"include,omitempty"`
Exclude string `json:"exclude,omitempty"`
WaitFor string `json:"wait_for,omitempty"`
Require map[string]string `json:"require,omitempty"`
Include map[string]string `json:"include,omitempty"`
Exclude map[string]string `json:"exclude,omitempty"`
WaitFor *bool `json:"wait_for,omitempty"`
}

// PolicyStateRollup represents the rollup action
Expand Down Expand Up @@ -264,5 +264,5 @@ type PolicyStateTransitionConditionCron struct {
// PolicyStateTransition is a sub type of PolicyState containing information about transition to other states
type PolicyStateTransition struct {
StateName string `json:"state_name"`
Conditions *PolicyStateTransitionCondition `json:"conditions"`
Conditions *PolicyStateTransitionCondition `json:"conditions,omitempty"`
}
35 changes: 33 additions & 2 deletions plugins/ism/api_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,41 @@ func TestPoliciesClient(t *testing.T) {
Source: "The index {{ctx.index}} failed during policy execution.",
},
},
DefaultState: "test",
DefaultState: "transition",
States: []ism.PolicyState{
ism.PolicyState{
Name: "test",
Name: "allocation",
Actions: []ism.PolicyStateAction{
ism.PolicyStateAction{
Allocation: &ism.PolicyStateAllocation{
Require: map[string]string{"temp": "warm"},
Include: map[string]string{"test": "warm"},
Exclude: map[string]string{"test2": "warm"},
WaitFor: opensearch.ToPointer(true),
},
},
},
Transitions: &[]ism.PolicyStateTransition{
ism.PolicyStateTransition{
StateName: "transition",
},
},
},
ism.PolicyState{
Name: "transition",
Actions: []ism.PolicyStateAction{
ism.PolicyStateAction{
Close: &ism.PolicyStateClose{},
},
},
Transitions: &[]ism.PolicyStateTransition{
ism.PolicyStateTransition{
StateName: "delete",
},
},
},
ism.PolicyState{
Name: "delete",
Actions: []ism.PolicyStateAction{
ism.PolicyStateAction{
Delete: &ism.PolicyStateDelete{},
Expand Down
Loading