Skip to content

Commit

Permalink
Merge branch 'master' into goreleaser-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetb authored Nov 23, 2024
2 parents f57e7f0 + 8e5b6d7 commit fa28121
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.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.23'
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 @@ -13,7 +13,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: '1.23'
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

0 comments on commit fa28121

Please sign in to comment.