Skip to content

Commit

Permalink
Instead of iterating over list of deploys, get directly
Browse files Browse the repository at this point in the history
Signed-off-by: Burak Sekili <buraksekili@gmail.com>
  • Loading branch information
buraksekili committed Nov 10, 2023
1 parent 9a7c8a7 commit 0a93fcc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions k8s/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ func (c *Client) RestartDashboard() error {
return fmt.Errorf("failed to list Tyk Dashboard Deployment, err: %v", err)
}

for i := range deployments.Items {
c.appArgs.K8s.DashboardDeploymentName = deployments.Items[i].ObjectMeta.Name
if len(deployments.Items) == 0 {
c.l.Warnf("failed to find Deploymet with label %v in %v",
c.appArgs.K8s.ReleaseNamespace,
labels.Set(ls.MatchLabels).String(),
)
}

if len(deployments.Items) > 0 {
c.appArgs.K8s.DashboardDeploymentName = deployments.Items[0].ObjectMeta.Name
}
}

Expand All @@ -56,10 +63,6 @@ func (c *Client) RestartDashboard() error {
return err
}

func (c *Client) Get() string {
return c.appArgs.K8s.DashboardSvcUrl
}

// DiscoverDashboardSvc lists Service objects with constants.TykBootstrapLabel label that has
// constants.TykBootstrapDashboardSvcLabel value and returns a service URL for Tyk Dashboard.
func (c *Client) DiscoverDashboardSvc() (string, error) {
Expand Down

0 comments on commit 0a93fcc

Please sign in to comment.