-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[check command] Add
--instance-filter
option (#15034)
- Loading branch information
1 parent
4647959
commit 144d511
Showing
7 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2023-present Datadog, Inc. | ||
|
||
package jsonquery | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/DataDog/datadog-agent/pkg/autodiscovery/integration" | ||
) | ||
|
||
func TestYAMLExistQuery(t *testing.T) { | ||
exist, err := YAMLCheckExist(integration.Data("{\"ip_address\": \"127.0.0.50\"}"), ".ip_address == \"127.0.0.50\"") | ||
assert.NoError(t, err) | ||
assert.True(t, exist) | ||
|
||
exist, err = YAMLCheckExist(integration.Data("{\"ip_address\": \"127.0.0.50\"}"), ".ip_address == \"127.0.0.99\"") | ||
assert.NoError(t, err) | ||
assert.False(t, exist) | ||
|
||
exist, err = YAMLCheckExist(integration.Data("{\"ip_address\": \"127.0.0.50\"}"), ".ip_address") | ||
assert.EqualError(t, err, "filter query must return a boolean: yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `127.0.0.50` into bool") | ||
assert.False(t, exist) | ||
|
||
exist, err = YAMLCheckExist(integration.Data("{}"), ".ip_address == \"127.0.0.99\"") | ||
assert.NoError(t, err) | ||
assert.False(t, exist) | ||
} |
11 changes: 11 additions & 0 deletions
11
releasenotes/notes/add_instance_filter_to_agent_check_command-c166bec4ff8ebf96.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Each section from every release note are combined when the | ||
# CHANGELOG.rst is rendered. So the text needs to be worded so that | ||
# it does not depend on any information only available in another | ||
# section. This may mean repeating some details, but each section | ||
# must be readable independently of the other. | ||
# | ||
# Each section note must be formatted as reStructuredText. | ||
--- | ||
enhancements: | ||
- | | ||
Add an ``--instance-filter`` option to the Agent check command. |