Skip to content

Commit

Permalink
Merge pull request #505 from kube-tarian/capten-cli-changes
Browse files Browse the repository at this point in the history
update apis implementation for cli handling
  • Loading branch information
vramk23 authored Jun 4, 2024
2 parents ae8aaeb + ffef4e2 commit 5be85c1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
6 changes: 3 additions & 3 deletions capten/agent/internal/api/cluster_plugin_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ func (a *Agent) GetClusterPlugins(ctx context.Context, request *clusterpluginspb
}

clusterPlugins := []*clusterpluginspb.ClusterPlugin{}
for idx, pluginConfig := range pluginConfigList {
clusterPlugins[idx] = &clusterpluginspb.ClusterPlugin{
for _, pluginConfig := range pluginConfigList {
clusterPlugins = append(clusterPlugins, &clusterpluginspb.ClusterPlugin{
StoreType: pluginConfig.StoreType,
PluginName: pluginConfig.PluginName,
Description: pluginConfig.Description,
Category: pluginConfig.Category,
Icon: pluginConfig.Icon,
Version: pluginConfig.Version,
InstallStatus: pluginConfig.InstallStatus,
}
})
}
return &clusterpluginspb.GetClusterPluginsResponse{
Status: clusterpluginspb.StatusCode_OK,
Expand Down
18 changes: 7 additions & 11 deletions capten/agent/internal/api/plugin_crossplane_project_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,25 @@ const (

func (a *Agent) RegisterCrossplaneProject(ctx context.Context, request *captenpluginspb.RegisterCrossplaneProjectRequest) (
*captenpluginspb.RegisterCrossplaneProjectResponse, error) {
a.log.Infof("Register Crossplane Git project request recieved")

if err := validateArgs(request.Id); err != nil {
a.log.Infof("request validation failed", err)
crossplaneProject, err := a.as.GetCrossplaneProject()
if err != nil {
a.log.Infof("failed to get git project, %v", err)
return &captenpluginspb.RegisterCrossplaneProjectResponse{
Status: captenpluginspb.StatusCode_INVALID_ARGUMENT,
StatusMessage: "request validation failed",
}, nil
}
a.log.Infof("Register Crossplane Git project %s request recieved", request.Id)

crossplaneProject, err := a.as.GetCrossplaneProjectForID(request.Id)
if err != nil {
a.log.Infof("failed to get git project %s, %v", request.Id, err)
return &captenpluginspb.RegisterCrossplaneProjectResponse{
Status: captenpluginspb.StatusCode_INVALID_ARGUMENT,
StatusMessage: "request validation failed",
}, nil
if crossplaneProject.Status == "" {
crossplaneProject.Status = string(model.CrossplaneProjectAvailable)
}

if crossplaneProject.Status != string(model.CrossplaneProjectConfigurationFailed) &&
crossplaneProject.Status != string(model.CrossplaneProjectAvailable) &&
crossplaneProject.Status != string(model.CrossplaneProjectConfigured) {
a.log.Infof("currently the Crossplane project configuration on-going %s, %v", request.Id, crossplaneProject.Status)
a.log.Infof("currently the Crossplane project configuration on-going %s, %v", crossplaneProject.Id, crossplaneProject.Status)
return &captenpluginspb.RegisterCrossplaneProjectResponse{
Status: captenpluginspb.StatusCode_OK,
StatusMessage: "Crossplane configuration on-going",
Expand Down
13 changes: 5 additions & 8 deletions capten/agent/internal/api/plugin_tekton_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import (
func (a *Agent) RegisterTektonProject(ctx context.Context, request *captenpluginspb.RegisterTektonProjectRequest) (
*captenpluginspb.RegisterTektonProjectResponse, error) {
a.log.Infof("registering the tekton project")
if err := validateArgs(request.Id); err != nil {
a.log.Infof("request validation failed", err)
return &captenpluginspb.RegisterTektonProjectResponse{
Status: captenpluginspb.StatusCode_INVALID_ARGUMENT,
StatusMessage: "request validation failed",
}, err
}

project, err := a.as.GetTektonProject()
if err != nil {
Expand All @@ -28,10 +21,14 @@ func (a *Agent) RegisterTektonProject(ctx context.Context, request *captenplugin
}, err
}

if project.Status == "" {
project.Status = string(model.TektonProjectAvailable)
}

if project.Status != string(model.TektonProjectConfigurationFailed) &&
project.Status != string(model.TektonProjectAvailable) &&
project.Status != string(model.TektonProjectConfigured) {
a.log.Infof("currently the Tekton project configuration on-going %s, %v", request.Id, project.Status)
a.log.Infof("currently the Tekton project configuration on-going %s, %v", project.Id, project.Status)
return &captenpluginspb.RegisterTektonProjectResponse{
Status: captenpluginspb.StatusCode_OK,
StatusMessage: "Tekton configuration on-going",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (a *Store) GetAllClusterPluginConfigs() ([]*clusterpluginspb.Plugin, error)
return nil, fmt.Errorf("failed to fetch plugins: %v", err.Error())
}

var pluginConfigs []*clusterpluginspb.Plugin
pluginConfigs := []*clusterpluginspb.Plugin{}
for _, p := range plugins {
values, _ := base64.StdEncoding.DecodeString(p.Values)
overrideValues, _ := base64.StdEncoding.DecodeString(p.OverrideValues)
Expand Down

0 comments on commit 5be85c1

Please sign in to comment.