Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit d768857

Browse files
author
sai chaithanya
authored
feat(discovery): add method to list resources based on kind (#151)
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 <sai.chaithanya@mayadata.io>
1 parent 370ef1a commit d768857

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/test-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
uses: actions/checkout@v2
1414
- name: setup env
1515
run: |
16-
echo "::set-env name=GOPATH::$(go env GOPATH)"
17-
echo "::add-path::$(go env GOPATH)/bin"
16+
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
17+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
1818
- name: Setup go
1919
uses: actions/setup-go@v1
2020
with:

dynamic/discovery/discovery.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,19 @@ func (d *APIResourceDiscovery) StartIfNotAlready() bool {
334334
d.isStarted = true
335335
return true
336336
}
337+
338+
// GetAPIResourcesForKind returns the list of discovered API resources
339+
// corresponding to the provided kind
340+
func (d *APIResourceDiscovery) GetAPIResourcesForKind(kind string) []*metav1.APIResource {
341+
var apiResources []*metav1.APIResource
342+
d.mutex.Lock()
343+
defer d.mutex.Unlock()
344+
345+
for _, apiResourceRegistery := range d.discoveredResources {
346+
apiResource, isExist := apiResourceRegistery.kinds[kind]
347+
if isExist {
348+
apiResources = append(apiResources, &apiResource.APIResource)
349+
}
350+
}
351+
return apiResources
352+
}

0 commit comments

Comments
 (0)