Skip to content

Commit

Permalink
Merge pull request #7 from kronostechnologies/feature/DOPS-3388-fix-a…
Browse files Browse the repository at this point in the history
…pp-list-for-ops-role

DOPS-3388 : Add parameter namespace to listApps function
  • Loading branch information
Chahdro authored Apr 5, 2023
2 parents 50223e4 + 61f05b9 commit 07ff531
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions action/apps_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ func Run(filters AppFilters) error {
ClientSet: GetClientSet(GetKubeConfigPath()),
}
currentContext := clientSet.Cluster
listApps, err := ListApps(clientSet.ClientSet)
var namespace string = ""
if len(filters.Filters) > 0 {
namespace = filters.Filters[0]
}
listApps, err := ListApps(clientSet.ClientSet, namespace)

if err != nil {
return err
Expand Down Expand Up @@ -146,8 +150,8 @@ func ConnectCluster() *kubernetes.Clientset {
}

//Return a pointer to a list of Pods
func ListApps(clientSet kubernetes.Interface) (*v1.PodList, error) {
pods, err := clientSet.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{})
func ListApps(clientSet kubernetes.Interface, namespace string) (*v1.PodList, error) {
pods, err := clientSet.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion action/apps_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *AppsRun) Run() error {
ClientSet: GetClientSet(GetKubeConfigPath()),
}
currentContext := clientSet.Cluster
listApps, err := ListApps(clientSet.ClientSet)
listApps, err := ListApps(clientSet.ClientSet, c.Application)

if err != nil {
return err
Expand Down

0 comments on commit 07ff531

Please sign in to comment.