Skip to content

Commit

Permalink
feat(discovery): add method to list resources based on kind (#151)
Browse files Browse the repository at this point in the history
This commit does the following changes:
- Adds functionality to discover the list of resources based
on their kind. This functionality will help consumers to get
resource details if they are aware of Resource Kind.
- Updates the way of configuring GitHub WorkFlow
Path and Envs(For more info click here).

Signed-off-by: mittachaitu <[email protected]>
  • Loading branch information
sai chaithanya authored Dec 6, 2020
1 parent 370ef1a commit d768857
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
uses: actions/checkout@v2
- name: setup env
run: |
echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup go
uses: actions/setup-go@v1
with:
Expand Down
16 changes: 16 additions & 0 deletions dynamic/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,19 @@ func (d *APIResourceDiscovery) StartIfNotAlready() bool {
d.isStarted = true
return true
}

// GetAPIResourcesForKind returns the list of discovered API resources
// corresponding to the provided kind
func (d *APIResourceDiscovery) GetAPIResourcesForKind(kind string) []*metav1.APIResource {
var apiResources []*metav1.APIResource
d.mutex.Lock()
defer d.mutex.Unlock()

for _, apiResourceRegistery := range d.discoveredResources {
apiResource, isExist := apiResourceRegistery.kinds[kind]
if isExist {
apiResources = append(apiResources, &apiResource.APIResource)
}
}
return apiResources
}

0 comments on commit d768857

Please sign in to comment.