Skip to content

Commit

Permalink
fix: reflect comments
Browse files Browse the repository at this point in the history
Signed-off-by: dusdjhyeon <dusdj0813@gmail.com>
  • Loading branch information
dusdjhyeon committed Sep 24, 2024
1 parent 7b1b5c9 commit 5f2eab5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
20 changes: 16 additions & 4 deletions chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,26 @@ func GetEndpoint(host string) (string, error) {
return host + "/api/query", nil
}

func GetHelmCommand(infra dbChaosInfra.ChaosInfra) string {
func GetHelmCommand(infra dbChaosInfra.ChaosInfra, infraURL string) string {
var (
infraNamespace string
DefaultInfraNamespace = "litmus"
)

if infra.InfraNamespace != nil && *infra.InfraNamespace != "" {
infraNamespace = *infra.InfraNamespace
} else {
infraNamespace = DefaultInfraNamespace
}

commands := fmt.Sprintf(`helm install litmus-agent litmuschaos/litmus-agent \
--namespace litmus --create-namespace \
--set "LITMUS_URL=http://litmusportal-frontend-service.litmus.svc.cluster.local:9091" \ # FOR SELF AGENT (SVC)
--set "LITMUS_BACKEND_URL=http://litmusportal-server-service.litmus.svc.cluster.local:9002" \ # FOR SELF AGENT (SVC)
--namespace %s --create-namespace \
--set "LITMUS_URL=%s" \
--set "INFRA_ID=%s" \
--set "ACCESS_KEY=%s" \
--set "global.INFRA_MODE=%s"`,
infraNamespace,
infraURL,
infra.InfraID,
infra.AccessKey,
infra.InfraScope,
Expand Down
25 changes: 17 additions & 8 deletions chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ import (

const (
// CIVersion specifies the version tag used for ci builds
CIVersion = "ci"
ClusterScope string = "cluster"
NamespaceScope string = "namespace"
InstallationManifest string = "kubernetes"
InstallationHelm string = "helm"
CIVersion = "ci"
ClusterScope string = "cluster"
NamespaceScope string = "namespace"
)

type InstallationMode string

const (
Manifest InstallationMode = "kubernetes"
Helm InstallationMode = "helm"
)

type Service interface {
Expand Down Expand Up @@ -207,8 +212,12 @@ func (in *infraService) RegisterInfra(c context.Context, projectID string, input
return nil, err
}

if input.InstallationType == nil {
return nil, fmt.Errorf("installation type is required")
}

switch *input.InstallationType {
case InstallationManifest:
case string(Manifest):
manifestYaml, err := GetK8sInfraYaml(fmt.Sprintf("%s://%s", referrerURL.Scheme, referrerURL.Host), newInfra)
if err != nil {
return nil, err
Expand All @@ -220,8 +229,8 @@ func (in *infraService) RegisterInfra(c context.Context, projectID string, input
Name: newInfra.Name,
Manifest: string(manifestYaml),
}, nil
case InstallationHelm:
helmCommand := GetHelmCommand(newInfra)
case string(Helm):
helmCommand := GetHelmCommand(newInfra, fmt.Sprintf("%s://%s", referrerURL.Scheme, referrerURL.Host))

return &model.RegisterInfraResponse{
InfraID: newInfra.InfraID,
Expand Down

0 comments on commit 5f2eab5

Please sign in to comment.