-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from kube-tarian/plugins-api-impl
get capten plugins apis implementation
- Loading branch information
Showing
22 changed files
with
1,128 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package agent | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/kube-tarian/kad/capten/agent/pkg/pb/captenpluginspb" | ||
) | ||
|
||
func (a *Agent) GetCaptenPlugins(ctx context.Context, request *captenpluginspb.GetCaptenPluginsRequest) ( | ||
*captenpluginspb.GetCaptenPluginsResponse, error) { | ||
a.log.Infof("Get Capten Plugins %s request recieved") | ||
|
||
res, err := a.as.GetAllApps() | ||
if err != nil { | ||
return &captenpluginspb.GetCaptenPluginsResponse{ | ||
Status: captenpluginspb.StatusCode_INTERNAL_ERROR, | ||
StatusMessage: "failed to fetch pluginss", | ||
}, nil | ||
} | ||
|
||
plugins := make([]*captenpluginspb.CaptenPlugin, 0) | ||
for _, r := range res { | ||
appConfig := r.GetConfig() | ||
if len(appConfig.PluginName) == 0 { | ||
continue | ||
} | ||
|
||
plugins = append(plugins, &captenpluginspb.CaptenPlugin{ | ||
PluginName: r.GetConfig().GetPluginName(), | ||
PluginDescription: r.GetConfig().GetPluginDescription(), | ||
LaunchIcon: r.GetConfig().GetIcon(), | ||
LaunchURL: r.GetConfig().GetLaunchURL(), | ||
InstallStatus: r.GetConfig().GetInstallStatus(), | ||
RuntimeStatus: r.GetConfig().GetRuntimeStatus(), | ||
}) | ||
} | ||
|
||
a.log.Infof("Fetched %d capten plugins", len(plugins)) | ||
return &captenpluginspb.GetCaptenPluginsResponse{Status: captenpluginspb.StatusCode_OK, | ||
StatusMessage: "successfully fetched plugin", | ||
Plugins: plugins}, nil | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
369 changes: 317 additions & 52 deletions
369
capten/agent/pkg/pb/captenpluginspb/capten_plugins.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
capten/agent/pkg/pb/captenpluginspb/capten_plugins_grpc.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/kube-tarian/kad/server/pkg/pb/captenpluginspb" | ||
) | ||
|
||
func (s *Server) GetCaptenPlugins(ctx context.Context, request *captenpluginspb.GetCaptenPluginsRequest) ( | ||
*captenpluginspb.GetCaptenPluginsResponse, error) { | ||
orgId, clusterId, err := validateOrgClusterWithArgs(ctx) | ||
if err != nil { | ||
s.log.Infof("request validation failed", err) | ||
return &captenpluginspb.GetCaptenPluginsResponse{ | ||
Status: captenpluginspb.StatusCode_INVALID_ARGUMENT, | ||
StatusMessage: "request validation failed", | ||
}, nil | ||
} | ||
s.log.Infof("Get Capten Plugins %s request for cluster %s recieved, [org: %s]", | ||
clusterId, orgId) | ||
|
||
a, err := s.agentHandeler.GetAgent(orgId, clusterId) | ||
if err != nil { | ||
s.log.Error("failed to connect to agent", err) | ||
return &captenpluginspb.GetCaptenPluginsResponse{Status: captenpluginspb.StatusCode_INTERNAL_ERROR, | ||
StatusMessage: "failed to connect to agent"}, nil | ||
} | ||
|
||
resp, err := a.GetCaptenPluginsClient().GetCaptenPlugins(ctx, &captenpluginspb.GetCaptenPluginsRequest{}) | ||
if err != nil { | ||
s.log.Error("failed to get cluster capten plugins from agent", err) | ||
return &captenpluginspb.GetCaptenPluginsResponse{Status: captenpluginspb.StatusCode_INTERNAL_ERROR, | ||
StatusMessage: "failed to get cluster application from agent"}, nil | ||
} | ||
|
||
s.log.Infof("Fetched %d capten plugins from the cluster %s, [org: %s]", len(resp.Plugins), clusterId, orgId) | ||
return &captenpluginspb.GetCaptenPluginsResponse{Status: captenpluginspb.StatusCode_OK, | ||
StatusMessage: "successfully fetched the data from agent", | ||
Plugins: resp.Plugins}, nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.