forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add labels on Application's k8s events (argoproj#11381) (argopr…
…oj#18160) * Add labels on Application's k8s events Signed-off-by: Siddhesh Ghadi <[email protected]> * Fix typo Signed-off-by: Siddhesh Ghadi <[email protected]> * Add new cm keys & doc Signed-off-by: Siddhesh Ghadi <[email protected]> * Fix typo Signed-off-by: Siddhesh Ghadi <[email protected]> * correct rebase changes Signed-off-by: Siddhesh Ghadi <[email protected]> * Fix linting Signed-off-by: Siddhesh Ghadi <[email protected]> --------- Signed-off-by: Siddhesh Ghadi <[email protected]>
- Loading branch information
Showing
11 changed files
with
344 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
. "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" | ||
. "github.com/argoproj/argo-cd/v2/test/e2e/fixture" | ||
. "github.com/argoproj/argo-cd/v2/test/e2e/fixture/app" | ||
) | ||
|
||
// resource.includeEventLabelKeys keys set in argocd-cm | ||
func TestLabelsOnAppK8sEvents(t *testing.T) { | ||
expectedLabels := map[string]string{"app": "test", "environment": "dev"} | ||
|
||
Given(t). | ||
Timeout(60). | ||
Path("two-nice-pods"). | ||
When(). | ||
SetParamInSettingConfigMap("resource.includeEventLabelKeys", "app,team,env*"). | ||
SetParamInSettingConfigMap("resource.excludeEventLabelKeys", "team"). | ||
CreateApp("--label=app=test", "--label=environment=dev", "--label=team=A", "--label=tier=ui"). | ||
Sync(). | ||
Then(). | ||
Expect(SyncStatusIs(SyncStatusCodeSynced)). | ||
And(func(app *Application) { | ||
events, err := KubeClientset.CoreV1().Events(app.Namespace).List(context.Background(), metav1.ListOptions{ | ||
FieldSelector: fmt.Sprintf("involvedObject.name=%s,involvedObject.kind=Application", app.Name), | ||
}) | ||
assert.NoError(t, err) | ||
for _, event := range events.Items { | ||
for k, v := range event.Labels { | ||
ev, found := expectedLabels[k] | ||
assert.True(t, found) | ||
assert.Equal(t, ev, v) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
// resource.includeEventLabelKeys keys not set in argocd-cm | ||
func TestNoLabelsOnAppK8sEvents(t *testing.T) { | ||
Given(t). | ||
Timeout(60). | ||
Path("two-nice-pods"). | ||
When(). | ||
CreateApp("--label=app=test", "--label=environment=dev", "--label=team=A", "--label=tier=ui"). | ||
Sync(). | ||
Then(). | ||
Expect(SyncStatusIs(SyncStatusCodeSynced)). | ||
And(func(app *Application) { | ||
events, err := KubeClientset.CoreV1().Events(app.Namespace).List(context.Background(), metav1.ListOptions{ | ||
FieldSelector: fmt.Sprintf("involvedObject.name=%s,involvedObject.kind=Application", app.Name), | ||
}) | ||
assert.NoError(t, err) | ||
for _, event := range events.Items { | ||
assert.Nil(t, event.Labels) | ||
} | ||
}) | ||
} |
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
Oops, something went wrong.