Skip to content

Make isHidden a primitive when finding v2 templates#55408

Merged
andreidan merged 2 commits intoelastic:masterfrom
andreidan:isHidden-boolean-primitive
Apr 19, 2020
Merged

Make isHidden a primitive when finding v2 templates#55408
andreidan merged 2 commits intoelastic:masterfrom
andreidan:isHidden-boolean-primitive

Conversation

@andreidan
Copy link
Copy Markdown
Contributor

isHidden was a Boolean in order to treat a special case identified
with V1 templates where if the create index request didn't specify if
the index should be hidden or not (ie. isHidden was null) but the
index matched a template that specified the index.hidden setting we
needed to remove the global templates from the templates we'll apply to
the new index (note: this is important with V1 templates as inheritance
is supported).

With V2 templates we match only one template with an index so the
equivalent check did not need to exist (we added a sanity check in
#55015 where we make sure
we don't apply an invalid global template - one that specifes the
index.hidden setting, but this is a check we make irrespective of the
user specifying or not if the index should be hidden)

This commit makes isHidden when matching V2 templates a boolean
primitive, eliminating the need for the null state to exist. Note that
some methods which use the matching V2 templates still work with a
Boolean object isHidden attribute as they are also matching the V1
templates. These methods will pass in false instead of null when
finding the V2 templates.

isHidden was a `Boolean` in order to treat a special case identified
with V1 templates where if the create index request didn't specify if
the index should be hidden or not (ie. isHidden was `null`) but the
index matched a template that specified the `index.hidden` setting we
needed to remove the global templates from the templates we'll apply to
the new index (note: this is important with V1 templates as inheritance
is supported).

With V2 templates we match only one template with an index so the
equivalent check did not need to exist (we added a sanity check in
elastic#55015 where we make sure
we don't apply an invalid global template - one that specifes the
`index.hidden` setting, but this is a check we make irrespective of the
user specifying or not if the index should be hidden)

This commit makes `isHidden` when matching V2 templates a boolean
primitive, eliminating the need for the `null` state to exist. Note that
some methods which use the matching V2 templates still work with a
`Boolean` object `isHidden` attribute as they are also matching the V1
templates. These methods will pass in `false` instead of `null` when
finding the V2 templates.
@andreidan andreidan added :Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. v8.0.0 v7.8.0 labels Apr 17, 2020
@andreidan andreidan requested a review from dakrone April 17, 2020 16:04
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

Copy link
Copy Markdown
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Andrei!

@andreidan
Copy link
Copy Markdown
Contributor Author

@elasticmachine update branch

@andreidan andreidan merged commit c5b923a into elastic:master Apr 19, 2020
andreidan added a commit to andreidan/elasticsearch that referenced this pull request Apr 19, 2020
isHidden was a `Boolean` in order to treat a special case identified
with V1 templates where if the create index request didn't specify if
the index should be hidden or not (ie. isHidden was `null`) but the
index matched a template that specified the `index.hidden` setting we
needed to remove the global templates from the templates we'll apply to
the new index (note: this is important with V1 templates as inheritance
is supported).

With V2 templates we match only one template with an index so the
equivalent check did not need to exist (we added a sanity check in
elastic#55015 where we make sure
we don't apply an invalid global template - one that specifes the
`index.hidden` setting, but this is a check we make irrespective of the
user specifying or not if the index should be hidden)

This commit makes `isHidden` when matching V2 templates a boolean
primitive, eliminating the need for the `null` state to exist. Note that
some methods which use the matching V2 templates still work with a
`Boolean` object `isHidden` attribute as they are also matching the V1
templates. These methods will pass in `false` instead of `null` when
finding the V2 templates.

(cherry picked from commit c5b923a)
Signed-off-by: Andrei Dan <andrei.dan@elastic.co>
andreidan added a commit that referenced this pull request Apr 20, 2020
isHidden was a `Boolean` in order to treat a special case identified
with V1 templates where if the create index request didn't specify if
the index should be hidden or not (ie. isHidden was `null`) but the
index matched a template that specified the `index.hidden` setting we
needed to remove the global templates from the templates we'll apply to
the new index (note: this is important with V1 templates as inheritance
is supported).

With V2 templates we match only one template with an index so the
equivalent check did not need to exist (we added a sanity check in
#55015 where we make sure
we don't apply an invalid global template - one that specifes the
`index.hidden` setting, but this is a check we make irrespective of the
user specifying or not if the index should be hidden)

This commit makes `isHidden` when matching V2 templates a boolean
primitive, eliminating the need for the `null` state to exist. Note that
some methods which use the matching V2 templates still work with a
`Boolean` object `isHidden` attribute as they are also matching the V1
templates. These methods will pass in `false` instead of `null` when
finding the V2 templates.

(cherry picked from commit c5b923a)
Signed-off-by: Andrei Dan <andrei.dan@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. >non-issue v7.8.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants