Skip to content

Commit

Permalink
Merge pull request #184 from openinfradev/fix_appgroup_delete
Browse files Browse the repository at this point in the history
feature. fix appgroup deletion error when cluster type is byoh cluster
  • Loading branch information
ktkfree authored Oct 30, 2023
2 parents 4f7872a + 199779b commit 6d03e47
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
3 changes: 3 additions & 0 deletions api/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5714,6 +5714,9 @@ const docTemplate = `{
"stackTemplateId"
],
"properties": {
"cloudService": {
"type": "string"
},
"clusterType": {
"type": "string"
},
Expand Down
3 changes: 3 additions & 0 deletions api/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5707,6 +5707,9 @@
"stackTemplateId"
],
"properties": {
"cloudService": {
"type": "string"
},
"clusterType": {
"type": "string"
},
Expand Down
2 changes: 2 additions & 0 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,8 @@ definitions:
type: object
domain.ImportClusterRequest:
properties:
cloudService:
type: string
clusterType:
type: string
description:
Expand Down
37 changes: 20 additions & 17 deletions internal/usecase/app-group.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,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.CloudAccount.ID.String()
isExist := false
for _, ca := range cloudAccounts {
if ca.ID == cluster.CloudAccount.ID {

// FOR TEST. ADD MAGIC KEYWORD
if strings.Contains(ca.Name, domain.CLOUD_ACCOUNT_INCLUSTER) {
tksCloudAccountId = ""
tksCloudAccountId := ""
if cluster.CloudService != domain.CloudService_BYOH {
cloudAccounts, err := u.cloudAccountRepo.Fetch(cluster.OrganizationId, nil)
if err != nil {
return httpErrors.NewBadRequestError(fmt.Errorf("Failed to get cloudAccounts"), "", "")
}
tksCloudAccountId = cluster.CloudAccount.ID.String()
isExist := false
for _, ca := range cloudAccounts {
if ca.ID == cluster.CloudAccount.ID {

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

// Call argo workflow template
Expand Down
1 change: 1 addition & 0 deletions pkg/domain/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ type ImportClusterRequest struct {
Description string `json:"description"`
ClusterType string `json:"clusterType"`
Kubeconfig []byte `json:"kubeconfig"`
CloudService string `json:"cloudService"`
}

type CreateClusterResponse struct {
Expand Down

0 comments on commit 6d03e47

Please sign in to comment.