Skip to content

Commit 3985d75

Browse files
authored
feat(selectors): Adding selectors inside the chaosengine (#181)
* feat(selectors): Adding selectors inside the chaosengine Signed-off-by: Shubham Chaudhary <shubham.chaudhary@harness.io> * upading image tag Signed-off-by: Shubham Chaudhary <shubham.chaudhary@harness.io> Signed-off-by: Shubham Chaudhary <shubham.chaudhary@harness.io>
1 parent b3593a3 commit 3985d75

7 files changed

Lines changed: 16 additions & 36 deletions

File tree

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: push-pipeline
22
on:
33
push:
44
branches:
5-
- master
5+
- dev-3.x
66
tags-ignore:
77
- '**'
88

@@ -56,7 +56,7 @@ jobs:
5656
env:
5757
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
5858
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }}
59-
DOCKER_TAG: ci
59+
DOCKER_TAG: dev-3.x
6060
DNAME: ${{ secrets.DNAME }}
6161
DPASS: ${{ secrets.DPASS }}
6262
run: make push-chaos-runner

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
DOCKER_REGISTRY ?= docker.io
55
DOCKER_REPO ?= litmuschaos
66
DOCKER_IMAGE ?= chaos-runner
7-
DOCKER_TAG ?= ci
7+
DOCKER_TAG ?= dev-3.x
88
IS_DOCKER_INSTALLED = $(shell which docker >> /dev/null 2>&1; echo $$?)
99
HOME = $(shell echo $$HOME)
1010

bin/runner.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ func main() {
3535
log.InfoWithValues("Experiments details are as follows", logrus.Fields{
3636
"Experiments List": engineDetails.Experiments,
3737
"Engine Name": engineDetails.Name,
38-
"appLabels": engineDetails.AppLabel,
39-
"appNs": engineDetails.AppNs,
40-
"appKind": engineDetails.AppKind,
38+
"Targets": engineDetails.Targets,
4139
"Service Account Name": engineDetails.SvcAccount,
4240
"Engine Namespace": engineDetails.EngineNamespace,
4341
})

pkg/utils/environment.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ import (
1414
func (engineDetails *EngineDetails) SetEngineDetails() *EngineDetails {
1515
engineDetails.Experiments = strings.Split(os.Getenv("EXPERIMENT_LIST"), ",")
1616
engineDetails.Name = os.Getenv("CHAOSENGINE")
17-
engineDetails.AppLabel = os.Getenv("APP_LABEL")
18-
engineDetails.AppNs = os.Getenv("APP_NAMESPACE")
1917
engineDetails.EngineNamespace = os.Getenv("CHAOS_NAMESPACE")
20-
engineDetails.AppKind = os.Getenv("APP_KIND")
2118
engineDetails.SvcAccount = os.Getenv("CHAOS_SVC_ACC")
2219
engineDetails.ClientUUID = os.Getenv("CLIENT_UUID")
2320
engineDetails.AuxiliaryAppInfo = os.Getenv("AUXILIARY_APPINFO")
24-
engineDetails.AnnotationKey = os.Getenv("ANNOTATION_KEY")
25-
engineDetails.AnnotationCheck = os.Getenv("ANNOTATION_CHECK")
21+
engineDetails.Targets = os.Getenv("TARGETS")
2622
return engineDetails
2723
}
2824

@@ -40,15 +36,11 @@ func (engineDetails *EngineDetails) SetEngineUID(clients ClientSets) error {
4036
func (expDetails *ExperimentDetails) SetENV(engineDetails EngineDetails, clients ClientSets) error {
4137
// Setting envs from engine fields other than env
4238
expDetails.setEnv("CHAOSENGINE", engineDetails.Name).
43-
setEnv("APP_LABEL", engineDetails.AppLabel).
39+
setEnv("TARGETS", engineDetails.Targets).
4440
setEnv("CHAOS_NAMESPACE", engineDetails.EngineNamespace).
45-
setEnv("APP_NAMESPACE", engineDetails.AppNs).
46-
setEnv("APP_KIND", engineDetails.AppKind).
4741
setEnv("AUXILIARY_APPINFO", engineDetails.AuxiliaryAppInfo).
4842
setEnv("CHAOS_UID", engineDetails.UID).
4943
setEnv("EXPERIMENT_NAME", expDetails.Name).
50-
setEnv("ANNOTATION_KEY", engineDetails.AnnotationKey).
51-
setEnv("ANNOTATION_CHECK", engineDetails.AnnotationCheck).
5244
setEnv("LIB_IMAGE_PULL_POLICY", string(expDetails.ExpImagePullPolicy)).
5345
setEnv("TERMINATION_GRACE_PERIOD_SECONDS", strconv.Itoa(int(expDetails.TerminationGracePeriodSeconds))).
5446
setEnv("DEFAULT_HEALTH_CHECK", expDetails.DefaultHealthCheck).

pkg/utils/types.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ import (
1919
type EngineDetails struct {
2020
Name string
2121
Experiments []string
22-
AppLabel string
23-
AppNs string
22+
Targets string
2423
SvcAccount string
25-
AppKind string
2624
ClientUUID string
2725
AuxiliaryAppInfo string
2826
UID string
2927
EngineNamespace string
30-
AnnotationKey string
31-
AnnotationCheck string
3228
}
3329

3430
// ExperimentDetails is for collecting all the experiment-related details

pkg/utils/watchJob_test.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ func TestPatchChaosEngineStatus(t *testing.T) {
1919
fakeServiceAcc := "Fake Service Account"
2020
fakeAppLabel := "Fake Label"
2121
fakeAppKind := "Fake Kind"
22-
fakeAnnotationCheck := "Fake Annotation Check"
2322
expStatus := ExperimentStatus{
2423
Name: "Fake exp Name",
2524
Status: v1alpha1.ExperimentStatusRunning,
@@ -41,10 +40,9 @@ func TestPatchChaosEngineStatus(t *testing.T) {
4140
},
4241
Spec: v1alpha1.ChaosEngineSpec{
4342
ChaosServiceAccount: fakeServiceAcc,
44-
AnnotationCheck: fakeAnnotationCheck,
45-
Appinfo: v1alpha1.ApplicationParams{
46-
Applabel: fakeAppLabel,
43+
Appinfo: &v1alpha1.ApplicationParams{
4744
Appns: engineDetails.EngineNamespace,
45+
Applabel: fakeAppLabel,
4846
AppKind: fakeAppKind,
4947
},
5048
},
@@ -67,10 +65,9 @@ func TestPatchChaosEngineStatus(t *testing.T) {
6765
},
6866
Spec: v1alpha1.ChaosEngineSpec{
6967
ChaosServiceAccount: fakeServiceAcc,
70-
AnnotationCheck: fakeAnnotationCheck,
71-
Appinfo: v1alpha1.ApplicationParams{
72-
Applabel: fakeAppLabel,
68+
Appinfo: &v1alpha1.ApplicationParams{
7369
Appns: engineDetails.EngineNamespace,
70+
Applabel: fakeAppLabel,
7471
AppKind: fakeAppKind,
7572
},
7673
},
@@ -123,7 +120,6 @@ func TestUpdateEngineWithResult(t *testing.T) {
123120
fakeServiceAcc := "Fake Service Account"
124121
fakeAppLabel := "Fake Label"
125122
fakeAppKind := "Fake Kind"
126-
fakeAnnotationCheck := "Fake Annotation Check"
127123
expStatus := ExperimentStatus{
128124
Name: "Fake-Exp-Name",
129125
Status: v1alpha1.ExperimentStatusRunning,
@@ -153,10 +149,9 @@ func TestUpdateEngineWithResult(t *testing.T) {
153149
},
154150
Spec: v1alpha1.ChaosEngineSpec{
155151
ChaosServiceAccount: fakeServiceAcc,
156-
AnnotationCheck: fakeAnnotationCheck,
157-
Appinfo: v1alpha1.ApplicationParams{
158-
Applabel: fakeAppLabel,
152+
Appinfo: &v1alpha1.ApplicationParams{
159153
Appns: engineDetails.EngineNamespace,
154+
Applabel: fakeAppLabel,
160155
AppKind: fakeAppKind,
161156
},
162157
JobCleanUpPolicy: "retain",
@@ -206,10 +201,9 @@ func TestUpdateEngineWithResult(t *testing.T) {
206201
},
207202
Spec: v1alpha1.ChaosEngineSpec{
208203
ChaosServiceAccount: fakeServiceAcc,
209-
AnnotationCheck: fakeAnnotationCheck,
210-
Appinfo: v1alpha1.ApplicationParams{
211-
Applabel: fakeAppLabel,
204+
Appinfo: &v1alpha1.ApplicationParams{
212205
Appns: engineDetails.EngineNamespace,
206+
Applabel: fakeAppLabel,
213207
AppKind: fakeAppKind,
214208
},
215209
JobCleanUpPolicy: "retain",

tests/runner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ var _ = Describe("BDD on chaos-runner", func() {
190190
Namespace: "litmus",
191191
},
192192
Spec: v1alpha1.ChaosEngineSpec{
193-
Appinfo: v1alpha1.ApplicationParams{
193+
Appinfo: &v1alpha1.ApplicationParams{
194194
Appns: "litmus",
195195
Applabel: "app=nginx",
196196
AppKind: "deployment",

0 commit comments

Comments
 (0)