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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: '1.20'
go-version-file: 'go.mod'
- name: GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: '1.20'
go-version-file: 'go.mod'
- name: GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
12 changes: 10 additions & 2 deletions cmd/kubectl-tree/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package main

import (
"context"
stderrors "errors"
"fmt"
"sync"
"time"

"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -33,8 +35,14 @@ func getAllResources(client dynamic.Interface, apis []apiResource, allNs bool) (
klog.V(4).Infof("[query api] start: %s", a.GroupVersionResource())
v, err := queryAPI(client, a, allNs)
if err != nil {
klog.V(4).Infof("[query api] error querying: %s, error=%v", a.GroupVersionResource(), err)
errResult = err
if errors.IsForbidden(err) {
// should not fail the overall process, but print an info message indicating the permission issue
klog.V(4).Infof("[query api] skipping forbidden resource: %s", a.GroupVersionResource())
klog.Infof("cannot query %s (forbidden), omitting from the tree", a.GroupVersionResource().GroupResource())
} else {
klog.V(4).Infof("[query api] error querying: %s, error=%v", a.GroupVersionResource(), err)
errResult = stderrors.Join(errResult, fmt.Errorf("failed to query the %s resources: %w", a.GroupVersionResource(), err))
}
return
}
mu.Lock()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ahmetb/kubectl-tree

go 1.20
go 1.22

require (
github.com/fatih/color v1.15.0
Expand Down
Loading