Skip to content

Commit fa28121

Browse files
authored
Merge branch 'master' into goreleaser-fix
2 parents f57e7f0 + 8e5b6d7 commit fa28121

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Go
1313
uses: actions/setup-go@v1
1414
with:
15-
go-version: '1.23'
15+
go-version-file: 'go.mod'
1616
- name: GoReleaser
1717
uses: goreleaser/goreleaser-action@v1
1818
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup Go
1414
uses: actions/setup-go@v1
1515
with:
16-
go-version: '1.23'
16+
go-version-file: 'go.mod'
1717
- name: GoReleaser
1818
uses: goreleaser/goreleaser-action@v1
1919
with:

cmd/kubectl-tree/query.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package main
22

33
import (
44
"context"
5+
stderrors "errors"
56
"fmt"
67
"sync"
78
"time"
89

10+
"k8s.io/apimachinery/pkg/api/errors"
911
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1012
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1113
"k8s.io/client-go/dynamic"
@@ -33,8 +35,14 @@ func getAllResources(client dynamic.Interface, apis []apiResource, allNs bool) (
3335
klog.V(4).Infof("[query api] start: %s", a.GroupVersionResource())
3436
v, err := queryAPI(client, a, allNs)
3537
if err != nil {
36-
klog.V(4).Infof("[query api] error querying: %s, error=%v", a.GroupVersionResource(), err)
37-
errResult = err
38+
if errors.IsForbidden(err) {
39+
// should not fail the overall process, but print an info message indicating the permission issue
40+
klog.V(4).Infof("[query api] skipping forbidden resource: %s", a.GroupVersionResource())
41+
klog.Infof("cannot query %s (forbidden), omitting from the tree", a.GroupVersionResource().GroupResource())
42+
} else {
43+
klog.V(4).Infof("[query api] error querying: %s, error=%v", a.GroupVersionResource(), err)
44+
errResult = stderrors.Join(errResult, fmt.Errorf("failed to query the %s resources: %w", a.GroupVersionResource(), err))
45+
}
3846
return
3947
}
4048
mu.Lock()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ahmetb/kubectl-tree
22

3-
go 1.20
3+
go 1.22
44

55
require (
66
github.com/fatih/color v1.15.0

0 commit comments

Comments
 (0)