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

bugfix. add workflow parameter for deleing appgroup #115

Merged
merged 1 commit into from
Jul 27, 2023
Merged
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
23 changes: 23 additions & 0 deletions internal/usecase/app-group.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,28 @@ func (u *AppGroupUsecase) Delete(ctx context.Context, id domain.AppGroupId) (err
}
organizationId := cluster.OrganizationId

// check cloudAccount
cloudAccounts, err := u.cloudAccountRepo.Fetch(cluster.OrganizationId, nil)
if err != nil {
return httpErrors.NewBadRequestError(fmt.Errorf("Failed to get cloudAccounts"), "", "")
}
tksCloudAccountId := cluster.CloudAccountId.String()
isExist := false
for _, ca := range cloudAccounts {
if ca.ID == cluster.CloudAccountId {

// FOR TEST. ADD MAGIC KEYWORD
if strings.Contains(ca.Name, domain.CLOUD_ACCOUNT_INCLUSTER) {
tksCloudAccountId = ""
}
isExist = true
break
}
}
if !isExist {
return httpErrors.NewBadRequestError(fmt.Errorf("Not found cloudAccountId[%s] in organization[%s]", cluster.CloudAccountId, cluster.OrganizationId), "", "")
}

// Call argo workflow template
workflowTemplate := ""
appGroupName := ""
Expand All @@ -196,6 +218,7 @@ func (u *AppGroupUsecase) Delete(ctx context.Context, id domain.AppGroupId) (err
"app_group_id=" + id.String(),
"keycloak_url=" + strings.TrimSuffix(viper.GetString("keycloak-address"), "/auth"),
"base_repo_branch=" + viper.GetString("revision"),
"cloud_account_id=" + tksCloudAccountId,
}

workflowId, err := u.argo.SumbitWorkflowFromWftpl(workflowTemplate, opts)
Expand Down