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

Reworked Go func to del old projects #20

Conversation

paulpalamarchuk
Copy link
Contributor

@paulpalamarchuk paulpalamarchuk commented Nov 1, 2019

@paulpalamarchuk paulpalamarchuk force-pushed the update_cleanup_func_with_new_input branch from f30cea8 to 54694ae Compare November 1, 2019 15:29
@morgante morgante requested a review from nick4fake November 1, 2019 16:38
@aaron-lane aaron-lane added the enhancement New feature or request label Nov 4, 2019
"fmt"
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"google.golang.org/api/cloudresourcemanager/v1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix import ordering, custom packages should be below standard one

if err != nil {
logger.Fatal(fmt.Sprintf("Could not convert %s to integer", maxAgeInHoursStr))
return err
const LifecycleStateActiveRequested = "ACTIVE"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put in in one const() block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved

ageFilter := func(project *cloudresourcemanager.Project) bool {
projectCreatedAt, err := time.Parse(time.RFC3339, project.CreateTime)
if err != nil {
logger.Println(fmt.Sprintf("Fail to parse CreateTime for [%s], skip it. Error [%s]", project.Name, err.Error()))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use logger.Printf for formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@paulpalamarchuk paulpalamarchuk changed the title Reworked Go fund to del old projects Reworked Go func to del old projects Nov 5, 2019
@paulpalamarchuk paulpalamarchuk force-pushed the update_cleanup_func_with_new_input branch 2 times, most recently from 224aa71 to 538ab28 Compare November 5, 2019 15:21
@morgante
Copy link
Contributor

morgante commented Nov 6, 2019

@paulpalamarchuk Is this ready for review? We need to get this done ASAP.

logger.Println("Try to get Cloud Resource Manager")
cloudResourceManagerService, err := cloudresourcemanager.New(client)
if err != nil {
logger.Println("Fail to get Cloud Resource Manager, terminate execution")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

client, err := google.DefaultClient(ctx, cloudresourcemanager.CloudPlatformScope)
if err != nil {
logger.Println("Fail to initialize Google client, terminate execution")
logger.Fatal(err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

cloudResourceManagerService, err := cloudresourcemanager2.New(client)
if err != nil {
logger.Println("Fail to get Folders Service, terminate execution")
logger.Fatal(err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

removeProjectsInFolder(folderId)
return nil
}); err != nil {
logger.Fatal(fmt.Sprintf("Fail to get subfolders for the forlder with id [%s], error [%s]", folderId, err.Error()))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@paulpalamarchuk paulpalamarchuk force-pushed the update_cleanup_func_with_new_input branch from 538ab28 to 52d39d5 Compare November 6, 2019 12:38
@paulpalamarchuk paulpalamarchuk marked this pull request as ready for review November 6, 2019 12:47
@paulpalamarchuk
Copy link
Contributor Author

@morgante PR ready for review

@paulpalamarchuk paulpalamarchuk force-pushed the update_cleanup_func_with_new_input branch from 52d39d5 to 1592406 Compare November 6, 2019 14:54
@paulpalamarchuk paulpalamarchuk force-pushed the update_cleanup_func_with_new_input branch from 1592406 to 89e6494 Compare November 6, 2019 15:03

variable "target_excluded_labels" {
type = map(string)
description = "Map of project lablels that won't be deleted."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description = "Map of project lablels that won't be deleted."
description = "Map of project labels that won't be deleted."


variable "target_included_labels" {
type = map(string)
description = "Map of project lablels that will be deleted."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description = "Map of project lablels that will be deleted."
description = "Map of project labels that will be deleted."

@@ -1,115 +0,0 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't remove go.sum.

@morgante morgante merged commit 4c6c87c into terraform-google-modules:master Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add infrastructure for cleaning up old test projects
4 participants