Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
octant plugin uses client state
Browse files Browse the repository at this point in the history
Signed-off-by: vikram yadav <vyadav@pivotal.io>
  • Loading branch information
vikram yadav committed Apr 7, 2021
1 parent 62bdd53 commit 8af396d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/octant-sample-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ func handleAction(request *service.ActionRequest) error {

if actionValue == pluginActionName {
// Sending an alert needs a clientID from the request context
alert := action.CreateAlert(action.AlertTypeInfo, fmt.Sprintf("My client ID is: %s", request.ClientID), action.DefaultAlertExpiration)
request.DashboardClient.SendAlert(request.Context(), request.ClientID, alert)
alert := action.CreateAlert(action.AlertTypeInfo, fmt.Sprintf("My client ID is: %s", request.ClientState.ClientID), action.DefaultAlertExpiration)
request.DashboardClient.SendAlert(request.Context(), request.ClientState.ClientID, alert)
}

return nil
Expand Down
1 change: 1 addition & 0 deletions internal/api/action_request_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

configFake "github.com/vmware-tanzu/octant/internal/config/fake"

"github.com/vmware-tanzu/octant/internal/api"
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/service/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ type request struct {

path string

ostate ocontext.ClientState
clientState ocontext.ClientState
}

// ClientState returns the octant plugin state
func (r *request) ClientState() ocontext.ClientState {
return r.ostate
return r.clientState
}

// DashboardClient returns a dashboard client for the request.
Expand Down
2 changes: 1 addition & 1 deletion web/src/stories/docs/plugins/GoPluginsIntro.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ p.Serve()

## Plugins with partial octant state
All plugin implementations are passed a request parameter which makes a partial octant state available to the plugins.
request.OState contains accessors for the current namespace and filters. The plugins can now respond to state updates by
request.ClientState contains accessors for the current namespace, filters and context name. The plugins can now respond to state updates by
either responding to specific actions (eg. action.octant.dev/setNamespace) or they can reflect the
current state using the request.ClientState.

Expand Down

0 comments on commit 8af396d

Please sign in to comment.