-
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.
- Loading branch information
Showing
30 changed files
with
1,208 additions
and
1,054 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
enabledApps: | ||
- argo-cd | ||
- crossplane | ||
- testkube | ||
- testkube-v1.0.0 | ||
- testkube-v1.0.1 | ||
|
||
disabledApps: |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
Name: "testkube" | ||
ChartName: "tools/testkube" | ||
Category: "Testing framework" | ||
Description: "" | ||
RepoName: "tools" | ||
RepoURL: "https://kube-tarian.github.io/helmrepo-supporting-tools" | ||
Namespace: "testkube" | ||
ReleaseName: "testkube" | ||
Version: "1.0.1" | ||
CreateNamespace: true | ||
OverrideValues: | ||
DomainName: "{{.DomainName}}" |
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,56 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
|
||
"github.com/kube-tarian/kad/server/pkg/pb/serverpb" | ||
"github.com/kube-tarian/kad/server/pkg/types" | ||
) | ||
|
||
func (s *Server) AddStoreApp(ctx context.Context, request *serverpb.AddStoreAppRequest) ( | ||
*serverpb.AddStoreAppResponse, error) { | ||
_, err := validateRequest(ctx, request.AppConfig.AppName, request.AppConfig.Version) | ||
if err != nil { | ||
s.log.Infof("request validation failed", err) | ||
return &serverpb.AddStoreAppResponse{ | ||
Status: serverpb.StatusCode_INVALID_ARGUMENT, | ||
StatusMessage: "request validation failed", | ||
}, nil | ||
} | ||
s.log.Infof("Add store app [%s:%s] request recieved", request.AppConfig.AppName, request.AppConfig.Version) | ||
|
||
config := &types.StoreAppConfig{ | ||
ReleaseName: request.AppConfig.ReleaseName, | ||
AppName: request.AppConfig.AppName, | ||
Version: request.AppConfig.Version, | ||
Category: request.AppConfig.Category, | ||
Description: request.AppConfig.Description, | ||
ChartName: request.AppConfig.ChartName, | ||
RepoName: request.AppConfig.RepoName, | ||
RepoURL: request.AppConfig.RepoURL, | ||
Namespace: request.AppConfig.Namespace, | ||
CreateNamespace: request.AppConfig.CreateNamespace, | ||
PrivilegedNamespace: request.AppConfig.PrivilegedNamespace, | ||
Icon: hex.EncodeToString(request.AppConfig.Icon), | ||
LaunchURL: request.AppConfig.LaunchURL, | ||
LaunchUIDescription: request.AppConfig.LaunchUIDescription, | ||
OverrideValues: encodeBase64BytesToString(request.AppValues.OverrideValues), | ||
LaunchUIValues: encodeBase64BytesToString(request.AppValues.LaunchUIValues), | ||
TemplateValues: encodeBase64BytesToString(request.AppValues.TemplateValues), | ||
} | ||
|
||
if err := s.serverStore.AddOrUpdateStoreApp(config); err != nil { | ||
s.log.Errorf("failed to add app config to store, %v", err) | ||
return &serverpb.AddStoreAppResponse{ | ||
Status: serverpb.StatusCode_INTERNRAL_ERROR, | ||
StatusMessage: "failed add app config to store", | ||
}, nil | ||
} | ||
|
||
s.log.Infof("Add store app [%s:%s] request successful", request.AppConfig.AppName, request.AppConfig.Version) | ||
return &serverpb.AddStoreAppResponse{ | ||
Status: serverpb.StatusCode_OK, | ||
StatusMessage: "app config is sucessfuly added to store", | ||
}, nil | ||
} |
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,44 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/kube-tarian/kad/server/pkg/pb/agentpb" | ||
"github.com/kube-tarian/kad/server/pkg/pb/serverpb" | ||
) | ||
|
||
func mapAgentAppsToServerResp(appDataList []*agentpb.AppData) []*serverpb.ClusterAppConfig { | ||
clusterAppConfigs := make([]*serverpb.ClusterAppConfig, len(appDataList)) | ||
for index, appConfig := range appDataList { | ||
var clusterAppConfig serverpb.ClusterAppConfig | ||
clusterAppConfig.AppName = appConfig.Config.AppName | ||
clusterAppConfig.Version = appConfig.Config.Version | ||
clusterAppConfig.Category = appConfig.Config.Category | ||
clusterAppConfig.Description = appConfig.Config.Description | ||
clusterAppConfig.ChartName = appConfig.Config.ChartName | ||
clusterAppConfig.RepoName = appConfig.Config.RepoName | ||
clusterAppConfig.RepoURL = appConfig.Config.RepoURL | ||
clusterAppConfig.Namespace = appConfig.Config.Namespace | ||
clusterAppConfig.CreateNamespace = appConfig.Config.CreateNamespace | ||
clusterAppConfig.PrivilegedNamespace = appConfig.Config.PrivilegedNamespace | ||
clusterAppConfig.Icon = appConfig.Config.Icon | ||
clusterAppConfig.LaunchURL = appConfig.Config.LaunchURL | ||
clusterAppConfig.InstallStatus = appConfig.Config.InstallStatus | ||
clusterAppConfig.RuntimeStatus = "" | ||
clusterAppConfig.DefualtApp = appConfig.Config.DefualtApp | ||
clusterAppConfigs[index] = &clusterAppConfig | ||
} | ||
return clusterAppConfigs | ||
} | ||
|
||
func mapAgentAppLauncesToServerResp(appLaunchCfgs []*agentpb.AppLaunchConfig) []*serverpb.AppLaunchConfig { | ||
svrAppLaunchCfg := make([]*serverpb.AppLaunchConfig, len(appLaunchCfgs)) | ||
for index, cfg := range appLaunchCfgs { | ||
var launchCfg serverpb.AppLaunchConfig | ||
launchCfg.ReleaseName = cfg.ReleaseName | ||
launchCfg.Category = cfg.Category | ||
launchCfg.LaunchUIDescription = cfg.Description | ||
launchCfg.Icon = cfg.Icon | ||
launchCfg.LaunchURL = cfg.LaunchURL | ||
svrAppLaunchCfg[index] = &launchCfg | ||
} | ||
return svrAppLaunchCfg | ||
} |
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,62 @@ | ||
package api | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"fmt" | ||
"text/template" | ||
|
||
"github.com/kube-tarian/kad/server/pkg/pb/agentpb" | ||
"github.com/pkg/errors" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
func (s *Server) replaceGlobalValues(orgId, clusterID string, overridedValues []byte) ([]byte, error) { | ||
agent, err := s.agentHandeler.GetAgent(orgId, clusterID) | ||
if err != nil { | ||
return nil, errors.WithMessagef(err, "failed to initialize agent for cluster %s", clusterID) | ||
} | ||
resp, err := agent.GetClient().GetClusterGlobalValues(context.TODO(), &agentpb.GetClusterGlobalValuesRequest{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if resp.Status != agentpb.StatusCode_OK { | ||
return nil, fmt.Errorf("failed to get global values for cluster %s", clusterID) | ||
} | ||
|
||
var globalValues map[string]interface{} | ||
err = yaml.Unmarshal(resp.GlobalValues, &globalValues) | ||
if err != nil { | ||
return nil, errors.WithMessagef(err, "failed to unmarshal cluster values") | ||
} | ||
|
||
var overrideValues map[string]interface{} | ||
err = yaml.Unmarshal(overridedValues, &overrideValues) | ||
if err != nil { | ||
return nil, errors.WithMessagef(err, "failed to unmarshal override values") | ||
} | ||
|
||
return replaceOverrideGlobalValues(overrideValues, globalValues) | ||
} | ||
|
||
func replaceOverrideGlobalValues(overrideValues map[string]interface{}, | ||
globlaValues map[string]interface{}) (transformedData []byte, err error) { | ||
yamlData, err := yaml.Marshal(overrideValues) | ||
if err != nil { | ||
return | ||
} | ||
|
||
tmpl, err := template.New("templateVal").Parse(string(yamlData)) | ||
if err != nil { | ||
return | ||
} | ||
|
||
var buf bytes.Buffer | ||
err = tmpl.Execute(&buf, globlaValues) | ||
if err != nil { | ||
return | ||
} | ||
|
||
transformedData = buf.Bytes() | ||
return | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.