Skip to content

Commit 754e97a

Browse files
authored
Add make targets for go workspaces, gosec targets use go run instead of container, run make fix-all (#1149)
* Add make target for go.work handling, make gosec not use container. Assisted-by: Cursor:grok-4.5 Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com> * add -omitempty=false to go fix, run fix-all Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com> * run fix-all again after rebase Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com> --------- Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
1 parent d35b3c6 commit 754e97a

59 files changed

Lines changed: 233 additions & 300 deletions

File tree

Some content is hidden

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

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ __debug_bin*
99
docs/
1010
examples/
1111
deployments/
12+
go.work
13+
go.work.sum

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ apiserver.local.config/
55
*.csv
66
load_test_results.txt
77
.env
8+
go.work
9+
go.work.sum
810

911
# Development artifact path
1012
.build/

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ include make/go.mk # fmt, vet, lint, fix-headers, fix-all
7171
include make/testing.mk # test, unit, unit-clean, vulncheck, test-e2e*
7272
include make/security.mk # gosec, gosec-sarif
7373
include make/mocks.mk # generate-mocks, clean-mocks
74+
include make/work.mk # go.work, clean-work
7475

7576
.DEFAULT_GOAL := help
7677

api/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ vet: ## Run go vet against the module
2727

2828
.PHONY: fix
2929
fix: ## Run go fix against the module
30-
go fix ./...
30+
go fix -omitzero=false ./...
3131

3232
.PHONY: tidy
3333
tidy: ## Run go tidy against the module

controllers/functionconfigs/functionconfigreconciler_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ func TestFunctionConfigReconciler(t *testing.T) {
192192
t.Fatalf("unable to add configapi to scheme: %v", err)
193193
}
194194
for _, tt := range tests {
195-
tt := tt // pin for closure
196195
t.Run(tt.name, func(t *testing.T) {
197196
c := fake.NewClientBuilder().WithObjects(tt.objs...).WithScheme(scheme).WithStatusSubresource(&configapi.FunctionConfig{}).Build()
198197

@@ -468,13 +467,13 @@ func TestConcurrentAccessSafety(t *testing.T) {
468467
// Writer goroutine
469468
go func() {
470469
defer close(done)
471-
for i := 0; i < 100; i++ {
470+
for range 100 {
472471
store.UpdateExecCache(obj.Name, obj)
473472
}
474473
}()
475474

476475
// Reader goroutine (concurrent with writer)
477-
for i := 0; i < 100; i++ {
476+
for range 100 {
478477
store.GetProcessorFromCache("ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.1")
479478
}
480479

controllers/packagerevisions/integration/packagerevision_integration_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ var _ = Describe("PackageRevision Controller Integration", func() {
126126
}
127127

128128
for _, tc := range transitions {
129-
tc := tc
130129
It(fmt.Sprintf("Should transition %s -> %s and set Ready=True", tc.current, tc.desired), func() {
131130
var fetched porchv1alpha2.PackageRevision
132131
Expect(k8sClient.Get(ctx, nn, &fetched)).To(Succeed())

controllers/packagerevisions/pkg/controllers/packagerevision/mergekey.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package packagerevision
2121
import (
2222
"bytes"
2323
"fmt"
24+
"maps"
2425
"path"
2526
"strings"
2627

@@ -50,9 +51,7 @@ func ensureMergeKey(resources map[string]string) (map[string]string, error) {
5051
return nil, fmt.Errorf("failed to add merge-key directive: %w", err)
5152
}
5253

53-
for k, v := range pr.extra {
54-
result[k] = v
55-
}
54+
maps.Copy(result, pr.extra)
5655

5756
return result, nil
5857
}

controllers/packagerevisions/pkg/webhooks/packagerevision_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func (v *PackageRevisionValidator) unmarshalPackageRevision(raw []byte, fieldNam
503503
}
504504

505505
// unmarshalInto unmarshals raw bytes into a target object, handling empty and malformed data.
506-
func (v *PackageRevisionValidator) unmarshalInto(raw []byte, target interface{}, fieldName string) *admission.Response {
506+
func (v *PackageRevisionValidator) unmarshalInto(raw []byte, target any, fieldName string) *admission.Response {
507507
if len(raw) == 0 {
508508
resp := admission.Errored(http.StatusBadRequest, fmt.Errorf("%s is empty", fieldName))
509509
return &resp

controllers/packagerevisions/pkg/webhooks/packagerevision_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ func TestUnmarshalInto(t *testing.T) {
11741174
tests := []struct {
11751175
name string
11761176
raw []byte
1177-
target interface{}
1177+
target any
11781178
fieldName string
11791179
wantErr bool
11801180
errMsg string

controllers/packagevariants/pkg/controllers/packagevariant/packagevariant_controller-with-workspacename_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,11 @@ status:
784784
t.Run(tn, func(t *testing.T) {
785785
var pv api.PackageVariant
786786
require.NoError(t, yaml.Unmarshal(
787-
[]byte(fmt.Sprintf(pvStr, tc.deletionPolicy)), &pv))
787+
fmt.Appendf(nil, pvStr, tc.deletionPolicy), &pv))
788788

789789
var pr porchapi.PackageRevision
790790
require.NoError(t, yaml.Unmarshal(
791-
[]byte(fmt.Sprintf(prStr, tc.prLifecycle)), &pr))
791+
fmt.Appendf(nil, prStr, tc.prLifecycle), &pr))
792792

793793
fc := &fakeClient{}
794794
reconciler := &PackageVariantReconciler{Client: fc}
@@ -963,7 +963,7 @@ items:
963963

964964
var pv api.PackageVariant
965965
require.NoError(t, yaml.Unmarshal(
966-
[]byte(fmt.Sprintf(pvStr, tc.adoptionPolicy)), &pv))
966+
fmt.Appendf(nil, pvStr, tc.adoptionPolicy), &pv))
967967

968968
actualStr := reconciler.getDownstreamPRs(context.TODO(), &pv, &prList)
969969
var actual []string

0 commit comments

Comments
 (0)