Skip to content

Commit 2f14293

Browse files
Integrate druidctl into CI pipeline (#1316)
1 parent 7e7b3d7 commit 2f14293

11 files changed

Lines changed: 31 additions & 14 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ updates:
1313
- "/"
1414
- "/api"
1515
- "/client"
16+
- "/druidctl"
1617
schedule:
1718
interval: monthly
1819
open-pull-requests-limit: 5

.github/workflows/base.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ jobs:
111111
git config --global user.email "gardener@sap.com"
112112
git config --global user.name "Gardener CI/CD"
113113
make --directory=api check-generate
114+
- name: druidctl-tidy
115+
run: make --directory=druidctl tidy
116+
- name: druidctl-check
117+
run: make --directory=druidctl check
114118
- name: prepare helm charts
115119
run: make prepare-helm-charts
116120
env:
@@ -129,6 +133,8 @@ jobs:
129133
args:
130134
- name: api-test-unit
131135
run: make --directory=api test-unit
136+
- name: druidctl-test-unit
137+
run: make --directory=druidctl test
132138
- name: test-unit
133139
run: make test-unit
134140
- name: test-integration
@@ -169,5 +175,7 @@ jobs:
169175
- prepare
170176
with:
171177
linter: gosec
172-
run: make sast-report
178+
run: |
179+
make sast-report
180+
make --directory=druidctl sast-report
173181
go-version: '1.25'

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ ci-checks:
9090
@$(MAKE) --directory=api tidy
9191
@$(MAKE) --directory=api check
9292
@$(MAKE) --directory=api check-generate
93+
@$(MAKE) --directory=druidctl tidy
94+
@$(MAKE) --directory=druidctl check
9395
@$(MAKE) ci-prepare-helm-charts
9496
@$(MAKE) check-git-status
9597

druidctl/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ sast: $(GOSEC)
8080
@echo "> Running gosec for druidctl module"
8181
@$(GOSEC) -exclude-generated ./...
8282

83+
.PHONY: sast-report
84+
sast-report: $(GOSEC)
85+
@echo "> Running gosec report for druidctl module"
86+
@$(GOSEC) -exclude-generated -track-suppressions -fmt=sarif -out=gosec-report.sarif -stdout ./...
87+
8388
.PHONY: clean clean-all
8489
clean:
8590
rm -rf $(BIN_DIR) coverage.out

druidctl/cmd/listresources/listresources.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ func (l *listResourcesCmdCtx) complete() error {
4747
}
4848

4949
// Build etcd reference list from resource args using kubectl-compatible parsing
50-
l.etcdRefList = l.GlobalOptions.BuildEtcdRefList()
50+
l.etcdRefList = l.BuildEtcdRefList()
5151
return nil
5252
}
5353

5454
func (l *listResourcesCmdCtx) validate() error {
55-
return l.GlobalOptions.ValidateResourceSelection()
55+
return l.ValidateResourceSelection()
5656
}
5757

5858
// execute lists the managed resources for the selected etcd resources based on the filter.

druidctl/cmd/reconciliation/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Use subcommands 'trigger', 'suspend', and 'resume' to control reconciliation sta
8080
func NewTriggerCommand(cmdCtx *cmdutils.CommandContext) *cobra.Command {
8181
var waitTillReady bool
8282
var watch bool
83-
var timeout time.Duration = defaultTimeout
83+
var timeout = defaultTimeout
8484

8585
cmd := &cobra.Command{
8686
Use: "trigger [resources] [flags]",

druidctl/cmd/reconciliation/reconcile.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ func (r *reconcileCmdCtx) complete() error {
2929
return fmt.Errorf("unable to create etcd client: %w", err)
3030
}
3131
r.etcdClient = etcdClient
32-
r.etcdRefList = r.GlobalOptions.BuildEtcdRefList()
32+
r.etcdRefList = r.BuildEtcdRefList()
3333
return nil
3434
}
3535

3636
func (r *reconcileCmdCtx) validate() error {
37-
if err := r.GlobalOptions.ValidateResourceSelection(); err != nil {
37+
if err := r.ValidateResourceSelection(); err != nil {
3838
return err
3939
}
4040
// timeout is only valid if wait-till-ready is set
@@ -47,6 +47,7 @@ func (r *reconcileCmdCtx) validate() error {
4747
}
4848
return nil
4949
}
50+
5051
// There are two types of reconciles, one where you add the reconcile annotation and exit.
5152
// Another where you wait till all the changes done to the Etcd resource have successfully reconciled and post reconciliation
5253
// all the etcd cluster members are Ready

druidctl/cmd/reconciliation/resumeetcdreconcile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ func (r *resumeReconcileCmdCtx) complete() error {
2626
return fmt.Errorf("unable to create etcd client: %w", err)
2727
}
2828
r.etcdClient = etcdClient
29-
r.etcdRefList = r.GlobalOptions.BuildEtcdRefList()
29+
r.etcdRefList = r.BuildEtcdRefList()
3030
return nil
3131
}
3232

3333
func (r *resumeReconcileCmdCtx) validate() error {
34-
return r.GlobalOptions.ValidateResourceSelection()
34+
return r.ValidateResourceSelection()
3535
}
3636

3737
// execute removes the suspend reconcile annotation from the Etcd resource.

druidctl/cmd/reconciliation/suspendetcdreconcile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ func (s *suspendReconcileCmdCtx) complete() error {
2626
return fmt.Errorf("unable to create etcd client: %w", err)
2727
}
2828
s.etcdClient = etcdClient
29-
s.etcdRefList = s.GlobalOptions.BuildEtcdRefList()
29+
s.etcdRefList = s.BuildEtcdRefList()
3030
return nil
3131
}
3232

3333
func (s *suspendReconcileCmdCtx) validate() error {
34-
return s.GlobalOptions.ValidateResourceSelection()
34+
return s.ValidateResourceSelection()
3535
}
3636

3737
// execute adds the suspend reconcile annotation to the Etcd resource.

druidctl/cmd/resourceprotection/etcdprotection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ func (r *resourceProtectionCmdCtx) complete() error {
2020
return fmt.Errorf("unable to create etcd client: %w", err)
2121
}
2222
r.etcdClient = etcdClient
23-
r.etcdRefList = r.GlobalOptions.BuildEtcdRefList()
23+
r.etcdRefList = r.BuildEtcdRefList()
2424
return nil
2525
}
2626

2727
func (r *resourceProtectionCmdCtx) validate() error {
28-
return r.GlobalOptions.ValidateResourceSelection()
28+
return r.ValidateResourceSelection()
2929
}
3030

3131
// addDisableProtectionAnnotation adds the disable protection annotation to the Etcd resource. It makes the resources vulnerable

0 commit comments

Comments
 (0)