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

trivial. minor fix. #90

Merged
merged 2 commits into from
Jun 22, 2023
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
2 changes: 1 addition & 1 deletion internal/repository/cloud-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (r *CloudAccountRepository) GetByName(organizationId string, name string) (

func (r *CloudAccountRepository) GetByAwsAccountId(awsAccountId string) (out domain.CloudAccount, err error) {
var cloudAccount CloudAccount
res := r.db.Preload(clause.Associations).First(&cloudAccount, "aws_account_id = ?", awsAccountId)
res := r.db.Preload(clause.Associations).First(&cloudAccount, "aws_account_id = ? AND status != ?", awsAccountId, domain.CloudAccountStatus_DELETED)

if res.Error != nil {
return domain.CloudAccount{}, res.Error
Expand Down
5 changes: 3 additions & 2 deletions internal/usecase/cloud-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (u *CloudAccountUsecase) Create(ctx context.Context, dto domain.CloudAccoun
log.InfoWithContext(ctx, "newly created CloudAccount ID:", cloudAccountId)

// FOR TEST. ADD MAGIC KEYWORD
if strings.Contains(dto.Name, "INCLUSTER") {
if strings.Contains(dto.Name, domain.CLOUD_ACCOUNT_INCLUSTER) {
if err := u.repo.InitWorkflow(cloudAccountId, "", domain.CloudAccountStatus_CREATED); err != nil {
return uuid.Nil, errors.Wrap(err, "Failed to initialize status")
}
Expand Down Expand Up @@ -210,7 +210,8 @@ func (u *CloudAccountUsecase) DeleteForce(ctx context.Context, cloudAccountId uu
return err
}

if cloudAccount.Status != domain.CloudAccountStatus_CREATE_ERROR {
if !strings.Contains(cloudAccount.Name, domain.CLOUD_ACCOUNT_INCLUSTER) &&
cloudAccount.Status != domain.CloudAccountStatus_CREATE_ERROR {
return fmt.Errorf("The status is not CREATE_ERROR. %s", cloudAccount.Status)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/usecase/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (u *ClusterUsecase) Create(ctx context.Context, dto domain.Cluster) (cluste
if ca.ID == dto.CloudAccountId {

// FOR TEST. ADD MAGIC KEYWORD
if strings.Contains(ca.Name, "INCLUSTER") {
if strings.Contains(ca.Name, domain.CLOUD_ACCOUNT_INCLUSTER) {
tksCloudAccountId = "NULL"
}
isExist = true
Expand Down Expand Up @@ -237,7 +237,7 @@ func (u *ClusterUsecase) Delete(ctx context.Context, clusterId domain.ClusterId)
return httpErrors.NewInternalServerError(fmt.Errorf("Failed to get cloudAccount"), "", "")
}
tksCloudAccountId := cluster.CloudAccountId.String()
if strings.Contains(cloudAccount.Name, "INCLUSTER") {
if strings.Contains(cloudAccount.Name, domain.CLOUD_ACCOUNT_INCLUSTER) {
tksCloudAccountId = "NULL"
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/domain/cloud-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/google/uuid"
)

const CLOUD_ACCOUNT_INCLUSTER = "INCLUSTER"

const (
CloudService_UNDEFINED = "UNDEFINED"
CloudService_AWS = "AWS"
Expand Down