Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "2"
linters:
default: standard
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linters.default configuration value "standard" is not a valid option in golangci-lint. The valid options for enabling linters are typically "enable", "disable", "enable-all", or "disable-all". This will likely cause configuration errors.

Suggested change
default: standard
default: enable

Copilot uses AI. Check for mistakes.
enable:
- unparam

formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'

Comment on lines +7 to +16
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration file specifies version "2" which corresponds to golangci-lint 2.x. However, the structure and syntax used in this file don't match the actual golangci-lint v2.x configuration format. The formatters section and its structure do not exist in golangci-lint. The correct structure should use linters-settings for configuring individual linters. This configuration may not work as intended.

Suggested change
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'

Copilot uses AI. Check for mistakes.
issues:
max-same-issues: 100

exclude-files:
- generated.*\\.go

exclude-dirs:
- vendor

run:
timeout: 10m
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ lint: $(BUILD_DIRS)
--env GO111MODULE=on \
--env GOFLAGS="-mod=vendor" \
$(BUILD_IMAGE) \
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=10m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default --exclude-dirs=client,vendor
golangci-lint run

$(BUILD_DIRS):
@mkdir -p $@
Expand Down
20 changes: 9 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module stash.appscode.dev/stash

go 1.23.0

toolchain go1.24.4
go 1.25.5

require (
github.com/go-sql-driver/mysql v1.8.1
Expand All @@ -17,7 +15,7 @@ require (
go.bytebuilders.dev/license-proxyserver v0.0.20
go.bytebuilders.dev/license-verifier v0.14.6
go.bytebuilders.dev/license-verifier/kubernetes v0.14.6
golang.org/x/text v0.23.0
golang.org/x/text v0.31.0
gomodules.xyz/blobfs v0.1.14
gomodules.xyz/cert v1.6.0
gomodules.xyz/encoding v0.0.8
Expand Down Expand Up @@ -47,7 +45,7 @@ require (
kmodules.xyz/prober v0.29.0
kmodules.xyz/webhook-runtime v0.29.1
sigs.k8s.io/controller-runtime v0.18.4
stash.appscode.dev/apimachinery v0.42.0
stash.appscode.dev/apimachinery v0.42.1-0.20251212062910-cc7cccc43100
)

require (
Expand Down Expand Up @@ -186,15 +184,15 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
gocloud.dev v0.26.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
golang.org/x/tools v0.38.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f // indirect
gomodules.xyz/counter v0.0.1 // indirect
Expand Down
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -1060,8 +1060,8 @@ golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1096,8 +1096,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1177,16 +1177,16 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1198,8 +1198,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1271,8 +1271,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down Expand Up @@ -1619,7 +1619,7 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+s
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
stash.appscode.dev/apimachinery v0.42.0 h1:tqGAhAbII/WoYxM4LyQW+Hc6jgjRgBYUcI3AORwBLYs=
stash.appscode.dev/apimachinery v0.42.0/go.mod h1:Q7iqhJAS0n7IV545NxaYNE5C31bBrWklZj7SfjOyryc=
stash.appscode.dev/apimachinery v0.42.1-0.20251212062910-cc7cccc43100 h1:Y3Y70xEQc+/TtMEt8IW/VY7Iz1cNRfSc5+CcZGgKUK4=
stash.appscode.dev/apimachinery v0.42.1-0.20251212062910-cc7cccc43100/go.mod h1:uxzHr2lfPtGuryxTwjvcS9H8A9WCMyUr6+0dQYJiTIA=
x-helm.dev/apimachinery v0.0.16 h1:Eb160xcdH9fMVHak5QSWYWxoaReytch+A7kk25QWjx0=
x-helm.dev/apimachinery v0.0.16/go.mod h1:05brgFw5oWOX7OTXT090SQojqXjbttqWfqoJo+ejBU4=
4 changes: 2 additions & 2 deletions hack/gendocs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func main() {
filePrepender := func(filename string) string {
filename = filepath.Base(filename)
base := strings.TrimSuffix(filename, path.Ext(filename))
name := cases.Title(language.English).String(strings.Replace(base, "_", " ", -1))
name := cases.Title(language.English).String(strings.ReplaceAll(base, "_", " "))
parts := strings.Split(name, " ")
if len(parts) > 1 {
name = strings.Join(parts[1:], " ")
Expand All @@ -97,7 +97,7 @@ func main() {
Name string
RootCmd bool
}{
strings.Replace(base, "_", "-", -1),
strings.ReplaceAll(base, "_", "-"),
name,
!strings.ContainsRune(base, '_'),
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/backup/backupsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ func (c *BackupSessionController) initBackupSessionWatcher() error {
c.bsInformer = c.StashInformerFactory.Stash().V1beta1().BackupSessions().Informer()
c.bsQueue = queue.New(api_v1beta1.ResourceKindBackupSession, c.MaxNumRequeues, c.NumThreads, c.processBackupSession)
_, _ = c.bsInformer.AddEventHandler(queue.NewFilteredHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
AddFunc: func(obj any) {
if backupsession, ok := obj.(*api_v1beta1.BackupSession); ok && c.selectedByLabels(backupsession) {
queue.Enqueue(c.bsQueue.GetQueue(), backupsession)
}
},
UpdateFunc: func(oldObj, newObj interface{}) {
UpdateFunc: func(oldObj, newObj any) {
oldBS, ok := oldObj.(*api_v1beta1.BackupSession)
if !ok {
klog.Errorf("Invalid BackupSession Object")
Expand Down
14 changes: 7 additions & 7 deletions pkg/controller/backup_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (c *StashController) NewBackupConfigurationWebhook() hooks.AdmissionHook {
UpdateFunc: func(oldObj, newObj runtime.Object) (runtime.Object, error) {
newBc := newObj.(*api_v1beta1.BackupConfiguration)

if newBc.ObjectMeta.DeletionTimestamp != nil {
if newBc.DeletionTimestamp != nil {
return nil, nil
}

Expand Down Expand Up @@ -116,7 +116,7 @@ func (c *StashController) initBackupConfigurationWatcher() {
if c.auditor != nil {
c.auditor.ForGVK(c.bcInformer, api_v1beta1.SchemeGroupVersion.WithKind(api_v1beta1.ResourceKindBackupConfiguration))
}
_, _ = c.bcInformer.AddEventHandler(queue.NewEventHandler(c.bcQueue.GetQueue(), func(oldObj, newObj interface{}) bool {
_, _ = c.bcInformer.AddEventHandler(queue.NewEventHandler(c.bcQueue.GetQueue(), func(oldObj, newObj any) bool {
bc := newObj.(*api_v1beta1.BackupConfiguration)
desiredPhase := invoker.CalculateBackupInvokerPhase(bc.Spec.Driver, bc.Status.Conditions)
return bc.GetDeletionTimestamp() != nil ||
Expand Down Expand Up @@ -428,7 +428,7 @@ func (r *backupInvokerReconciler) validateDriverRequirements() (bool, error) {
return false, nil
}

func (c *StashController) checkForResticSnapshotterRequirements(logger klog.Logger, inv interface{}, r repoReferenceHandler) (bool, error) {
func (c *StashController) checkForResticSnapshotterRequirements(logger klog.Logger, inv any, r repoReferenceHandler) (bool, error) {
repository, err := c.checkForRepositoryExistence(inv, r)
if err != nil {
return false, err
Expand Down Expand Up @@ -463,12 +463,12 @@ func (c *StashController) checkForResticSnapshotterRequirements(logger klog.Logg
return false, conditions.SetValidationPassedToTrue(inv)
}

func (c *StashController) checkVolumeSnapshotterRequirements(inv interface{}) error {
func (c *StashController) checkVolumeSnapshotterRequirements(inv any) error {
// nothing to do
return conditions.SetValidationPassedToTrue(inv)
}

func (c *StashController) checkForRepositoryExistence(inv interface{}, r repoReferenceHandler) (*api_v1alpha1.Repository, error) {
func (c *StashController) checkForRepositoryExistence(inv any, r repoReferenceHandler) (*api_v1alpha1.Repository, error) {
repository, err := r.GetRepository()
if err != nil {
if kerr.IsNotFound(err) {
Expand All @@ -477,7 +477,7 @@ func (c *StashController) checkForRepositoryExistence(inv interface{}, r repoRef
return nil, conditions.SetRepositoryFoundConditionToUnknown(inv, err)
}

if repository.ObjectMeta.DeletionTimestamp != nil {
if repository.DeletionTimestamp != nil {
return nil, conditions.SetRepositoryFoundConditionToFalse(inv)
}

Expand All @@ -488,7 +488,7 @@ func (c *StashController) checkForRepositoryExistence(inv interface{}, r repoRef
return repository, c.upsertRepositoryReferences(r)
}

func (c *StashController) checkForBackendSecretExistence(inv interface{}, repository *api_v1alpha1.Repository) (*core.Secret, error) {
func (c *StashController) checkForBackendSecretExistence(inv any, repository *api_v1alpha1.Repository) (*core.Secret, error) {
secret, err := c.kubeClient.CoreV1().Secrets(repository.Namespace).Get(context.TODO(), repository.Spec.Backend.StorageSecretName, metav1.GetOptions{})
if err != nil {
if kerr.IsNotFound(err) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/backup_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,9 @@ func (r *backupSessionReconciler) cleanupBackupHistory() error {
}
// delete the BackupSession that does not fit within the history limit
for i := int(historyLimit); i < len(bsList); i++ {
if invoker.IsBackupCompleted(bsList[i].Status.Phase) && !(bsList[i].Name == lastCompletedSession && historyLimit > 0) {
if invoker.IsBackupCompleted(bsList[i].Status.Phase) && (bsList[i].Name != lastCompletedSession || historyLimit <= 0) {
err = r.ctrl.stashClient.StashV1beta1().BackupSessions(r.session.GetObjectMeta().Namespace).Delete(context.TODO(), bsList[i].Name, meta.DeleteInBackground())
if err != nil && !(kerr.IsNotFound(err) || kerr.IsGone(err)) {
if err != nil && !kerr.IsNotFound(err) && !kerr.IsGone(err) {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (r *repositoryReconciler) updateObservedGeneration() error {
r.ctrl.stashClient.StashV1alpha1(),
r.repository.ObjectMeta,
func(in *api_v1alpha1.RepositoryStatus) (types.UID, *api_v1alpha1.RepositoryStatus) {
in.ObservedGeneration = r.repository.ObjectMeta.Generation
in.ObservedGeneration = r.repository.Generation
return r.repository.UID, in
},
metav1.UpdateOptions{},
Expand Down
18 changes: 8 additions & 10 deletions pkg/controller/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"stash.appscode.dev/stash/pkg/util"

appsv1 "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
kerr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -41,7 +40,6 @@ import (
"k8s.io/klog/v2"
kutil "kmodules.xyz/client-go"
core_util "kmodules.xyz/client-go/core/v1"
"kmodules.xyz/client-go/meta"
meta_util "kmodules.xyz/client-go/meta"
ocapps "kmodules.xyz/openshift/apis/apps/v1"
wapi "kmodules.xyz/webhook-runtime/apis/workload/v1"
Expand Down Expand Up @@ -416,13 +414,13 @@ func (c *StashController) ensureUnnecessaryConfigMapLockDeleted(w *wapi.Workload
return nil
}

func (c *StashController) ensureImagePullSecrets(invokerMeta metav1.ObjectMeta, owner *metav1.OwnerReference) ([]core.LocalObjectReference, error) {
operatorNamespace := meta.PodNamespace()
func (c *StashController) ensureImagePullSecrets(invokerMeta metav1.ObjectMeta, owner *metav1.OwnerReference) ([]corev1.LocalObjectReference, error) {
operatorNamespace := meta_util.PodNamespace()
if operatorNamespace == "" {
operatorNamespace = "kube-system"
}

var imagePullSecrets []core.LocalObjectReference
var imagePullSecrets []corev1.LocalObjectReference
for i := range c.ImagePullSecrets {
// get the respective secret from the operator namespace
secret, err := c.kubeClient.CoreV1().Secrets(operatorNamespace).Get(context.TODO(), c.ImagePullSecrets[i], metav1.GetOptions{})
Expand All @@ -435,7 +433,7 @@ func (c *StashController) ensureImagePullSecrets(invokerMeta metav1.ObjectMeta,
Namespace: invokerMeta.Namespace,
}
// create the image pull secret if not present already
_, _, err = core_util.CreateOrPatchSecret(context.TODO(), c.kubeClient, newPullSecret, func(in *core.Secret) *core.Secret {
_, _, err = core_util.CreateOrPatchSecret(context.TODO(), c.kubeClient, newPullSecret, func(in *corev1.Secret) *corev1.Secret {
// set the invoker as the owner of this secret
core_util.EnsureOwnerReference(&in.ObjectMeta, owner)
in.Type = secret.Type
Expand All @@ -445,7 +443,7 @@ func (c *StashController) ensureImagePullSecrets(invokerMeta metav1.ObjectMeta,
if err != nil {
return nil, err
}
imagePullSecrets = append(imagePullSecrets, core.LocalObjectReference{
imagePullSecrets = append(imagePullSecrets, corev1.LocalObjectReference{
Name: newPullSecret.Name,
})
}
Expand Down Expand Up @@ -582,7 +580,7 @@ func (opt *invokerOptions) handleInitContainerInjectionFailure(inv invoker.Resto
opt.ctrl.kubeClient,
eventer.EventSourceWorkloadController,
opt.workload.Object,
core.EventTypeWarning,
corev1.EventTypeWarning,
eventer.EventReasonInitContainerInjectionFailed,
fmt.Sprintf("Failed to inject stash init-container into %s %s/%s. Reason: %v",
opt.targetRef.Kind,
Expand All @@ -605,7 +603,7 @@ func (opt *invokerOptions) handleInitContainerInjectionSuccess(inv invoker.Resto
opt.ctrl.kubeClient,
eventer.EventSourceWorkloadController,
opt.workload.Object,
core.EventTypeNormal,
corev1.EventTypeNormal,
eventer.EventReasonInitContainerInjectionSucceeded,
fmt.Sprintf("Successfully injected stash init-container into %s %s/%s.",
opt.targetRef.Kind,
Expand All @@ -624,7 +622,7 @@ func (opt *invokerOptions) handleInitContainerDeletionSuccess() error {
opt.ctrl.kubeClient,
eventer.EventSourceWorkloadController,
opt.workload.Object,
core.EventTypeNormal,
corev1.EventTypeNormal,
eventer.EventReasonInitContainerDeletionSucceeded,
fmt.Sprintf("Successfully removed stash init-container from %s %s/%s.",
opt.targetRef.Kind,
Expand Down
Loading
Loading