Skip to content

Commit 95e3577

Browse files
Merge pull request #172 from SaschaSchwarze0/sascha-updates
Update dependencies and other things
2 parents 7403482 + b4e218a commit 95e3577

File tree

218 files changed

+4749
-8778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+4749
-8778
lines changed

.github/actions/setup/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
go-version:
66
description: "The Go version to download (if necessary) and use. Supports semver spec and ranges. Be sure to enclose this option in single quotation marks."
77
required: false
8-
default: "1.22.x"
8+
default: "1.24.x"
99
runs:
1010
using: composite
1111
steps:

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ jobs:
2727
TAG: ${{ github.event.inputs.release }}
2828

2929
steps:
30-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@v6
3131
with:
3232
ref: ${{ github.event.inputs.git-ref }}
3333
- uses: ./.github/actions/setup
3434
- uses: sigstore/cosign-installer@v3
35-
- uses: azure/setup-helm@v3.5
35+
- uses: azure/setup-helm@v4
3636
with:
37-
version: v3.8.0
37+
version: v3.19.2
3838

3939
- name: Build Release Changelog
4040
env:

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout Code
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v6
2323
- uses: ./.github/actions/setup
2424
- name: Run gosec
2525
uses: securego/gosec@master

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: unit
1717
steps:
1818
- name: Checkout Code
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v6
2020
- uses: ./.github/actions/setup
2121
- name: test-unit
2222
run: make test-unit
@@ -25,7 +25,7 @@ jobs:
2525
name: integration
2626
steps:
2727
- name: Checkout Code
28-
uses: actions/checkout@v4
28+
uses: actions/checkout@v6
2929
- uses: ./.github/actions/setup
3030
- name: test-integration
3131
run: make test-integration
@@ -35,7 +35,7 @@ jobs:
3535
# runs-on: ubuntu-latest
3636
# steps:
3737
# - name: Checkout Code
38-
# uses: actions/checkout@v4
38+
# uses: actions/checkout@v6
3939
# - uses: ./.github/actions/setup
4040
# - uses: ./.github/actions/shipwright
4141

.github/workflows/verify.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
name: generate
2020
steps:
2121
- name: Checkout Code
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v6
2323

2424
- uses: ./.github/actions/setup
2525

@@ -32,8 +32,8 @@ jobs:
3232
name: golangci-lint
3333
steps:
3434
- name: Checkout Code
35-
uses: actions/checkout@v4
35+
uses: actions/checkout@v6
3636
- name: golangci-lint
37-
uses: golangci/golangci-lint-action@v6
37+
uses: golangci/golangci-lint-action@v9
3838
with:
3939
args: --timeout=10m

.golangci.yaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1+
version: "2"
12
linters:
23
enable:
4+
- contextcheck
35
- errcheck
4-
- gosimple
6+
- goconst
7+
- gosec
58
- govet
69
- ineffassign
10+
- misspell
711
- staticcheck
812
- unused
9-
- contextcheck
10-
- goconst
13+
exclusions:
14+
generated: lax
15+
presets:
16+
- comments
17+
- common-false-positives
18+
- legacy
19+
- std-error-handling
20+
paths:
21+
- third_party$
22+
- builtin$
23+
- examples$
24+
formatters:
25+
enable:
1126
- gofmt
12-
- misspell
27+
exclusions:
28+
generated: lax
29+
paths:
30+
- third_party$
31+
- builtin$
32+
- examples$

controllers/customrun_controller.go

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type CustomRunReconciler struct {
4545
// generateBuildRun generates a BuildRun instance owned by the informed Tekton CustomRun object, the
4646
// BuildRun name is randomly generated using the Run's name as base.
4747
func (r *CustomRunReconciler) generateBuildRun(
48-
ctx context.Context,
48+
logger logr.Logger,
4949
customRun *tektonapibeta.CustomRun,
5050
) (*buildapi.BuildRun, error) {
5151
br := buildapi.BuildRun{
@@ -64,6 +64,35 @@ func (r *CustomRunReconciler) generateBuildRun(
6464
Timeout: customRun.Spec.Timeout,
6565
},
6666
}
67+
68+
for _, workspaceBinding := range customRun.Spec.Workspaces {
69+
if workspaceBinding.Name == "shp-source" {
70+
br.Annotations = map[string]string{
71+
"source-workspace": "shp-source",
72+
}
73+
74+
// TODO use subPath as context directory
75+
} else {
76+
if workspaceBinding.SubPath != "" {
77+
// TODO should we fail ?
78+
logger.Info("SubPath is ignored", "namespace", customRun.Namespace, "name", customRun.Name, "workspace", workspaceBinding.SubPath)
79+
}
80+
81+
br.Spec.Volumes = append(br.Spec.Volumes, buildapi.BuildVolume{
82+
Name: workspaceBinding.Name,
83+
VolumeSource: corev1.VolumeSource{
84+
ConfigMap: workspaceBinding.ConfigMap,
85+
CSI: workspaceBinding.CSI,
86+
EmptyDir: workspaceBinding.EmptyDir,
87+
PersistentVolumeClaim: workspaceBinding.PersistentVolumeClaim,
88+
Projected: workspaceBinding.Projected,
89+
Secret: workspaceBinding.Secret,
90+
},
91+
})
92+
}
93+
94+
}
95+
6796
err := controllerutil.SetControllerReference(customRun, &br, r.Scheme)
6897
if err != nil {
6998
return nil, err
@@ -126,8 +155,8 @@ func (r *CustomRunReconciler) Reconcile(
126155
) (ctrl.Result, error) {
127156
logger := log.FromContext(ctx)
128157

129-
var customRun tektonapibeta.CustomRun
130-
err := r.Get(ctx, req.NamespacedName, &customRun)
158+
customRun := &tektonapibeta.CustomRun{}
159+
err := r.Get(ctx, req.NamespacedName, customRun)
131160
if err != nil {
132161
if !errors.IsNotFound(err) {
133162
logger.Error(err, "Unable to fetch Run")
@@ -162,7 +191,7 @@ func (r *CustomRunReconciler) Reconcile(
162191
return Done()
163192
}
164193

165-
if br, err = r.generateBuildRun(ctx, &customRun); err != nil {
194+
if br, err = r.generateBuildRun(logger, customRun); err != nil {
166195
logger.V(0).Error(err, "Issuing BuildRun returned error")
167196
return RequeueOnError(err)
168197
}
@@ -178,13 +207,13 @@ func (r *CustomRunReconciler) Reconcile(
178207
customRun.Status.StartTime = &now
179208

180209
// storing the ExtraFields on the Tekton Run instance status
181-
if err = r.Client.Status().Patch(ctx, &customRun, client.MergeFrom(originalCustomRun)); err != nil {
210+
if err = r.Client.Status().Patch(ctx, customRun, client.MergeFrom(originalCustomRun)); err != nil {
182211
logger.V(0).Error(err, "trying to patch Tekton CustomRun status")
183212
return RequeueOnError(err)
184213
}
185214
logger.V(0).Info("Tekton CustomRun Status ExtraFields updated with BuildRun coordinates")
186215

187-
if err = r.Client.Create(ctx, br); err != nil {
216+
if err = r.Create(ctx, br); err != nil {
188217
logger.V(0).Error(err, "Trying to create a new BuildRun instance")
189218
return RequeueOnError(err)
190219
}
@@ -194,7 +223,7 @@ func (r *CustomRunReconciler) Reconcile(
194223
logger.V(0).Info("Retrieving BuildRun instance...")
195224
// when the meta-information is populated, we need to extract the BuildRun name and retrieve
196225
// the object
197-
if err = r.Client.Get(ctx, extraFields.GetNamespacedName(), br); err != nil {
226+
if err = r.Get(ctx, extraFields.GetNamespacedName(), br); err != nil {
198227
logger.V(0).Error(err, "Trying to retrieve BuildRun instance")
199228
return RequeueOnError(err)
200229
}
@@ -204,16 +233,16 @@ func (r *CustomRunReconciler) Reconcile(
204233

205234
originalBr := br.DeepCopy()
206235
br.Spec.State = buildapi.BuildRunRequestedStatePtr(buildapi.BuildRunStateCancel)
207-
if err = r.Client.Patch(ctx, br, client.MergeFrom(originalBr)); err != nil {
236+
if err = r.Patch(ctx, br, client.MergeFrom(originalBr)); err != nil {
208237
logger.V(0).Error(err, "trying to patch BuildRun with cancellation state")
209238
return RequeueOnError(err)
210239
}
211240
} else {
212241
// reflecting BuildRuns' status conditions on the Tekton Run owner instance
213-
r.reflectBuildRunStatusOnTektonCustomRun(logger, &customRun, br)
242+
r.reflectBuildRunStatusOnTektonCustomRun(logger, customRun, br)
214243

215244
logger.V(0).Info("Updating Tekton CustomRun instance status...")
216-
if err = r.Client.Status().Patch(ctx, &customRun, client.MergeFrom(originalCustomRun)); err != nil {
245+
if err = r.Client.Status().Patch(ctx, customRun, client.MergeFrom(originalCustomRun)); err != nil {
217246
logger.V(0).Error(err, "trying to patch Tekton CustomRun status")
218247
return RequeueOnError(err)
219248
}

controllers/inventory_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (r *InventoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
4141
return RequeueOnError(client.IgnoreNotFound(err))
4242
}
4343

44-
if b.ObjectMeta.DeletionTimestamp.IsZero() {
44+
if b.DeletionTimestamp.IsZero() {
4545
logger.V(0).Info("Adding Build on the Inventory")
4646
r.buildInventory.Add(&b)
4747
} else {

controllers/pipelinerun_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (r *PipelineRunReconciler) createBuildRun(
6565
},
6666
},
6767
}
68-
if err := r.Client.Create(ctx, &br); err != nil {
68+
if err := r.Create(ctx, &br); err != nil {
6969
return "", err
7070
}
7171
return br.GetName(), nil
@@ -111,7 +111,7 @@ func (r *PipelineRunReconciler) Reconcile(
111111

112112
// creating a objectRef based on the informed PipelineRun, the instance is informed to the
113113
// inventory query interface to list Shipwright Builds that should be triggered
114-
objectRef, err := filter.PipelineRunToObjectRef(ctx, r.Clock.Now(), &pipelineRun)
114+
objectRef, err := filter.PipelineRunToObjectRef(ctx, r.Now(), &pipelineRun)
115115
if err != nil {
116116
return ctrl.Result{}, err
117117
}
@@ -183,7 +183,7 @@ func (r *PipelineRunReconciler) Reconcile(
183183
filter.PipelineRunAnnotateName(&pipelineRun)
184184

185185
// patching the PipelineRun to reflect labels and annotations needed on the object
186-
if err = r.Client.Patch(ctx, &pipelineRun, client.MergeFrom(originalPipelineRun)); err != nil {
186+
if err = r.Patch(ctx, &pipelineRun, client.MergeFrom(originalPipelineRun)); err != nil {
187187
logger.V(0).Error(err, "trying to update PipelineRun metadata")
188188
return RequeueOnError(err)
189189
}

controllers/result.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ func Done() (ctrl.Result, error) {
1313
}
1414

1515
func RequeueOnError(err error) (ctrl.Result, error) {
16-
requeue := true
17-
if err == nil {
18-
requeue = false
19-
}
20-
return ctrl.Result{Requeue: requeue}, err
16+
return ctrl.Result{Requeue: err != nil}, err
2117
}

0 commit comments

Comments
 (0)