Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding plugin api endpoint url #405

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions capten/agent/internal/api/app_deploy_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ func (a *Agent) InstallApp(ctx context.Context, request *agentpb.InstallAppReque
}, nil
}

apiEndpoint, err := executeStringTemplateValues(request.AppConfig.ApiEndpoint, request.AppValues.OverrideValues)
if err != nil {
a.log.Errorf("failed to derive template launch URL for app %s, %v", request.AppConfig.ReleaseName, err)
return &agentpb.InstallAppResponse{
Status: agentpb.StatusCode_INTERNRAL_ERROR,
StatusMessage: "failed to prepare app values",
}, nil
}

syncConfig := &agentpb.SyncAppData{
Config: &agentpb.AppConfig{
ReleaseName: request.AppConfig.ReleaseName,
Expand All @@ -49,6 +58,7 @@ func (a *Agent) InstallApp(ctx context.Context, request *agentpb.InstallAppReque
DefualtApp: request.AppConfig.DefualtApp,
PluginName: request.AppConfig.PluginName,
PluginDescription: request.AppConfig.PluginDescription,
ApiEndpoint: apiEndpoint,
},
Values: &agentpb.AppValues{
OverrideValues: request.AppValues.OverrideValues,
Expand Down
11 changes: 9 additions & 2 deletions capten/agent/internal/capten-store/app_config_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
updateTime = "update_time"
usecase, projectUrl, status, details = "usecase", "project_url", "status", "details"
pluginName, pluginDescription = "plugin_name", "plugin_description"
apiEndpoint = "api_endpoint"
)

var (
Expand All @@ -56,6 +57,7 @@ var (
templateValues, defaultApp,
icon, installStatus,
updateTime, pluginName, pluginDescription,
apiEndpoint,
}
)

Expand Down Expand Up @@ -101,7 +103,7 @@ func (a *Store) GetAppConfig(appReleaseName string) (*agentpb.SyncAppData, error
&templateValues, &config.DefualtApp,
&config.Icon, &config.InstallStatus,
&config.LastUpdateTime, &config.PluginName,
&config.PluginDescription,
&config.PluginDescription, &config.ApiEndpoint,
); err != nil {
return nil, err
}
Expand Down Expand Up @@ -138,7 +140,7 @@ func (a *Store) GetAllApps() ([]*agentpb.SyncAppData, error) {
&templateValues, &config.DefualtApp,
&config.Icon, &config.InstallStatus,
&config.LastUpdateTime, &config.PluginName,
&config.PluginDescription,
&config.PluginDescription, &config.ApiEndpoint,
) {
configCopy := config
overrideValuesCopy, _ := base64.StdEncoding.DecodeString(overrideValues)
Expand Down Expand Up @@ -258,6 +260,11 @@ func formUpdateKvPairs(config *agentpb.SyncAppData) (string, bool) {
fmt.Sprintf("%s = '%s'", pluginDescription, config.Config.PluginDescription))
}

if config.Config.ApiEndpoint != "" {
params = append(params,
fmt.Sprintf("%s = '%s'", apiEndpoint, config.Config.ApiEndpoint))
}

params = append(params,
fmt.Sprintf("%s = '%s'", updateTime, time.Now().Format(time.RFC3339)))

Expand Down
454 changes: 232 additions & 222 deletions capten/agent/internal/pb/agentpb/agent.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE GitProjects DROP COLUMN used_plugins;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE GitProjects ADD used_plugins set<TEXT>;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE ClusterAppConfig DROP COLUMN api_endpoint;
1 change: 1 addition & 0 deletions capten/database/cassandra/migrations/012_app_config.up.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE ClusterAppConfig ADD api_endpoint TEXT;
1 change: 1 addition & 0 deletions proto/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ message AppConfig {
string lastUpdateTime = 18;
string pluginName = 19;
string pluginDescription = 20;
string apiEndpoint = 21;
}

message AppValues {
Expand Down
3 changes: 3 additions & 0 deletions proto/server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ message StoreAppConfig {
string launchURL = 13;
string launchUIDescription = 14;
bool defualtApp = 15;
string pluginName = 16;
string pluginDescription = 17;
string apiEndpoint = 18;
}

message StoreAppAllValues {
Expand Down
7 changes: 0 additions & 7 deletions server/data/store-apps/app_list.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
enabledApps:
- argo-cd-v1.0.0
- argo-cd-v1.0.1
- crossplane-v1.0.1
- testkube-v1.0.0
- testkube-v1.0.1
- tekton-v0.1.7

disabledApps:
- tekton-v0.1.1
- tekton-v0.1.4
- tekton-v0.1.5
26 changes: 0 additions & 26 deletions server/data/store-apps/conf/argo-cd-v1.0.0.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions server/data/store-apps/conf/testkube-v1.0.0.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion server/data/store-apps/conf/testkube-v1.0.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ReleaseName: "testkube"
Version: "1.0.1"
CreateNamespace: true
OverrideValues:
DomainName: "{{.DomainName}}"
DomainName: "{{.DomainName}}"
24 changes: 0 additions & 24 deletions server/data/store-apps/conf/values/argo-cd-v1.0.0_template.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions server/pkg/api/add_store_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (s *Server) AddStoreApp(ctx context.Context, request *serverpb.AddStoreAppR
OverrideValues: request.AppValues.OverrideValues,
LaunchUIValues: request.AppValues.LaunchUIValues,
TemplateValues: request.AppValues.TemplateValues,
PluginName: request.AppConfig.PluginName,
PluginDescription: request.AppConfig.PluginDescription,
APIEndpoint: request.AppConfig.ApiEndpoint,
}

if err := s.serverStore.AddOrUpdateStoreApp(config); err != nil {
Expand Down
1 change: 1 addition & 0 deletions server/pkg/api/deploy_store_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (s *Server) DeployStoreApp(ctx context.Context, request *serverpb.DeploySto
DefualtApp: false,
PluginName: config.PluginName,
PluginDescription: config.PluginDescription,
ApiEndpoint: config.APIEndpoint,
},
AppValues: &agentpb.AppValues{
OverrideValues: dervivedOverrideValues,
Expand Down
2 changes: 1 addition & 1 deletion server/pkg/api/get_store_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *Server) GetStoreApps(ctx context.Context, request *serverpb.GetStoreApp
}

appsData := []*serverpb.StoreAppsData{}
for _, config := range *configs {
for _, config := range configs {
overrideValues, err := s.deriveTemplateOverrideValues(config.OverrideValues, clusterGlobalValues)
if err != nil {
s.log.Errorf("failed to update overrided store app values for app %s, %v", config.ReleaseName, err)
Expand Down
Loading
Loading