Skip to content

Commit

Permalink
plugins/ism: add omitempty to Conditions fiels in Trasistion struct
Browse files Browse the repository at this point in the history
Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
  • Loading branch information
Jakob3xD committed Aug 30, 2024
1 parent 10f5b50 commit 20d8ddf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added

### Changed
- Adjust ISM Transition to omitempty Conditions field ([#609](https://github.com/opensearch-project/opensearch-go/pull/609))

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion plugins/ism/api_policies.go
Original file line number Diff line number Diff line change
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"`
}
17 changes: 15 additions & 2 deletions plugins/ism/api_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,29 @@ 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: "delete",
Actions: []ism.PolicyStateAction{
ism.PolicyStateAction{
Delete: &ism.PolicyStateDelete{},
},
},
},
ism.PolicyState{
Name: "transition",
Actions: []ism.PolicyStateAction{
ism.PolicyStateAction{
Close: &ism.PolicyStateClose{},
},
},
Transitions: &[]ism.PolicyStateTransition{
ism.PolicyStateTransition{
StateName: "delete",
},
},
},
},
Template: []ism.Template{
ism.Template{
Expand Down

0 comments on commit 20d8ddf

Please sign in to comment.