Skip to content

Commit

Permalink
fix: Show individual rollout in other namespace (#1344)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii Perenesenko <[email protected]>
  • Loading branch information
perenesenko authored Jul 14, 2021
1 parent 21c7826 commit de0d8e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,30 +189,30 @@ func (s *ArgoRolloutsServer) Run(ctx context.Context, port int, dashboard bool)
errors.CheckError(conn.Close())
}

func (s *ArgoRolloutsServer) initRolloutViewController(name string, ctx context.Context) *viewcontroller.RolloutViewController {
controller := viewcontroller.NewRolloutViewController(s.Options.Namespace, name, s.Options.KubeClientset, s.Options.RolloutsClientset)
func (s *ArgoRolloutsServer) initRolloutViewController(namespace string, name string, ctx context.Context) *viewcontroller.RolloutViewController {
controller := viewcontroller.NewRolloutViewController(namespace, name, s.Options.KubeClientset, s.Options.RolloutsClientset)
controller.Start(ctx)
return controller
}

func (s *ArgoRolloutsServer) getRolloutInfo(name string) (*rollout.RolloutInfo, error) {
controller := s.initRolloutViewController(name, context.Background())
func (s *ArgoRolloutsServer) getRolloutInfo(namespace string, name string) (*rollout.RolloutInfo, error) {
controller := s.initRolloutViewController(namespace, name, context.Background())
ri, err := controller.GetRolloutInfo()
if err != nil {
return nil, err
}
return ri, nil
}

// GetRollout returns a rollout
// GetRolloutInfo returns a rollout
func (s *ArgoRolloutsServer) GetRolloutInfo(c context.Context, q *rollout.RolloutInfoQuery) (*rollout.RolloutInfo, error) {
return s.getRolloutInfo(q.GetName())
return s.getRolloutInfo(q.GetNamespace(), q.GetName())
}

// WatchRollout returns a rollout stream
// WatchRolloutInfo returns a rollout stream
func (s *ArgoRolloutsServer) WatchRolloutInfo(q *rollout.RolloutInfoQuery, ws rollout.RolloutService_WatchRolloutInfoServer) error {
ctx := context.Background()
controller := s.initRolloutViewController(q.GetName(), ctx)
ctx := ws.Context()
controller := s.initRolloutViewController(q.GetNamespace(), q.GetName(), ctx)

rolloutUpdates := make(chan *rollout.RolloutInfo)
controller.RegisterCallback(func(roInfo *rollout.RolloutInfo) {
Expand Down Expand Up @@ -250,7 +250,7 @@ func (s *ArgoRolloutsServer) ListReplicaSetsAndPods(ctx context.Context, namespa
return allReplicaSetsP, allPodsP, nil
}

// ListRollouts returns a list of all rollouts
// ListRolloutInfos returns a list of all rollouts
func (s *ArgoRolloutsServer) ListRolloutInfos(ctx context.Context, q *rollout.RolloutInfoListQuery) (*rollout.RolloutInfoList, error) {
rolloutIf := s.Options.RolloutsClientset.ArgoprojV1alpha1().Rollouts(q.GetNamespace())
rolloutList, err := rolloutIf.List(ctx, v1.ListOptions{})
Expand Down Expand Up @@ -281,7 +281,7 @@ func (s *ArgoRolloutsServer) RestartRollout(ctx context.Context, q *rollout.Rest
return restart.RestartRollout(rolloutIf, q.GetName(), &restartAt)
}

// WatchRollouts returns a stream of all rollouts
// WatchRolloutInfos returns a stream of all rollouts
func (s *ArgoRolloutsServer) WatchRolloutInfos(q *rollout.RolloutInfoListQuery, ws rollout.RolloutService_WatchRolloutInfosServer) error {
send := func(r *rollout.RolloutInfo) {
err := ws.Send(&rollout.RolloutWatchEvent{
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const App = () => {
}, []);
const changeNamespace = (val: string) => {
setNamespace(val);
window.localStorage.setItem(NAMESPACE_KEY, namespace);
window.localStorage.setItem(NAMESPACE_KEY, val);
};

return (
Expand Down

0 comments on commit de0d8e0

Please sign in to comment.