Skip to content

Commit

Permalink
Fixed infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Casperson committed Jul 28, 2024
1 parent a8dd053 commit 70091c8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions internal/steps/space_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ func (s SpaceExportStep) deleteProjectGroup(myclient *client.Client, projectGrou
}

func (s SpaceExportStep) deleteProject(myclient *client.Client, project *projects.Project) error {
fmt.Println("Attempting to delete project " + fmt.Sprint(project.ID))
if err := myclient.Projects.DeleteByID(project.ID); err != nil {
return err
}
Expand All @@ -473,6 +474,7 @@ func (s SpaceExportStep) deleteProject(myclient *client.Client, project *project
}

func (s SpaceExportStep) deleteFeed(myclient *client.Client, feed feeds.IFeed) error {
fmt.Println("Attempting to delete feed " + fmt.Sprint(feed.GetID()))
if err := myclient.Feeds.DeleteByID(feed.GetID()); err != nil {
return err
}
Expand All @@ -481,6 +483,7 @@ func (s SpaceExportStep) deleteFeed(myclient *client.Client, feed feeds.IFeed) e
}

func (s SpaceExportStep) deleteAccount(myclient *client.Client, account accounts.IAccount) error {
fmt.Println("Attempting to delete account " + fmt.Sprint(account.GetID()))
if err := myclient.Accounts.DeleteByID(account.GetID()); err != nil {
return err
}
Expand All @@ -506,8 +509,12 @@ func (s SpaceExportStep) renameAccount(myclient *client.Client, account accounts
if len(exactMatches) == 0 {
break
}

index++
}

fmt.Println("Attempting to rename account " + fmt.Sprint(account.GetID()))

account.SetName(account.GetName() + " (old " + fmt.Sprint(index) + ")")
if _, err := accounts.Update(myclient, account); err != nil {
return err
Expand Down Expand Up @@ -541,6 +548,7 @@ func (s SpaceExportStep) projectGroupExists(myclient *client.Client) (bool, *pro
}

func (s SpaceExportStep) deleteLibraryVariableSet(myclient *client.Client, lvs *variables.LibraryVariableSet) error {
fmt.Println("Attempting to delete lvs " + fmt.Sprint(lvs.GetID()))
if err := myclient.LibraryVariableSets.DeleteByID(lvs.ID); err != nil {
return err
}
Expand All @@ -567,8 +575,11 @@ func (s SpaceExportStep) renameLibraryVariableSet(myclient *client.Client, lvs *
if len(exactMatches) == 0 {
break
}

index++
}

fmt.Println("Attempting to rename lvs " + fmt.Sprint(lvs.GetID()))
lvs.Name = lvs.Name + " (old " + fmt.Sprint(index) + ")"
if _, err := libraryvariablesets.Update(myclient, lvs); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion octoterrawiz.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {
AwsS3Bucket: os.Getenv("AWS_DEFAULT_BUCKET"),
AwsS3BucketRegion: os.Getenv("AWS_DEFAULT_REGION"),
PromptForDelete: false,
UseContainerImages: true,
UseContainerImages: false,
AzureResourceGroupName: os.Getenv("OCTOTERRAWIZ_AZURE_RESOURCE_GROUP"),
AzureStorageAccountName: os.Getenv("OCTOTERRAWIZ_AZURE_STORAGE_ACCOUNT"),
AzureContainerName: os.Getenv("OCTOTERRAWIZ_AZURE_CONTAINER"),
Expand Down
1 change: 1 addition & 0 deletions octoterrawiz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ func TestProjectMigration(t *testing.T) {
AwsS3Bucket: os.Getenv("AWS_DEFAULT_BUCKET"),
AwsS3BucketRegion: os.Getenv("AWS_DEFAULT_REGION"),
PromptForDelete: false,
UseContainerImages: false,
AzureResourceGroupName: "",
AzureStorageAccountName: "",
AzureContainerName: "",
Expand Down

0 comments on commit 70091c8

Please sign in to comment.