Skip to content

Commit

Permalink
Fix ISM issues (#609)
Browse files Browse the repository at this point in the history
* plugins/ism: add omitempty to Conditions fiels in Trasistion struct

Signed-off-by: Jakob Hahn <[email protected]>

* plugins/ism: fix allocaation field types

Signed-off-by: Jakob Hahn <[email protected]>

---------

Signed-off-by: Jakob Hahn <[email protected]>
  • Loading branch information
Jakob3xD authored Aug 30, 2024
1 parent 10f5b50 commit 45c6c6d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
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

0 comments on commit 45c6c6d

Please sign in to comment.