Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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.18
go-version: 1.20
Copy link
Owner

Choose a reason for hiding this comment

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

You need to type ' or " around this otherwise it becomes 1.2 float :) at this point let's do 1.22

Copy link
Owner

Choose a reason for hiding this comment

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

Omg i made this error myself it turns out 🤦

- 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.18
go-version: 1.20
- 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.18
go 1.20

require (
github.com/fatih/color v1.13.0
Expand Down