From 8f747af6257d9a7a514e0c519186915b56ead21c Mon Sep 17 00:00:00 2001 From: Keegan Campbell Date: Fri, 18 Feb 2022 15:51:27 -0800 Subject: [PATCH] Standardize logs (#1053) * First batch of changes * Another batch of changes * More changes, maybe fix build * More log cleanup * Final changes * Fix one additional error message --- github/config.go | 4 ++-- .../data_source_github_actions_public_key.go | 2 -- github/data_source_github_branch.go | 3 +-- github/data_source_github_membership.go | 4 +--- github/data_source_github_organization.go | 2 -- ...ce_github_organization_team_sync_groups.go | 3 --- .../data_source_github_organization_teams.go | 3 --- github/data_source_github_release.go | 4 ---- github/data_source_github_repositories.go | 2 -- github/data_source_github_repository.go | 4 +--- github/data_source_github_repository_file.go | 1 - github/data_source_github_team.go | 2 -- github/data_source_github_user.go | 2 -- github/data_source_github_users.go | 7 +++--- github/migrate_github_repository_webhook.go | 7 +++--- github/provider.go | 4 ++-- github/provider_utils.go | 4 ++-- github/repository_utils.go | 8 +++---- ...ource_github_actions_environment_secret.go | 6 ++--- ...github_actions_organization_permissions.go | 2 -- ...urce_github_actions_organization_secret.go | 6 ++--- .../resource_github_actions_runner_group.go | 10 ++------- github/resource_github_actions_secret.go | 5 ++--- ...urce_github_app_installation_repository.go | 10 ++------- github/resource_github_branch.go | 10 +-------- github/resource_github_branch_default.go | 5 ----- github/resource_github_branch_protection.go | 22 +++++++++---------- .../resource_github_branch_protection_v3.go | 9 +------- ...ource_github_branch_protection_v3_utils.go | 5 +---- github/resource_github_issue_label.go | 16 ++------------ github/resource_github_membership.go | 5 +---- .../resource_github_organization_project.go | 8 +------ .../resource_github_organization_webhook.go | 7 +----- github/resource_github_project_card.go | 8 +------ github/resource_github_project_column.go | 7 +----- github/resource_github_repository.go | 9 ++------ ...ce_github_repository_autolink_reference.go | 4 ---- ...resource_github_repository_collaborator.go | 11 ++-------- .../resource_github_repository_deploy_key.go | 5 +---- .../resource_github_repository_environment.go | 7 +----- github/resource_github_repository_file.go | 9 ++------ .../resource_github_repository_milestone.go | 6 +---- github/resource_github_repository_project.go | 6 +---- ...resource_github_repository_pull_request.go | 4 ++-- github/resource_github_repository_test.go | 2 +- github/resource_github_repository_webhook.go | 6 +---- github/resource_github_team.go | 7 +----- github/resource_github_team_membership.go | 5 +---- github/resource_github_team_repository.go | 11 ++-------- ...resource_github_team_sync_group_mapping.go | 7 +----- github/resource_github_user_gpg_key.go | 5 +---- ...esource_github_user_invitation_accepter.go | 2 -- github/resource_github_user_ssh_key.go | 6 +---- github/resource_organization_block.go | 5 +---- github/transport.go | 4 ---- github/transport_test.go | 10 ++++----- 56 files changed, 78 insertions(+), 260 deletions(-) diff --git a/github/config.go b/github/config.go index 6b53179a40..e6c91af734 100644 --- a/github/config.go +++ b/github/config.go @@ -147,14 +147,14 @@ func (c *Config) Meta() (interface{}, error) { owner.v3client = v3client if c.Anonymous() { - log.Printf("[DEBUG] No token present; configuring anonymous owner.") + log.Printf("[INFO] No token present; configuring anonymous owner.") return &owner, nil } else { _, err = c.ConfigureOwner(&owner) if err != nil { return &owner, err } - log.Printf("[DEBUG] Token present; configuring authenticated owner: %s", owner.name) + log.Printf("[INFO] Token present; configuring authenticated owner: %s", owner.name) return &owner, nil } } diff --git a/github/data_source_github_actions_public_key.go b/github/data_source_github_actions_public_key.go index 184ed861a1..cdf22f2e2c 100644 --- a/github/data_source_github_actions_public_key.go +++ b/github/data_source_github_actions_public_key.go @@ -2,7 +2,6 @@ package github import ( "context" - "log" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) @@ -31,7 +30,6 @@ func dataSourceGithubActionsPublicKey() *schema.Resource { func dataSourceGithubActionsPublicKeyRead(d *schema.ResourceData, meta interface{}) error { repository := d.Get("repository").(string) owner := meta.(*Owner).name - log.Printf("[INFO] Refreshing GitHub Actions Public Key from: %s/%s", owner, repository) client := meta.(*Owner).v3client ctx := context.Background() diff --git a/github/data_source_github_branch.go b/github/data_source_github_branch.go index ea1772df8d..38177fe92d 100644 --- a/github/data_source_github_branch.go +++ b/github/data_source_github_branch.go @@ -47,12 +47,11 @@ func dataSourceGithubBranchRead(d *schema.ResourceData, meta interface{}) error branchName := d.Get("branch").(string) branchRefName := "refs/heads/" + branchName - log.Printf("[DEBUG] Reading GitHub branch reference %s/%s (%s)", orgName, repoName, branchRefName) ref, resp, err := client.Git.GetRef(context.TODO(), orgName, repoName, branchRefName) if err != nil { if err, ok := err.(*github.ErrorResponse); ok { if err.Response.StatusCode == http.StatusNotFound { - log.Printf("Error reading GitHub branch reference %s/%s (%s): %s", orgName, repoName, branchRefName, err) + log.Printf("[INFO] Error reading GitHub branch reference %s/%s (%s): %s", orgName, repoName, branchRefName, err) d.SetId("") return nil } diff --git a/github/data_source_github_membership.go b/github/data_source_github_membership.go index 6d2b3f005e..ace0d9f657 100644 --- a/github/data_source_github_membership.go +++ b/github/data_source_github_membership.go @@ -2,7 +2,6 @@ package github import ( "context" - "log" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) @@ -34,11 +33,10 @@ func dataSourceGithubMembership() *schema.Resource { func dataSourceGithubMembershipRead(d *schema.ResourceData, meta interface{}) error { username := d.Get("username").(string) - log.Printf("[INFO] Refreshing GitHub membership: %s", username) client := meta.(*Owner).v3client - orgName := meta.(*Owner).name + if configuredOrg := d.Get("organization").(string); configuredOrg != "" { orgName = configuredOrg } diff --git a/github/data_source_github_organization.go b/github/data_source_github_organization.go index 5208f78e4c..75bed75a99 100644 --- a/github/data_source_github_organization.go +++ b/github/data_source_github_organization.go @@ -1,7 +1,6 @@ package github import ( - "log" "strconv" "github.com/google/go-github/v42/github" @@ -53,7 +52,6 @@ func dataSourceGithubOrganization() *schema.Resource { func dataSourceGithubOrganizationRead(d *schema.ResourceData, meta interface{}) error { name := d.Get("name").(string) - log.Printf("[INFO] Refreshing GitHub Organization: %s", name) client := meta.(*Owner).v3client ctx := meta.(*Owner).StopContext diff --git a/github/data_source_github_organization_team_sync_groups.go b/github/data_source_github_organization_team_sync_groups.go index c7668c9f0b..73a990b0da 100644 --- a/github/data_source_github_organization_team_sync_groups.go +++ b/github/data_source_github_organization_team_sync_groups.go @@ -3,7 +3,6 @@ package github import ( "context" "fmt" - "log" "github.com/google/go-github/v42/github" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -39,8 +38,6 @@ func dataSourceGithubOrganizationTeamSyncGroups() *schema.Resource { } func dataSourceGithubOrganizationTeamSyncGroupsRead(d *schema.ResourceData, meta interface{}) error { - log.Print("[INFO] Refreshing GitHub Organization Team-Sync Groups") - client := meta.(*Owner).v3client ctx := context.Background() diff --git a/github/data_source_github_organization_teams.go b/github/data_source_github_organization_teams.go index 1cca0feb3c..b7b6778534 100644 --- a/github/data_source_github_organization_teams.go +++ b/github/data_source_github_organization_teams.go @@ -3,7 +3,6 @@ package github import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/shurcooL/githubv4" - "log" ) func dataSourceGithubOrganizationTeams() *schema.Resource { @@ -72,8 +71,6 @@ func dataSourceGithubOrganizationTeamsRead(d *schema.ResourceData, meta interfac orgName := meta.(*Owner).name rootTeamsOnly := d.Get("root_teams_only").(bool) - log.Print("[INFO] Refreshing GitHub Teams for Organization: ", orgName) - var query TeamsQuery variables := map[string]interface{}{ "first": githubv4.Int(100), diff --git a/github/data_source_github_release.go b/github/data_source_github_release.go index 08f790b3ea..9aceeef731 100644 --- a/github/data_source_github_release.go +++ b/github/data_source_github_release.go @@ -3,7 +3,6 @@ package github import ( "context" "fmt" - "log" "strconv" "strings" @@ -111,7 +110,6 @@ func dataSourceGithubReleaseRead(d *schema.ResourceData, meta interface{}) error switch retrieveBy := strings.ToLower(d.Get("retrieve_by").(string)); retrieveBy { case "latest": - log.Printf("[INFO] Refreshing GitHub latest release from repository %s", repository) release, _, err = client.Repositories.GetLatestRelease(ctx, owner, repository) case "id": releaseID := int64(d.Get("release_id").(int)) @@ -119,7 +117,6 @@ func dataSourceGithubReleaseRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("`release_id` must be set when `retrieve_by` = `id`") } - log.Printf("[INFO] Refreshing GitHub release by id %d from repository %s", releaseID, repository) release, _, err = client.Repositories.GetRelease(ctx, owner, repository, releaseID) case "tag": tag := d.Get("release_tag").(string) @@ -127,7 +124,6 @@ func dataSourceGithubReleaseRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("`release_tag` must be set when `retrieve_by` = `tag`") } - log.Printf("[INFO] Refreshing GitHub release by tag %s from repository %s", tag, repository) release, _, err = client.Repositories.GetReleaseByTag(ctx, owner, repository, tag) default: return fmt.Errorf("one of: `latest`, `id`, `tag` must be set for `retrieve_by`") diff --git a/github/data_source_github_repositories.go b/github/data_source_github_repositories.go index af9fe77b56..3f8dae759a 100644 --- a/github/data_source_github_repositories.go +++ b/github/data_source_github_repositories.go @@ -2,7 +2,6 @@ package github import ( "context" - "log" "github.com/google/go-github/v42/github" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -53,7 +52,6 @@ func dataSourceGithubRepositoriesRead(d *schema.ResourceData, meta interface{}) }, } - log.Printf("[DEBUG] Searching for GitHub repositories: %q", query) fullNames, names, err := searchGithubRepositories(client, query, opt) if err != nil { return err diff --git a/github/data_source_github_repository.go b/github/data_source_github_repository.go index 3d6d4c555d..9a4d1b8896 100644 --- a/github/data_source_github_repository.go +++ b/github/data_source_github_repository.go @@ -3,7 +3,6 @@ package github import ( "context" "fmt" - "log" "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -199,10 +198,9 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er } if repoName == "" { - return fmt.Errorf("One of %q or %q has to be provided", "full_name", "name") + return fmt.Errorf("one of %q or %q has to be provided", "full_name", "name") } - log.Printf("[DEBUG] Reading GitHub repository %s/%s", owner, repoName) repo, _, err := client.Repositories.Get(context.TODO(), owner, repoName) if err != nil { return err diff --git a/github/data_source_github_repository_file.go b/github/data_source_github_repository_file.go index 79da02c757..8bb4cf06d0 100644 --- a/github/data_source_github_repository_file.go +++ b/github/data_source_github_repository_file.go @@ -76,7 +76,6 @@ func dataSourceGithubRepositoryFileRead(d *schema.ResourceData, meta interface{} return err } - log.Printf("[DEBUG] Data Source reading repository file: %s/%s/%s, branch: %s", owner, repo, file, branch) opts := &github.RepositoryContentGetOptions{Ref: branch} fc, _, _, err := client.Repositories.GetContents(ctx, owner, repo, file, opts) if err != nil { diff --git a/github/data_source_github_team.go b/github/data_source_github_team.go index 7bd0e01a0e..426d91abcb 100644 --- a/github/data_source_github_team.go +++ b/github/data_source_github_team.go @@ -2,7 +2,6 @@ package github import ( "context" - "log" "strconv" "github.com/google/go-github/v42/github" @@ -55,7 +54,6 @@ func dataSourceGithubTeam() *schema.Resource { func dataSourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { slug := d.Get("slug").(string) - log.Printf("[INFO] Refreshing GitHub Team: %s", slug) client := meta.(*Owner).v3client orgId := meta.(*Owner).id diff --git a/github/data_source_github_user.go b/github/data_source_github_user.go index 461fd64546..0c623dedd0 100644 --- a/github/data_source_github_user.go +++ b/github/data_source_github_user.go @@ -2,7 +2,6 @@ package github import ( "context" - "log" "strconv" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -101,7 +100,6 @@ func dataSourceGithubUser() *schema.Resource { func dataSourceGithubUserRead(d *schema.ResourceData, meta interface{}) error { username := d.Get("username").(string) - log.Printf("[INFO] Refreshing GitHub User: %s", username) client := meta.(*Owner).v3client ctx := context.Background() diff --git a/github/data_source_github_users.go b/github/data_source_github_users.go index f9363e3bfc..f6fa47d5f3 100644 --- a/github/data_source_github_users.go +++ b/github/data_source_github_users.go @@ -3,11 +3,11 @@ package github import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/shurcooL/githubv4" - "log" "reflect" "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/shurcooL/githubv4" ) func dataSourceGithubUsers() *schema.Resource { @@ -69,7 +69,6 @@ func dataSourceGithubUsersRead(d *schema.ResourceData, meta interface{}) error { query := reflect.New(reflect.StructOf(fields)).Elem() if len(usernames) > 0 { - log.Printf("[INFO] Refreshing GitHub Users: %s", strings.Join(usernames, ", ")) ctx := context.WithValue(context.Background(), ctxId, d.Id()) client := meta.(*Owner).v4client err := client.Query(ctx, query.Addr().Interface(), variables) diff --git a/github/migrate_github_repository_webhook.go b/github/migrate_github_repository_webhook.go index 99f6c3e89f..4cc8d74f60 100644 --- a/github/migrate_github_repository_webhook.go +++ b/github/migrate_github_repository_webhook.go @@ -11,16 +11,16 @@ import ( func resourceGithubWebhookMigrateState(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { switch v { case 0: - log.Println("[INFO] Found GitHub Webhook State v0; migrating to v1") + log.Printf("[INFO] Found GitHub Webhook State v0; migrating to v1") return migrateGithubWebhookStateV0toV1(is) default: - return is, fmt.Errorf("Unexpected schema version: %d", v) + return is, fmt.Errorf("unexpected schema version: %d", v) } } func migrateGithubWebhookStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { if is.Empty() { - log.Println("[DEBUG] Empty InstanceState; nothing to migrate.") + log.Printf("[DEBUG] Empty InstanceState; nothing to migrate.") return is, nil } @@ -48,7 +48,6 @@ func migrateGithubWebhookStateV0toV1(is *terraform.InstanceState) (*terraform.In } is.Attributes[prefix+"#"] = "1" - log.Printf("[DEBUG] GitHub Webhook Attributes after State Migration: %#v", is.Attributes) return is, nil diff --git a/github/provider.go b/github/provider.go index c051275a51..24b554940e 100644 --- a/github/provider.go +++ b/github/provider.go @@ -201,7 +201,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc { org := d.Get("organization").(string) if org != "" { - log.Printf("[DEBUG] Selecting organization attribute as owner: %s", org) + log.Printf("[INFO] Selecting organization attribute as owner: %s", org) owner = org } @@ -247,7 +247,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc { if writeDelay <= 0 { return nil, fmt.Errorf("write_delay_ms must be greater than 0ms") } - log.Printf("[DEBUG] Setting write_delay_ms to %d", writeDelay) + log.Printf("[INFO] Setting write_delay_ms to %d", writeDelay) config := Config{ Token: token, diff --git a/github/provider_utils.go b/github/provider_utils.go index 3672c7508d..3b52353f6b 100644 --- a/github/provider_utils.go +++ b/github/provider_utils.go @@ -98,11 +98,11 @@ func testAccCheckOrganization() error { func OwnerOrOrgEnvDefaultFunc() (interface{}, error) { if organization := os.Getenv("GITHUB_ORGANIZATION"); organization != "" { - log.Printf("[DEBUG] Selecting owner %s from GITHUB_ORGANIZATION environment variable", organization) + log.Printf("[INFO] Selecting owner %s from GITHUB_ORGANIZATION environment variable", organization) return organization, nil } owner := os.Getenv("GITHUB_OWNER") - log.Printf("[DEBUG] Selecting owner %s from GITHUB_OWNER environment variable", owner) + log.Printf("[INFO] Selecting owner %s from GITHUB_OWNER environment variable", owner) return owner, nil } diff --git a/github/repository_utils.go b/github/repository_utils.go index 2940005b0b..034bf77288 100644 --- a/github/repository_utils.go +++ b/github/repository_utils.go @@ -3,7 +3,6 @@ package github import ( "context" "fmt" - "log" "net/http" "strings" @@ -17,7 +16,7 @@ func checkRepositoryBranchExists(client *github.Client, owner, repo, branch stri if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { if ghErr.Response.StatusCode == http.StatusNotFound { - return fmt.Errorf("Branch %s not found in repository %s/%s or repository is not readable", branch, owner, repo) + return fmt.Errorf("branch %s not found in repository %s/%s or repository is not readable", branch, owner, repo) } } return err @@ -34,7 +33,7 @@ func checkRepositoryFileExists(client *github.Client, owner, repo, file, branch return nil } if fc == nil { - return fmt.Errorf("File %s not a file in in repository %s/%s or repository is not readable", file, owner, repo) + return fmt.Errorf("file %s not a file in in repository %s/%s or repository is not readable", file, owner, repo) } return nil @@ -77,11 +76,10 @@ func getFileCommit(client *github.Client, owner, repo, file, branch string) (*gi for _, f := range rc.Files { if f.GetFilename() == file && f.GetStatus() != "removed" { - log.Printf("[DEBUG] Found file: %s in commit: %s", file, sha) return rc, nil } } } - return nil, fmt.Errorf("Cannot find file %s in repo %s/%s", file, owner, repo) + return nil, fmt.Errorf("cannot find file %s in repo %s/%s", file, owner, repo) } diff --git a/github/resource_github_actions_environment_secret.go b/github/resource_github_actions_environment_secret.go index 431105df78..d0b4dde4f7 100644 --- a/github/resource_github_actions_environment_secret.go +++ b/github/resource_github_actions_environment_secret.go @@ -127,7 +127,7 @@ func resourceGithubActionsEnvironmentSecretRead(d *schema.ResourceData, meta int if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing environment secret %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing environment secret %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -156,7 +156,7 @@ func resourceGithubActionsEnvironmentSecretRead(d *schema.ResourceData, meta int // as deleted (unset the ID) in order to fix potential drift by recreating // the resource. if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() { - log.Printf("[WARN] The environment secret %s has been externally updated in GitHub", d.Id()) + log.Printf("[INFO] The environment secret %s has been externally updated in GitHub", d.Id()) d.SetId("") } else if !ok { d.Set("updated_at", secret.UpdatedAt.String()) @@ -178,7 +178,7 @@ func resourceGithubActionsEnvironmentSecretDelete(d *schema.ResourceData, meta i if err != nil { return err } - log.Printf("[DEBUG] Deleting environment secret: %s", d.Id()) + log.Printf("[INFO] Deleting environment secret: %s", d.Id()) _, err = client.Actions.DeleteEnvSecret(ctx, int(repo.GetID()), envName, secretName) return err diff --git a/github/resource_github_actions_organization_permissions.go b/github/resource_github_actions_organization_permissions.go index c48a51f866..ab68193d2a 100644 --- a/github/resource_github_actions_organization_permissions.go +++ b/github/resource_github_actions_organization_permissions.go @@ -3,7 +3,6 @@ package github import ( "context" "errors" - "log" "github.com/google/go-github/v42/github" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -110,7 +109,6 @@ func resourceGithubActionsEnabledRepositoriesObject(d *schema.ResourceData) ([]i var enabled []int64 config := d.Get("enabled_repositories_config").([]interface{}) - log.Printf("[help] length of config in actopms enabled is %v", len(config)) if len(config) > 0 { data := config[0].(map[string]interface{}) switch x := data["repository_ids"].(type) { diff --git a/github/resource_github_actions_organization_secret.go b/github/resource_github_actions_organization_secret.go index 9bf66fa38d..bf9b576309 100644 --- a/github/resource_github_actions_organization_secret.go +++ b/github/resource_github_actions_organization_secret.go @@ -141,7 +141,7 @@ func resourceGithubActionsOrganizationSecretRead(d *schema.ResourceData, meta in if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing actions secret %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing actions secret %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -196,7 +196,7 @@ func resourceGithubActionsOrganizationSecretRead(d *schema.ResourceData, meta in // as deleted (unset the ID) in order to fix potential drift by recreating // the resource. if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() { - log.Printf("[WARN] The secret %s has been externally updated in GitHub", d.Id()) + log.Printf("[INFO] The secret %s has been externally updated in GitHub", d.Id()) d.SetId("") } else if !ok { d.Set("updated_at", secret.UpdatedAt.String()) @@ -210,7 +210,7 @@ func resourceGithubActionsOrganizationSecretDelete(d *schema.ResourceData, meta orgName := meta.(*Owner).name ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting secret: %s", d.Id()) + log.Printf("[INFO] Deleting secret: %s", d.Id()) _, err := client.Actions.DeleteOrgSecret(ctx, orgName, d.Id()) return err } diff --git a/github/resource_github_actions_runner_group.go b/github/resource_github_actions_runner_group.go index e7ef70f603..98c1d6494e 100644 --- a/github/resource_github_actions_runner_group.go +++ b/github/resource_github_actions_runner_group.go @@ -96,7 +96,6 @@ func resourceGithubActionsRunnerGroupCreate(d *schema.ResourceData, meta interfa ctx := context.Background() - log.Printf("[DEBUG] Creating organization runner group: %s (%s)", name, orgName) runnerGroup, resp, err := client.Actions.CreateOrganizationRunnerGroup(ctx, orgName, github.CreateRunnerGroupRequest{ @@ -141,7 +140,6 @@ func resourceGithubActionsRunnerGroupRead(d *schema.ResourceData, meta interface ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading organization runner group: %s (%s)", d.Id(), orgName) runnerGroup, resp, err := client.Actions.GetOrganizationRunnerGroup(ctx, orgName, runnerGroupID) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -149,7 +147,7 @@ func resourceGithubActionsRunnerGroupRead(d *schema.ResourceData, meta interface return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing organization runner group %s/%s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing organization runner group %s/%s from state because it no longer exists in GitHub", orgName, d.Id()) d.SetId("") return nil @@ -168,7 +166,6 @@ func resourceGithubActionsRunnerGroupRead(d *schema.ResourceData, meta interface d.Set("selected_repositories_url", runnerGroup.GetSelectedRepositoriesURL()) d.Set("visibility", runnerGroup.GetVisibility()) - log.Printf("[DEBUG] Reading organization runner group repositories: %s (%s)", d.Id(), orgName) selectedRepositoryIDs := []int64{} options := github.ListOptions{ PerPage: maxPerPage, @@ -191,7 +188,6 @@ func resourceGithubActionsRunnerGroupRead(d *schema.ResourceData, meta interface options.Page = resp.NextPage } - log.Printf("[DEBUG] Got selected_repository_ids: %v", selectedRepositoryIDs) d.Set("selected_repository_ids", selectedRepositoryIDs) return nil @@ -220,7 +216,6 @@ func resourceGithubActionsRunnerGroupUpdate(d *schema.ResourceData, meta interfa } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating organization runner group: %s (%s)", d.Id(), orgName) if _, _, err := client.Actions.UpdateOrganizationRunnerGroup(ctx, orgName, runnerGroupID, options); err != nil { return err } @@ -238,7 +233,6 @@ func resourceGithubActionsRunnerGroupUpdate(d *schema.ResourceData, meta interfa reposOptions := github.SetRepoAccessRunnerGroupRequest{SelectedRepositoryIDs: selectedRepositoryIDs} - log.Printf("[DEBUG] Updating organization runner group's selected repositries: %s (%s)", d.Id(), orgName) if _, err := client.Actions.SetRepositoryAccessRunnerGroup(ctx, orgName, runnerGroupID, reposOptions); err != nil { return err } @@ -260,7 +254,7 @@ func resourceGithubActionsRunnerGroupDelete(d *schema.ResourceData, meta interfa } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting organization runner group: %s (%s)", d.Id(), orgName) + log.Printf("[INFO] Deleting organization runner group: %s (%s)", d.Id(), orgName) _, err = client.Actions.DeleteOrganizationRunnerGroup(ctx, orgName, runnerGroupID) return err } diff --git a/github/resource_github_actions_secret.go b/github/resource_github_actions_secret.go index 8fbb5c0dbb..44275d8656 100644 --- a/github/resource_github_actions_secret.go +++ b/github/resource_github_actions_secret.go @@ -111,7 +111,7 @@ func resourceGithubActionsSecretRead(d *schema.ResourceData, meta interface{}) e if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing actions secret %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing actions secret %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -140,7 +140,7 @@ func resourceGithubActionsSecretRead(d *schema.ResourceData, meta interface{}) e // as deleted (unset the ID) in order to fix potential drift by recreating // the resource. if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() { - log.Printf("[WARN] The secret %s has been externally updated in GitHub", d.Id()) + log.Printf("[INFO] The secret %s has been externally updated in GitHub", d.Id()) d.SetId("") } else if !ok { d.Set("updated_at", secret.UpdatedAt.String()) @@ -159,7 +159,6 @@ func resourceGithubActionsSecretDelete(d *schema.ResourceData, meta interface{}) return err } - log.Printf("[DEBUG] Deleting secret: %s", d.Id()) _, err = client.Actions.DeleteRepoSecret(ctx, orgName, repoName, secretName) return err diff --git a/github/resource_github_app_installation_repository.go b/github/resource_github_app_installation_repository.go index bdb4273e27..6f59341985 100644 --- a/github/resource_github_app_installation_repository.go +++ b/github/resource_github_app_installation_repository.go @@ -59,9 +59,6 @@ func resourceGithubAppInstallationRepositoryCreate(d *schema.ResourceData, meta } repoID := repo.GetID() - log.Printf("[DEBUG] Creating app installation repository association: %s:%s", - installationIDString, repoName) - _, _, err = client.Apps.AddRepository(ctx, installationID, repoID) if err != nil { return err @@ -97,7 +94,6 @@ func resourceGithubAppInstallationRepositoryRead(d *schema.ResourceData, meta in return err } - log.Printf("[DEBUG] Found %d repos, checking if any matches %s", repos.TotalCount, repoName) for _, r := range repos.Repositories { if r.GetName() == repoName { d.Set("installation_id", installationIDString) @@ -113,7 +109,7 @@ func resourceGithubAppInstallationRepositoryRead(d *schema.ResourceData, meta in opt.Page = resp.NextPage } - log.Printf("[WARN] Removing app installation repository association %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing app installation repository association %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -124,6 +120,7 @@ func resourceGithubAppInstallationRepositoryDelete(d *schema.ResourceData, meta if err != nil { return err } + installationIDString := d.Get("installation_id").(string) installationID, err := strconv.ParseInt(installationIDString, 10, 64) if err != nil { @@ -133,10 +130,7 @@ func resourceGithubAppInstallationRepositoryDelete(d *schema.ResourceData, meta client := meta.(*Owner).v3client ctx := context.Background() - repoName := d.Get("repository").(string) repoID := d.Get("repo_id").(int) - log.Printf("[DEBUG] Deleting app installation repository association: %s:%s", - installationIDString, repoName) _, err = client.Apps.RemoveRepository(ctx, installationID, int64(repoID)) if err != nil { diff --git a/github/resource_github_branch.go b/github/resource_github_branch.go index a8afccb744..a6353dc230 100644 --- a/github/resource_github_branch.go +++ b/github/resource_github_branch.go @@ -74,8 +74,6 @@ func resourceGithubBranchCreate(d *schema.ResourceData, meta interface{}) error sourceBranchRefName := "refs/heads/" + sourceBranchName if _, hasSourceSHA := d.GetOk("source_sha"); !hasSourceSHA { - log.Printf("[DEBUG] Querying GitHub branch reference %s/%s (%s) to derive source_sha", - orgName, repoName, sourceBranchRefName) ref, _, err := client.Git.GetRef(ctx, orgName, repoName, sourceBranchRefName) if err != nil { return fmt.Errorf("Error querying GitHub branch reference %s/%s (%s): %s", @@ -85,8 +83,6 @@ func resourceGithubBranchCreate(d *schema.ResourceData, meta interface{}) error } sourceBranchSHA := d.Get("source_sha").(string) - log.Printf("[DEBUG] Creating GitHub branch reference %s/%s (%s)", - orgName, repoName, branchRefName) _, _, err := client.Git.CreateRef(ctx, orgName, repoName, &github.Reference{ Ref: &branchRefName, Object: &github.GitObject{SHA: &sourceBranchSHA}, @@ -115,8 +111,6 @@ func resourceGithubBranchRead(d *schema.ResourceData, meta interface{}) error { } branchRefName := "refs/heads/" + branchName - log.Printf("[DEBUG] Querying GitHub branch reference %s/%s (%s)", - orgName, repoName, branchRefName) ref, resp, err := client.Git.GetRef(ctx, orgName, repoName, branchRefName) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -124,7 +118,7 @@ func resourceGithubBranchRead(d *schema.ResourceData, meta interface{}) error { return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing branch %s/%s (%s) from state because it no longer exists in Github", + log.Printf("[INFO] Removing branch %s/%s (%s) from state because it no longer exists in GitHub", orgName, repoName, branchName) d.SetId("") return nil @@ -155,8 +149,6 @@ func resourceGithubBranchDelete(d *schema.ResourceData, meta interface{}) error } branchRefName := "refs/heads/" + branchName - log.Printf("[DEBUG] Deleting GitHub branch reference %s/%s (%s)", - orgName, repoName, branchRefName) _, err = client.Git.DeleteRef(ctx, orgName, repoName, branchRefName) if err != nil { return fmt.Errorf("Error deleting GitHub branch reference %s/%s (%s): %s", diff --git a/github/resource_github_branch_default.go b/github/resource_github_branch_default.go index ee9a285b4d..2826714ad8 100644 --- a/github/resource_github_branch_default.go +++ b/github/resource_github_branch_default.go @@ -2,7 +2,6 @@ package github import ( "context" - "log" "github.com/google/go-github/v42/github" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -45,7 +44,6 @@ func resourceGithubBranchDefaultCreate(d *schema.ResourceData, meta interface{}) ctx := context.Background() - log.Printf("[DEBUG] Creating branch default: %s (%s/%s)", defaultBranch, owner, repoName) if _, _, err := client.Repositories.Edit(ctx, owner, repoName, repository); err != nil { return err } @@ -83,7 +81,6 @@ func resourceGithubBranchDefaultDelete(d *schema.ResourceData, meta interface{}) client := meta.(*Owner).v3client owner := meta.(*Owner).name repoName := d.Id() - defaultBranch := d.Get("branch").(string) repository := &github.Repository{ DefaultBranch: nil, @@ -91,7 +88,6 @@ func resourceGithubBranchDefaultDelete(d *schema.ResourceData, meta interface{}) ctx := context.Background() - log.Printf("[DEBUG] Removing branch default: %s (%s/%s)", defaultBranch, owner, repoName) _, _, err := client.Repositories.Edit(ctx, owner, repoName, repository) return err } @@ -109,7 +105,6 @@ func resourceGithubBranchDefaultUpdate(d *schema.ResourceData, meta interface{}) ctx := context.Background() - log.Printf("[DEBUG] Updating branch default: %s (%s/%s)", defaultBranch, owner, repoName) if _, _, err := client.Repositories.Edit(ctx, owner, repoName, repository); err != nil { return err } diff --git a/github/resource_github_branch_protection.go b/github/resource_github_branch_protection.go index 852b3ff34e..2cd3c647ef 100644 --- a/github/resource_github_branch_protection.go +++ b/github/resource_github_branch_protection.go @@ -193,7 +193,7 @@ func resourceGithubBranchProtectionRead(d *schema.ResourceData, meta interface{} err := client.Query(ctx, &query, variables) if err != nil { if strings.Contains(err.Error(), "Could not resolve to a node with the global id") { - log.Printf("[WARN] Removing branch protection (%s) from state because it no longer exists in GitHub", d.Id()) + log.Printf("[INFO] Removing branch protection (%s) from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil } @@ -205,55 +205,55 @@ func resourceGithubBranchProtectionRead(d *schema.ResourceData, meta interface{} err = d.Set(PROTECTION_PATTERN, protection.Pattern) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_PATTERN, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_PATTERN, protection.Repository.Name, protection.Pattern, d.Id()) } err = d.Set(PROTECTION_ALLOWS_DELETIONS, protection.AllowsDeletions) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_ALLOWS_DELETIONS, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_ALLOWS_DELETIONS, protection.Repository.Name, protection.Pattern, d.Id()) } err = d.Set(PROTECTION_ALLOWS_FORCE_PUSHES, protection.AllowsForcePushes) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_ALLOWS_FORCE_PUSHES, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_ALLOWS_FORCE_PUSHES, protection.Repository.Name, protection.Pattern, d.Id()) } err = d.Set(PROTECTION_IS_ADMIN_ENFORCED, protection.IsAdminEnforced) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_IS_ADMIN_ENFORCED, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_IS_ADMIN_ENFORCED, protection.Repository.Name, protection.Pattern, d.Id()) } err = d.Set(PROTECTION_REQUIRES_COMMIT_SIGNATURES, protection.RequiresCommitSignatures) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_COMMIT_SIGNATURES, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_COMMIT_SIGNATURES, protection.Repository.Name, protection.Pattern, d.Id()) } err = d.Set(PROTECTION_REQUIRES_LINEAR_HISTORY, protection.RequiresLinearHistory) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_LINEAR_HISTORY, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_LINEAR_HISTORY, protection.Repository.Name, protection.Pattern, d.Id()) } err = d.Set(PROTECTION_REQUIRES_CONVERSATION_RESOLUTION, protection.RequiresConversationResolution) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_CONVERSATION_RESOLUTION, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_CONVERSATION_RESOLUTION, protection.Repository.Name, protection.Pattern, d.Id()) } approvingReviews := setApprovingReviews(protection) err = d.Set(PROTECTION_REQUIRES_APPROVING_REVIEWS, approvingReviews) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_APPROVING_REVIEWS, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_APPROVING_REVIEWS, protection.Repository.Name, protection.Pattern, d.Id()) } statusChecks := setStatusChecks(protection) err = d.Set(PROTECTION_REQUIRES_STATUS_CHECKS, statusChecks) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_STATUS_CHECKS, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_STATUS_CHECKS, protection.Repository.Name, protection.Pattern, d.Id()) } restrictsPushes := setPushes(protection) err = d.Set(PROTECTION_RESTRICTS_PUSHES, restrictsPushes) if err != nil { - log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_RESTRICTS_PUSHES, protection.Repository.Name, protection.Pattern, d.Id()) + log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_RESTRICTS_PUSHES, protection.Repository.Name, protection.Pattern, d.Id()) } return nil diff --git a/github/resource_github_branch_protection_v3.go b/github/resource_github_branch_protection_v3.go index 68b44cc6c0..7cdd080be8 100644 --- a/github/resource_github_branch_protection_v3.go +++ b/github/resource_github_branch_protection_v3.go @@ -171,8 +171,6 @@ func resourceGithubBranchProtectionV3Create(d *schema.ResourceData, meta interfa } ctx := context.Background() - log.Printf("[DEBUG] Creating branch protection: %s/%s (%s)", - orgName, repoName, branch) protection, _, err := client.Repositories.UpdateBranchProtection(ctx, orgName, repoName, @@ -215,8 +213,6 @@ func resourceGithubBranchProtectionV3Read(d *schema.ResourceData, meta interface ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading branch protection: %s/%s (%s)", - orgName, repoName, branch) githubProtection, resp, err := client.Repositories.GetBranchProtection(ctx, orgName, repoName, branch) if err != nil { @@ -228,7 +224,7 @@ func resourceGithubBranchProtectionV3Read(d *schema.ResourceData, meta interface return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing branch protection %s/%s (%s) from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing branch protection %s/%s (%s) from state because it no longer exists in GitHub", orgName, repoName, branch) d.SetId("") return nil @@ -285,8 +281,6 @@ func resourceGithubBranchProtectionV3Update(d *schema.ResourceData, meta interfa orgName := meta.(*Owner).name ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating branch protection: %s/%s (%s)", - orgName, repoName, branch) protection, _, err := client.Repositories.UpdateBranchProtection(ctx, orgName, repoName, @@ -336,7 +330,6 @@ func resourceGithubBranchProtectionV3Delete(d *schema.ResourceData, meta interfa orgName := meta.(*Owner).name ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting branch protection: %s/%s (%s)", orgName, repoName, branch) _, err = client.Repositories.RemoveBranchProtection(ctx, orgName, repoName, branch) return err diff --git a/github/resource_github_branch_protection_v3_utils.go b/github/resource_github_branch_protection_v3_utils.go index 601f55c12e..2c4bf8b37a 100644 --- a/github/resource_github_branch_protection_v3_utils.go +++ b/github/resource_github_branch_protection_v3_utils.go @@ -71,11 +71,10 @@ func requireSignedCommitsRead(d *schema.ResourceData, meta interface{}) error { ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading branch protection signed commit status: %s/%s (%s)", orgName, repoName, branch) signedCommitStatus, _, err := client.Repositories.GetSignaturesProtectedBranch(ctx, orgName, repoName, branch) if err != nil { - log.Printf("[WARN] Not able to read signature protection: %s/%s (%s)", orgName, repoName, branch) + log.Printf("[INFO] Not able to read signature protection: %s/%s (%s)", orgName, repoName, branch) return nil } @@ -98,10 +97,8 @@ func requireSignedCommitsUpdate(d *schema.ResourceData, meta interface{}) (err e } if requiredSignedCommit { - log.Printf("[DEBUG] Enabling branch protection signed commit: %s/%s (%s) - $s", orgName, repoName, branch) _, _, err = client.Repositories.RequireSignaturesOnProtectedBranch(ctx, orgName, repoName, branch) } else { - log.Printf("[DEBUG] Removing branch protection signed commit: %s/%s (%s) - $s", orgName, repoName, branch) _, err = client.Repositories.OptionalSignaturesOnProtectedBranch(ctx, orgName, repoName, branch) } return err diff --git a/github/resource_github_issue_label.go b/github/resource_github_issue_label.go index 672192a87d..3a60fba397 100644 --- a/github/resource_github_issue_label.go +++ b/github/resource_github_issue_label.go @@ -88,8 +88,6 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta interfa } } - log.Printf("[DEBUG] Querying label existence: %s (%s/%s)", - name, orgName, repoName) existing, resp, err := client.Issues.GetLabel(ctx, orgName, repoName, originalName) if err != nil && resp.StatusCode != http.StatusNotFound { @@ -99,9 +97,6 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta interfa if existing != nil { label.Description = github.String(d.Get("description").(string)) - log.Printf("[DEBUG] Updating label: %s:%s (%s/%s)", - name, color, orgName, repoName) - // Pull out the original name. If we already have a resource, this is the // parsed ID. If not, it's the value given to the resource. var originalName string @@ -125,13 +120,8 @@ func resourceGithubIssueLabelCreateOrUpdate(d *schema.ResourceData, meta interfa label.Description = github.String(v.(string)) } - log.Printf("[DEBUG] Creating label: %s:%s (%s/%s)", - name, color, orgName, repoName) - _, resp, err := client.Issues.CreateLabel(ctx, + _, _, err := client.Issues.CreateLabel(ctx, orgName, repoName, label) - if resp != nil { - log.Printf("[DEBUG] Response from creating label: %#v", *resp) - } if err != nil { return err } @@ -155,7 +145,6 @@ func resourceGithubIssueLabelRead(d *schema.ResourceData, meta interface{}) erro ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading label: %s (%s/%s)", name, orgName, repoName) githubLabel, resp, err := client.Issues.GetLabel(ctx, orgName, repoName, name) if err != nil { @@ -164,7 +153,7 @@ func resourceGithubIssueLabelRead(d *schema.ResourceData, meta interface{}) erro return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing label %s (%s/%s) from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing label %s (%s/%s) from state because it no longer exists in GitHub", name, orgName, repoName) d.SetId("") return nil @@ -191,7 +180,6 @@ func resourceGithubIssueLabelDelete(d *schema.ResourceData, meta interface{}) er name := d.Get("name").(string) ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting label: %s (%s/%s)", name, orgName, repoName) _, err := client.Issues.DeleteLabel(ctx, orgName, repoName, name) return err diff --git a/github/resource_github_membership.go b/github/resource_github_membership.go index 68d0adaf9d..9f5bc6e9dc 100644 --- a/github/resource_github_membership.go +++ b/github/resource_github_membership.go @@ -56,7 +56,6 @@ func resourceGithubMembershipCreateOrUpdate(d *schema.ResourceData, meta interfa ctx = context.WithValue(ctx, ctxId, d.Id()) } - log.Printf("[DEBUG] Creating membership: %s/%s", orgName, username) _, _, err = client.Organizations.EditOrgMembership(ctx, username, orgName, @@ -91,7 +90,6 @@ func resourceGithubMembershipRead(d *schema.ResourceData, meta interface{}) erro ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading membership: %s", d.Id()) membership, resp, err := client.Organizations.GetOrgMembership(ctx, username, orgName) if err != nil { @@ -100,7 +98,7 @@ func resourceGithubMembershipRead(d *schema.ResourceData, meta interface{}) erro return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing membership %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing membership %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -126,7 +124,6 @@ func resourceGithubMembershipDelete(d *schema.ResourceData, meta interface{}) er orgName := meta.(*Owner).name ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting membership: %s", d.Id()) _, err = client.Organizations.RemoveOrgMembership(ctx, d.Get("username").(string), orgName) diff --git a/github/resource_github_organization_project.go b/github/resource_github_organization_project.go index d66611f54a..f0aba3f195 100644 --- a/github/resource_github_organization_project.go +++ b/github/resource_github_organization_project.go @@ -54,7 +54,6 @@ func resourceGithubOrganizationProjectCreate(d *schema.ResourceData, meta interf body := d.Get("body").(string) ctx := context.Background() - log.Printf("[DEBUG] Creating organization project: %s (%s)", name, orgName) project, _, err := client.Organizations.CreateProject(ctx, orgName, &github.ProjectOptions{ @@ -88,7 +87,6 @@ func resourceGithubOrganizationProjectRead(d *schema.ResourceData, meta interfac ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading organization project: %s (%s)", d.Id(), orgName) project, resp, err := client.Projects.GetProject(ctx, projectID) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -96,7 +94,7 @@ func resourceGithubOrganizationProjectRead(d *schema.ResourceData, meta interfac return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing organization project %s/%s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing organization project %s/%s from state because it no longer exists in GitHub", orgName, d.Id()) d.SetId("") return nil @@ -121,7 +119,6 @@ func resourceGithubOrganizationProjectUpdate(d *schema.ResourceData, meta interf } client := meta.(*Owner).v3client - orgName := meta.(*Owner).name name := d.Get("name").(string) body := d.Get("body").(string) @@ -137,7 +134,6 @@ func resourceGithubOrganizationProjectUpdate(d *schema.ResourceData, meta interf } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating organization project: %s (%s)", d.Id(), orgName) if _, _, err := client.Projects.UpdateProject(ctx, projectID, &options); err != nil { return err } @@ -152,14 +148,12 @@ func resourceGithubOrganizationProjectDelete(d *schema.ResourceData, meta interf } client := meta.(*Owner).v3client - orgName := meta.(*Owner).name projectID, err := strconv.ParseInt(d.Id(), 10, 64) if err != nil { return err } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting organization project: %s (%s)", d.Id(), orgName) _, err = client.Projects.DeleteProject(ctx, projectID) return err } diff --git a/github/resource_github_organization_webhook.go b/github/resource_github_organization_webhook.go index c9f1661be4..b35fda6ffe 100644 --- a/github/resource_github_organization_webhook.go +++ b/github/resource_github_organization_webhook.go @@ -87,7 +87,6 @@ func resourceGithubOrganizationWebhookCreate(d *schema.ResourceData, meta interf webhookObj := resourceGithubOrganizationWebhookObject(d) ctx := context.Background() - log.Printf("[DEBUG] Creating organization webhook: %d (%s)", webhookObj.GetID(), orgName) hook, _, err := client.Organizations.CreateHook(ctx, orgName, webhookObj) if err != nil { @@ -124,7 +123,6 @@ func resourceGithubOrganizationWebhookRead(d *schema.ResourceData, meta interfac ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading organization webhook: %s (%s)", d.Id(), orgName) hook, resp, err := client.Organizations.GetHook(ctx, orgName, hookID) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -132,7 +130,7 @@ func resourceGithubOrganizationWebhookRead(d *schema.ResourceData, meta interfac return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing organization webhook %s/%s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing organization webhook %s/%s from state because it no longer exists in GitHub", orgName, d.Id()) d.SetId("") return nil @@ -181,8 +179,6 @@ func resourceGithubOrganizationWebhookUpdate(d *schema.ResourceData, meta interf } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating organization webhook: %s (%s)", d.Id(), orgName) - _, _, err = client.Organizations.EditHook(ctx, orgName, hookID, webhookObj) if err != nil { @@ -207,7 +203,6 @@ func resourceGithubOrganizationWebhookDelete(d *schema.ResourceData, meta interf } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting organization webhook: %s (%s)", d.Id(), orgName) _, err = client.Organizations.DeleteHook(ctx, orgName, hookID) return err } diff --git a/github/resource_github_project_card.go b/github/resource_github_project_card.go index 14056d6b0a..5cce7d3dc9 100644 --- a/github/resource_github_project_card.go +++ b/github/resource_github_project_card.go @@ -54,7 +54,6 @@ func resourceGithubProjectCardCreate(d *schema.ResourceData, meta interface{}) e return unconvertibleIdErr(columnIDStr, err) } - log.Printf("[DEBUG] Creating project card note in column ID: %d", columnID) client := meta.(*Owner).v3client options := github.ProjectCardOptions{Note: d.Get("note").(string)} ctx := context.Background() @@ -71,19 +70,17 @@ func resourceGithubProjectCardCreate(d *schema.ResourceData, meta interface{}) e func resourceGithubProjectCardRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*Owner).v3client - nodeID := d.Id() cardID := d.Get("card_id").(int) ctx := context.WithValue(context.Background(), ctxId, d.Id()) if !d.IsNewResource() { ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading project card: %s", nodeID) card, _, err := client.Projects.GetProjectCard(ctx, int64(cardID)) if err != nil { if err, ok := err.(*github.ErrorResponse); ok { if err.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing project card %s from state because it no longer exists in GitHub", d.Id()) + log.Printf("[INFO] Removing project card %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil } @@ -109,7 +106,6 @@ func resourceGithubProjectCardUpdate(d *schema.ResourceData, meta interface{}) e client := meta.(*Owner).v3client cardID := d.Get("card_id").(int) - log.Printf("[DEBUG] Updating project Card: %s", d.Id()) options := github.ProjectCardOptions{ Note: d.Get("note").(string), } @@ -126,7 +122,6 @@ func resourceGithubProjectCardDelete(d *schema.ResourceData, meta interface{}) e client := meta.(*Owner).v3client ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting project Card: %s", d.Id()) cardID := d.Get("card_id").(int) _, err := client.Projects.DeleteProjectCard(ctx, int64(cardID)) if err != nil { @@ -144,7 +139,6 @@ func resourceGithubProjectCardImport(d *schema.ResourceData, meta interface{}) ( return []*schema.ResourceData{d}, unconvertibleIdErr(cardIDStr, err) } - log.Printf("[DEBUG] Importing project card with card ID: %d", cardID) client := meta.(*Owner).v3client ctx := context.Background() card, _, err := client.Projects.GetProjectCard(ctx, cardID) diff --git a/github/resource_github_project_column.go b/github/resource_github_project_column.go index c4c28218d4..14e7a14326 100644 --- a/github/resource_github_project_column.go +++ b/github/resource_github_project_column.go @@ -62,8 +62,6 @@ func resourceGithubProjectColumnCreate(d *schema.ResourceData, meta interface{}) } ctx := context.Background() - orgName := meta.(*Owner).name - log.Printf("[DEBUG] Creating project column (%s) in project %d (%s)", options.Name, projectID, orgName) column, _, err := client.Projects.CreateProjectColumn(ctx, projectID, &options, @@ -90,12 +88,11 @@ func resourceGithubProjectColumnRead(d *schema.ResourceData, meta interface{}) e ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading project column: %s", d.Id()) column, _, err := client.Projects.GetProjectColumn(ctx, columnID) if err != nil { if err, ok := err.(*github.ErrorResponse); ok { if err.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing project column %s from state because it no longer exists in GitHub", d.Id()) + log.Printf("[INFO] Removing project column %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil } @@ -125,7 +122,6 @@ func resourceGithubProjectColumnUpdate(d *schema.ResourceData, meta interface{}) } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating project column: %s", d.Id()) _, _, err = client.Projects.UpdateProjectColumn(ctx, columnID, &options) if err != nil { return err @@ -143,7 +139,6 @@ func resourceGithubProjectColumnDelete(d *schema.ResourceData, meta interface{}) } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting project column: %s", d.Id()) _, err = client.Projects.DeleteProjectColumn(ctx, columnID) return err } diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index a7156c5566..d8a16ee611 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -313,8 +313,6 @@ func resourceGithubRepositoryCreate(d *schema.ResourceData, meta interface{}) er repoName := repoReq.GetName() ctx := context.Background() - log.Printf("[DEBUG] Creating repository: %s/%s", owner, repoName) - // determine if repository should be private. assume public to start isPrivate := false @@ -403,8 +401,6 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro owner := meta.(*Owner).name repoName := d.Id() - log.Printf("[DEBUG] Reading repository: %s/%s", owner, repoName) - ctx := context.WithValue(context.Background(), ctxId, d.Id()) if !d.IsNewResource() { ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) @@ -417,7 +413,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing repository %s/%s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository %s/%s from state because it no longer exists in GitHub", owner, repoName) d.SetId("") return nil @@ -494,7 +490,7 @@ func resourceGithubRepositoryUpdate(d *schema.ResourceData, meta interface{}) er // Can only update a repository if it is not archived or the update is to // archive the repository (unarchiving is not supported by the Github API) if d.Get("archived").(bool) && !d.HasChange("archived") { - log.Printf("[DEBUG] Skipping update of archived repository") + log.Printf("[INFO] Skipping update of archived repository") return nil } @@ -517,7 +513,6 @@ func resourceGithubRepositoryUpdate(d *schema.ResourceData, meta interface{}) er owner := meta.(*Owner).name ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating repository: %s/%s", owner, repoName) repo, _, err := client.Repositories.Edit(ctx, owner, repoName, repoReq) if err != nil { return err diff --git a/github/resource_github_repository_autolink_reference.go b/github/resource_github_repository_autolink_reference.go index 32084abb6a..5546da16c7 100644 --- a/github/resource_github_repository_autolink_reference.go +++ b/github/resource_github_repository_autolink_reference.go @@ -3,7 +3,6 @@ package github import ( "context" "fmt" - "log" "regexp" "strconv" "strings" @@ -74,7 +73,6 @@ func resourceGithubRepositoryAutolinkReferenceCreate(d *schema.ResourceData, met URLTemplate: &targetURLTemplate, } - log.Printf("[DEBUG] Creating repository autolink reference: %s -> %s (%s/%s)", keyPrefix, targetURLTemplate, owner, repoName) autolinkRef, _, err := client.Repositories.AddAutolink(ctx, owner, repoName, opts) if err != nil { return err @@ -98,7 +96,6 @@ func resourceGithubRepositoryAutolinkReferenceRead(d *schema.ResourceData, meta ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading repository autolink reference: %s (%s/%s)", d.Id(), owner, repoName) autolinkRef, _, err := client.Repositories.GetAutolink(ctx, owner, repoName, autolinkRefID) if err != nil { return err @@ -124,7 +121,6 @@ func resourceGithubRepositoryAutolinkReferenceDelete(d *schema.ResourceData, met } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting repository autolink reference: %s (%s/%s)", d.Id(), owner, repoName) _, err = client.Repositories.DeleteAutolink(ctx, owner, repoName, autolinkRefID) return err } diff --git a/github/resource_github_repository_collaborator.go b/github/resource_github_repository_collaborator.go index 047f385ac9..635956d01f 100644 --- a/github/resource_github_repository_collaborator.go +++ b/github/resource_github_repository_collaborator.go @@ -70,8 +70,6 @@ func resourceGithubRepositoryCollaboratorCreate(d *schema.ResourceData, meta int repoName := d.Get("repository").(string) ctx := context.Background() - log.Printf("[DEBUG] Creating repository collaborator: %s (%s/%s)", - username, owner, repoName) _, _, err := client.Repositories.AddCollaborator(ctx, owner, repoName, @@ -106,7 +104,7 @@ func resourceGithubRepositoryCollaboratorRead(d *schema.ResourceData, meta inter if ghErr.Response.StatusCode == http.StatusNotFound { // this short circuits the rest of the code because if the // repo is 404, no reason to try to list existing collaborators - log.Printf("[WARN] Removing repository collaborator %s/%s %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository collaborator %s/%s %s from state because it no longer exists in GitHub", owner, repoName, username) d.SetId("") return nil @@ -116,7 +114,6 @@ func resourceGithubRepositoryCollaboratorRead(d *schema.ResourceData, meta inter } if invitation != nil { username = invitation.GetInvitee().GetLogin() - log.Printf("[DEBUG] Found invitation for %q", username) permissionName, err := getInvitationPermission(invitation) if err != nil { @@ -141,11 +138,9 @@ func resourceGithubRepositoryCollaboratorRead(d *schema.ResourceData, meta inter if err != nil { return err } - log.Printf("[DEBUG] Found %d collaborators, checking if any matches %q", len(collaborators), username) for _, c := range collaborators { if strings.EqualFold(c.GetLogin(), username) { - log.Printf("[DEBUG] Matching collaborator found for %q", username) permissionName, err := getRepoPermission(c.GetPermissions()) if err != nil { return err @@ -165,7 +160,7 @@ func resourceGithubRepositoryCollaboratorRead(d *schema.ResourceData, meta inter } // The user is neither invited nor a collaborator - log.Printf("[WARN] Removing repository collaborator %s (%s/%s) from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository collaborator %s (%s/%s) from state because it no longer exists in GitHub", username, owner, repoName) d.SetId("") @@ -194,8 +189,6 @@ func resourceGithubRepositoryCollaboratorDelete(d *schema.ResourceData, meta int return err } - log.Printf("[DEBUG] Deleting repository collaborator: %s (%s/%s)", - username, owner, repoName) _, err = client.Repositories.RemoveCollaborator(ctx, owner, repoName, username) return err } diff --git a/github/resource_github_repository_deploy_key.go b/github/resource_github_repository_deploy_key.go index e456f5e209..35fc94bb25 100644 --- a/github/resource_github_repository_deploy_key.go +++ b/github/resource_github_repository_deploy_key.go @@ -63,7 +63,6 @@ func resourceGithubRepositoryDeployKeyCreate(d *schema.ResourceData, meta interf owner := meta.(*Owner).name ctx := context.Background() - log.Printf("[DEBUG] Creating repository deploy key: %s (%s/%s)", title, owner, repoName) resultKey, _, err := client.Repositories.CreateKey(ctx, owner, repoName, &github.Key{ Key: github.String(key), Title: github.String(title), @@ -99,7 +98,6 @@ func resourceGithubRepositoryDeployKeyRead(d *schema.ResourceData, meta interfac ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading repository deploy key: %s (%s/%s)", d.Id(), owner, repoName) key, resp, err := client.Repositories.GetKey(ctx, owner, repoName, id) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -107,7 +105,7 @@ func resourceGithubRepositoryDeployKeyRead(d *schema.ResourceData, meta interfac return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing repository deploy key %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository deploy key %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -140,7 +138,6 @@ func resourceGithubRepositoryDeployKeyDelete(d *schema.ResourceData, meta interf } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting repository deploy key: %s (%s/%s)", idString, owner, repoName) _, err = client.Repositories.DeleteKey(ctx, owner, repoName, id) if err != nil { return err diff --git a/github/resource_github_repository_environment.go b/github/resource_github_repository_environment.go index 936fedfe7d..04cd7f7cfe 100644 --- a/github/resource_github_repository_environment.go +++ b/github/resource_github_repository_environment.go @@ -86,7 +86,6 @@ func resourceGithubRepositoryEnvironmentCreate(d *schema.ResourceData, meta inte ctx := context.Background() - log.Printf("[DEBUG] Creating repository environment: %s/%s/%s", owner, repoName, envName) _, _, err := client.Repositories.CreateUpdateEnvironment(ctx, owner, repoName, envName, &updateData) if err != nil { @@ -109,12 +108,11 @@ func resourceGithubRepositoryEnvironmentRead(d *schema.ResourceData, meta interf ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Reading repository environment: %s (%s/%s/%s)", d.Id(), owner, repoName, envName) env, _, err := client.Repositories.GetEnvironment(ctx, owner, repoName, envName) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing repository environment %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository environment %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -173,9 +171,7 @@ func resourceGithubRepositoryEnvironmentUpdate(d *schema.ResourceData, meta inte ctx := context.Background() - log.Printf("[DEBUG] Updating repository environment: %s/%s/%s", owner, repoName, envName) resultKey, _, err := client.Repositories.CreateUpdateEnvironment(ctx, owner, repoName, envName, &updateData) - if err != nil { return err } @@ -196,7 +192,6 @@ func resourceGithubRepositoryEnvironmentDelete(d *schema.ResourceData, meta inte ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting repository environment: %s/%s/%s", owner, repoName, envName) _, err = client.Repositories.DeleteEnvironment(ctx, owner, repoName, envName) return err } diff --git a/github/resource_github_repository_file.go b/github/resource_github_repository_file.go index de3fa557ad..82842fcd38 100644 --- a/github/resource_github_repository_file.go +++ b/github/resource_github_repository_file.go @@ -191,12 +191,11 @@ func resourceGithubRepositoryFileCreate(d *schema.ResourceData, meta interface{} opts.SHA = fileContent.SHA } else { // Error if overwriting a file is not requested - return fmt.Errorf("[ERROR] Refusing to overwrite existing file. Configure `overwrite_on_create` to `true` to override.") + return fmt.Errorf("refusing to overwrite existing file: configure `overwrite_on_create` to `true` to override") } } // Create a new or overwritten file - log.Printf("[DEBUG] Creating repository file: %s/%s/%s in branch: %s", owner, repo, file, branch) create, _, err := client.Repositories.CreateFile(ctx, owner, repo, file, opts) if err != nil { return err @@ -221,11 +220,10 @@ func resourceGithubRepositoryFileRead(d *schema.ResourceData, meta interface{}) return err } - log.Printf("[DEBUG] Reading repository file: %s/%s/%s, branch: %s", owner, repo, file, branch) opts := &github.RepositoryContentGetOptions{Ref: branch} fc, _, _, _ := client.Repositories.GetContents(ctx, owner, repo, file, opts) if fc == nil { - log.Printf("[WARN] Removing repository path %s/%s/%s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository path %s/%s/%s from state because it no longer exists in GitHub", owner, repo, file) d.SetId("") return nil @@ -241,7 +239,6 @@ func resourceGithubRepositoryFileRead(d *schema.ResourceData, meta interface{}) d.Set("file", file) d.Set("sha", fc.GetSHA()) - log.Printf("[DEBUG] Fetching commit info for repository file: %s/%s/%s", owner, repo, file) var commit *github.RepositoryCommit // Use the SHA to lookup the commit info if we know it, otherwise loop through commits @@ -289,7 +286,6 @@ func resourceGithubRepositoryFileUpdate(d *schema.ResourceData, meta interface{} opts.Message = &m } - log.Printf("[DEBUG] Updating content in repository file: %s/%s/%s", owner, repo, file) create, _, err := client.Repositories.CreateFile(ctx, owner, repo, file, opts) if err != nil { return err @@ -318,7 +314,6 @@ func resourceGithubRepositoryFileDelete(d *schema.ResourceData, meta interface{} Branch: &branch, } - log.Printf("[DEBUG] Deleting repository file: %s/%s/%s", owner, repo, file) _, _, err := client.Repositories.DeleteFile(ctx, owner, repo, file, opts) if err != nil { return nil diff --git a/github/resource_github_repository_milestone.go b/github/resource_github_repository_milestone.go index a34aa9adca..553fcf6b59 100644 --- a/github/resource_github_repository_milestone.go +++ b/github/resource_github_repository_milestone.go @@ -106,7 +106,6 @@ func resourceGithubRepositoryMilestoneCreate(d *schema.ResourceData, meta interf milestone.State = github.String(v.(string)) } - log.Printf("[DEBUG] Creating milestone for repository: %s/%s", owner, repoName) milestone, _, err := conn.Issues.CreateMilestone(ctx, owner, repoName, milestone) if err != nil { return err @@ -128,7 +127,6 @@ func resourceGithubRepositoryMilestoneRead(d *schema.ResourceData, meta interfac return err } - log.Printf("[DEBUG] Reading milestone for repository: %s/%s", owner, repoName) milestone, _, err := conn.Issues.GetMilestone(ctx, owner, repoName, number) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -136,7 +134,7 @@ func resourceGithubRepositoryMilestoneRead(d *schema.ResourceData, meta interfac return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing milestone for %s/%s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing milestone for %s/%s from state because it no longer exists in GitHub", owner, repoName) d.SetId("") return nil @@ -192,7 +190,6 @@ func resourceGithubRepositoryMilestoneUpdate(d *schema.ResourceData, meta interf milestone.State = github.String(n.(string)) } - log.Printf("[DEBUG] Updating milestone for repository: %s/%s", owner, repoName) _, _, err = conn.Issues.EditMilestone(ctx, owner, repoName, number, milestone) if err != nil { return err @@ -211,7 +208,6 @@ func resourceGithubRepositoryMilestoneDelete(d *schema.ResourceData, meta interf return err } - log.Printf("[DEBUG] Deleting milestone for repository: %s/%s", owner, repoName) _, err = conn.Issues.DeleteMilestone(ctx, owner, repoName, number) if err != nil { return err diff --git a/github/resource_github_repository_project.go b/github/resource_github_repository_project.go index bfbf8d2392..60ae47a2a7 100644 --- a/github/resource_github_repository_project.go +++ b/github/resource_github_repository_project.go @@ -70,7 +70,6 @@ func resourceGithubRepositoryProjectCreate(d *schema.ResourceData, meta interfac } ctx := context.Background() - log.Printf("[DEBUG] Creating repository project: %s (%s/%s)", name, owner, repoName) project, _, err := client.Repositories.CreateProject(ctx, owner, repoName, &options) if err != nil { @@ -94,7 +93,6 @@ func resourceGithubRepositoryProjectRead(d *schema.ResourceData, meta interface{ ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading repository project: %s", d.Id()) project, resp, err := client.Projects.GetProject(ctx, projectID) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -102,7 +100,7 @@ func resourceGithubRepositoryProjectRead(d *schema.ResourceData, meta interface{ return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing repository project %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository project %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -137,7 +135,6 @@ func resourceGithubRepositoryProjectUpdate(d *schema.ResourceData, meta interfac } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating repository project: %s", d.Id()) _, _, err = client.Projects.UpdateProject(ctx, projectID, &options) if err != nil { return err @@ -155,7 +152,6 @@ func resourceGithubRepositoryProjectDelete(d *schema.ResourceData, meta interfac } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting repository project: %s", d.Id()) _, err = client.Projects.DeleteProject(ctx, projectID) return err } diff --git a/github/resource_github_repository_pull_request.go b/github/resource_github_repository_pull_request.go index 0fce420615..c2a4eb0a2b 100644 --- a/github/resource_github_repository_pull_request.go +++ b/github/resource_github_repository_pull_request.go @@ -180,7 +180,7 @@ func resourceGithubRepositoryPullRequestRead(d *schema.ResourceData, meta interf d.Set("head_sha", head.GetSHA()) } else { // Totally unexpected condition. Better do that than segfault, I guess? - log.Printf("[WARN] Head branch missing, expected %s", d.Get("head_ref")) + log.Printf("[INFO] Head branch missing, expected %s", d.Get("head_ref")) d.SetId("") return nil } @@ -190,7 +190,7 @@ func resourceGithubRepositoryPullRequestRead(d *schema.ResourceData, meta interf d.Set("base_sha", base.GetSHA()) } else { // Seme logic as with the missing head branch. - log.Printf("[WARN] Base branch missing, expected %s", d.Get("base_ref")) + log.Printf("[INFO] Base branch missing, expected %s", d.Get("base_ref")) d.SetId("") return nil } diff --git a/github/resource_github_repository_test.go b/github/resource_github_repository_test.go index a6549dd134..8814659406 100644 --- a/github/resource_github_repository_test.go +++ b/github/resource_github_repository_test.go @@ -1134,7 +1134,7 @@ func testSweepRepositories(region string) error { for _, r := range repos { if name := r.GetName(); strings.HasPrefix(name, "tf-acc-") || strings.HasPrefix(name, "foo-") { - log.Printf("Destroying Repository %s", name) + log.Printf("[DEBUG] Destroying Repository %s", name) if _, err := client.Repositories.Delete(context.TODO(), meta.(*Owner).name, name); err != nil { return err diff --git a/github/resource_github_repository_webhook.go b/github/resource_github_repository_webhook.go index 4562f3b457..e648c1a705 100644 --- a/github/resource_github_repository_webhook.go +++ b/github/resource_github_repository_webhook.go @@ -105,7 +105,6 @@ func resourceGithubRepositoryWebhookCreate(d *schema.ResourceData, meta interfac hk := resourceGithubRepositoryWebhookObject(d) ctx := context.Background() - log.Printf("[DEBUG] Creating repository webhook: %d (%s/%s)", hk.GetID(), owner, repoName) hook, _, err := client.Repositories.CreateHook(ctx, owner, repoName, hk) if err != nil { return err @@ -140,7 +139,6 @@ func resourceGithubRepositoryWebhookRead(d *schema.ResourceData, meta interface{ ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading repository webhook: %s (%s/%s)", d.Id(), owner, repoName) hook, _, err := client.Repositories.GetHook(ctx, owner, repoName, hookID) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -148,7 +146,7 @@ func resourceGithubRepositoryWebhookRead(d *schema.ResourceData, meta interface{ return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing repository webhook %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing repository webhook %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -191,7 +189,6 @@ func resourceGithubRepositoryWebhookUpdate(d *schema.ResourceData, meta interfac } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating repository webhook: %s (%s/%s)", d.Id(), owner, repoName) _, _, err = client.Repositories.EditHook(ctx, owner, repoName, hookID, hk) if err != nil { return err @@ -211,7 +208,6 @@ func resourceGithubRepositoryWebhookDelete(d *schema.ResourceData, meta interfac } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting repository webhook: %s (%s/%s)", d.Id(), owner, repoName) _, err = client.Repositories.DeleteHook(ctx, owner, repoName, hookID) return err } diff --git a/github/resource_github_team.go b/github/resource_github_team.go index b8d2e6628f..7f932b7a55 100644 --- a/github/resource_github_team.go +++ b/github/resource_github_team.go @@ -99,7 +99,6 @@ func resourceGithubTeamCreate(d *schema.ResourceData, meta interface{}) error { } ctx := context.Background() - log.Printf("[DEBUG] Creating team: %s (%s)", name, ownerName) githubTeam, _, err := client.Teams.CreateTeam(ctx, ownerName, newTeam) if err != nil { @@ -146,7 +145,6 @@ func resourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading team: %s", d.Id()) team, resp, err := client.Teams.GetTeamByID(ctx, orgId, id) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -154,7 +152,7 @@ func resourceGithubTeamRead(d *schema.ResourceData, meta interface{}) error { return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing team %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing team %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -205,7 +203,6 @@ func resourceGithubTeamUpdate(d *schema.ResourceData, meta interface{}) error { } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating team: %s", d.Id()) team, _, err := client.Teams.EditTeamByID(ctx, orgId, teamId, editedTeam, false) if err != nil { return err @@ -241,7 +238,6 @@ func resourceGithubTeamDelete(d *schema.ResourceData, meta interface{}) error { } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting team: %s", d.Id()) _, err = client.Teams.DeleteTeamByID(ctx, orgId, id) return err } @@ -276,7 +272,6 @@ func removeDefaultMaintainer(teamSlug string, meta interface{}) error { } for _, user := range query.Organization.Team.Members.Nodes { - log.Printf("[DEBUG] Removing default maintainer from team: %s", user.Login) _, err := client.Teams.RemoveTeamMembershipBySlug(meta.(*Owner).StopContext, orgName, teamSlug, string(user.Login)) if err != nil { return err diff --git a/github/resource_github_team_membership.go b/github/resource_github_team_membership.go index 6014414e48..8899becdab 100644 --- a/github/resource_github_team_membership.go +++ b/github/resource_github_team_membership.go @@ -62,7 +62,6 @@ func resourceGithubTeamMembershipCreateOrUpdate(d *schema.ResourceData, meta int username := d.Get("username").(string) role := d.Get("role").(string) - log.Printf("[DEBUG] Creating team membership: %s/%s (%s)", teamIdString, username, role) _, _, err = client.Teams.AddTeamMembershipByID(ctx, orgId, teamId, @@ -104,7 +103,6 @@ func resourceGithubTeamMembershipRead(d *schema.ResourceData, meta interface{}) ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading team membership: %s/%s", teamIdString, username) membership, resp, err := client.Teams.GetTeamMembershipByID(ctx, orgId, teamId, username) if err != nil { @@ -113,7 +111,7 @@ func resourceGithubTeamMembershipRead(d *schema.ResourceData, meta interface{}) return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing team membership %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing team membership %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -139,7 +137,6 @@ func resourceGithubTeamMembershipDelete(d *schema.ResourceData, meta interface{} username := d.Get("username").(string) ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting team membership: %s/%s", teamIdString, username) _, err = client.Teams.RemoveTeamMembershipByID(ctx, orgId, teamId, username) return err diff --git a/github/resource_github_team_repository.go b/github/resource_github_team_repository.go index 542c3c5b3c..bd08f4855a 100644 --- a/github/resource_github_team_repository.go +++ b/github/resource_github_team_repository.go @@ -67,8 +67,6 @@ func resourceGithubTeamRepositoryCreate(d *schema.ResourceData, meta interface{} permission := d.Get("permission").(string) ctx := context.Background() - log.Printf("[DEBUG] Creating team repository association: %s:%s (%s/%s)", - givenTeamId, permission, orgName, repoName) _, err = client.Teams.AddTeamRepoByID(ctx, orgId, teamId, @@ -111,7 +109,6 @@ func resourceGithubTeamRepositoryRead(d *schema.ResourceData, meta interface{}) ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading team repository association: %s (%s/%s)", teamIdString, orgName, repoName) repo, resp, repoErr := client.Teams.IsTeamRepoByID(ctx, orgId, teamId, orgName, repoName) if repoErr != nil { if ghErr, ok := repoErr.(*github.ErrorResponse); ok { @@ -119,7 +116,7 @@ func resourceGithubTeamRepositoryRead(d *schema.ResourceData, meta interface{}) return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing team repository association %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing team repository association %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -167,8 +164,6 @@ func resourceGithubTeamRepositoryUpdate(d *schema.ResourceData, meta interface{} permission := d.Get("permission").(string) ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Updating team repository association: %s:%s (%s/%s)", - teamIdString, permission, orgName, repoName) // the go-github library's AddTeamRepo method uses the add/update endpoint from Github API _, err = client.Teams.AddTeamRepoByID(ctx, orgId, @@ -208,8 +203,6 @@ func resourceGithubTeamRepositoryDelete(d *schema.ResourceData, meta interface{} orgName := meta.(*Owner).name ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting team repository association: %s (%s/%s)", - teamIdString, orgName, repoName) resp, err := client.Teams.RemoveTeamRepoByID(ctx, orgId, teamId, orgName, repoName) if resp.Response.StatusCode == 404 { @@ -220,7 +213,7 @@ func resourceGithubTeamRepositoryDelete(d *schema.ResourceData, meta interface{} } newRepoName := repo.GetName() if newRepoName != repoName { - log.Printf("[DEBUG] Repo name has changed %s -> %s. "+ + log.Printf("[INFO] Repo name has changed %s -> %s. "+ "Try deleting team repository again.", repoName, newRepoName) _, err := client.Teams.RemoveTeamRepoByID(ctx, orgId, teamId, orgName, newRepoName) diff --git a/github/resource_github_team_sync_group_mapping.go b/github/resource_github_team_sync_group_mapping.go index 35f98fd665..9c0bf4a6cb 100644 --- a/github/resource_github_team_sync_group_mapping.go +++ b/github/resource_github_team_sync_group_mapping.go @@ -70,7 +70,6 @@ func resourceGithubTeamSyncGroupMappingCreate(d *schema.ResourceData, meta inter slug := d.Get("team_slug").(string) idpGroupList := expandTeamSyncGroups(d) - log.Printf("[DEBUG] Creating team-sync group mapping (Team slug: %s)", slug) _, _, err = client.Teams.CreateOrUpdateIDPGroupConnectionsBySlug(ctx, orgName, slug, *idpGroupList) if err != nil { return err @@ -96,7 +95,6 @@ func resourceGithubTeamSyncGroupMappingRead(d *schema.ResourceData, meta interfa ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading team-sync group mapping (Team slug: %s)", slug) idpGroupList, resp, err := client.Teams.ListIDPGroupsForTeamBySlug(ctx, orgName, slug) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -104,7 +102,7 @@ func resourceGithubTeamSyncGroupMappingRead(d *schema.ResourceData, meta interfa return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing team_sync_group mapping for %s/%s from state because it no longer exists in Github", + log.Printf("[INFO] Removing team_sync_group mapping for %s/%s from state because it no longer exists in GitHub", orgName, slug) d.SetId("") return nil @@ -138,7 +136,6 @@ func resourceGithubTeamSyncGroupMappingUpdate(d *schema.ResourceData, meta inter slug := d.Get("team_slug").(string) idpGroupList := expandTeamSyncGroups(d) - log.Printf("[DEBUG] Updating team-sync group mapping (Team slug: %s)", slug) _, _, err = client.Teams.CreateOrUpdateIDPGroupConnectionsBySlug(ctx, orgName, slug, *idpGroupList) if err != nil { return err @@ -161,9 +158,7 @@ func resourceGithubTeamSyncGroupMappingDelete(d *schema.ResourceData, meta inter groups := make([]*github.IDPGroup, 0) emptyGroupList := github.IDPGroupList{Groups: groups} - log.Printf("[DEBUG] Deleting team-sync group mapping (Team slug: %s)", slug) _, _, err = client.Teams.CreateOrUpdateIDPGroupConnectionsBySlug(ctx, orgName, slug, emptyGroupList) - return err } diff --git a/github/resource_github_user_gpg_key.go b/github/resource_github_user_gpg_key.go index eb44ab5931..7f0eb8a35e 100644 --- a/github/resource_github_user_gpg_key.go +++ b/github/resource_github_user_gpg_key.go @@ -40,7 +40,6 @@ func resourceGithubUserGpgKeyCreate(d *schema.ResourceData, meta interface{}) er pubKey := d.Get("armored_public_key").(string) ctx := context.Background() - log.Printf("[DEBUG] Creating user GPG key:\n%s", pubKey) key, _, err := client.Users.CreateGPGKey(ctx, pubKey) if err != nil { return err @@ -63,7 +62,6 @@ func resourceGithubUserGpgKeyRead(d *schema.ResourceData, meta interface{}) erro ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading user GPG key: %s", d.Id()) key, _, err := client.Users.GetGPGKey(ctx, id) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -71,7 +69,7 @@ func resourceGithubUserGpgKeyRead(d *schema.ResourceData, meta interface{}) erro return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing user GPG key %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing user GPG key %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -94,7 +92,6 @@ func resourceGithubUserGpgKeyDelete(d *schema.ResourceData, meta interface{}) er } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting user GPG key: %s", d.Id()) _, err = client.Users.DeleteGPGKey(ctx, id) return err diff --git a/github/resource_github_user_invitation_accepter.go b/github/resource_github_user_invitation_accepter.go index 4a6e77ed33..c14b3aabae 100644 --- a/github/resource_github_user_invitation_accepter.go +++ b/github/resource_github_user_invitation_accepter.go @@ -3,7 +3,6 @@ package github import ( "context" "fmt" - "log" "strconv" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -35,7 +34,6 @@ func resourceGithubUserInvitationAccepterCreate(d *schema.ResourceData, meta int } ctx := context.Background() - log.Printf("[DEBUG] Accepting invitation: %d", invitationId) _, err = client.Users.AcceptInvitation(ctx, int64(invitationId)) if err != nil { return err diff --git a/github/resource_github_user_ssh_key.go b/github/resource_github_user_ssh_key.go index 15e3f1d351..1c21a8b732 100644 --- a/github/resource_github_user_ssh_key.go +++ b/github/resource_github_user_ssh_key.go @@ -54,7 +54,6 @@ func resourceGithubUserSshKeyCreate(d *schema.ResourceData, meta interface{}) er key := d.Get("key").(string) ctx := context.Background() - log.Printf("[DEBUG] Creating user SSH key: %s", title) userKey, _, err := client.Users.CreateKey(ctx, &github.Key{ Title: github.String(title), Key: github.String(key), @@ -80,7 +79,6 @@ func resourceGithubUserSshKeyRead(d *schema.ResourceData, meta interface{}) erro ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading user SSH key: %s", d.Id()) key, resp, err := client.Users.GetKey(ctx, id) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -88,7 +86,7 @@ func resourceGithubUserSshKeyRead(d *schema.ResourceData, meta interface{}) erro return nil } if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing user SSH key %s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing user SSH key %s from state because it no longer exists in GitHub", d.Id()) d.SetId("") return nil @@ -113,8 +111,6 @@ func resourceGithubUserSshKeyDelete(d *schema.ResourceData, meta interface{}) er } ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting user SSH key: %s", d.Id()) _, err = client.Users.DeleteKey(ctx, id) - return err } diff --git a/github/resource_organization_block.go b/github/resource_organization_block.go index 1f709c6b61..3e5a4c02c3 100644 --- a/github/resource_organization_block.go +++ b/github/resource_organization_block.go @@ -44,7 +44,6 @@ func resourceOrganizationBlockCreate(d *schema.ResourceData, meta interface{}) e ctx := context.Background() username := d.Get("username").(string) - log.Printf("[DEBUG] Creating organization block: %s (%s)", username, orgName) _, err = client.Organizations.BlockUser(ctx, orgName, username) if err != nil { return err @@ -65,7 +64,6 @@ func resourceOrganizationBlockRead(d *schema.ResourceData, meta interface{}) err ctx = context.WithValue(ctx, ctxEtag, d.Get("etag").(string)) } - log.Printf("[DEBUG] Reading organization block: %s (%s)", d.Id(), orgName) blocked, resp, err := client.Organizations.IsBlocked(ctx, orgName, username) if err != nil { if ghErr, ok := err.(*github.ErrorResponse); ok { @@ -74,7 +72,7 @@ func resourceOrganizationBlockRead(d *schema.ResourceData, meta interface{}) err } // not sure if this will ever be hit, I imagine just returns false? if ghErr.Response.StatusCode == http.StatusNotFound { - log.Printf("[WARN] Removing organization block %s/%s from state because it no longer exists in GitHub", + log.Printf("[INFO] Removing organization block %s/%s from state because it no longer exists in GitHub", orgName, d.Id()) d.SetId("") return nil @@ -101,7 +99,6 @@ func resourceOrganizationBlockDelete(d *schema.ResourceData, meta interface{}) e username := d.Id() ctx := context.WithValue(context.Background(), ctxId, d.Id()) - log.Printf("[DEBUG] Deleting organization block: %s (%s)", d.Id(), orgName) _, err := client.Organizations.UnblockUser(ctx, orgName, username) return err } diff --git a/github/transport.go b/github/transport.go index eb042e33dd..a0f77adc58 100644 --- a/github/transport.go +++ b/github/transport.go @@ -114,14 +114,10 @@ func (rlt *RateLimitTransport) RoundTrip(req *http.Request) (*http.Response, err } func (rlt *RateLimitTransport) lock(req *http.Request) { - ctx := req.Context() - log.Printf("[TRACE] Acquiring lock for GitHub API request (%q)", ctx.Value(ctxId)) rlt.m.Lock() } func (rlt *RateLimitTransport) unlock(req *http.Request) { - ctx := req.Context() - log.Printf("[TRACE] Releasing lock for GitHub API request (%q)", ctx.Value(ctxId)) rlt.m.Unlock() } diff --git a/github/transport_test.go b/github/transport_test.go index f1d8135159..5b8b3aa734 100644 --- a/github/transport_test.go +++ b/github/transport_test.go @@ -53,7 +53,7 @@ func githubApiMock(responseSequence []*mockResponse) *httptest.Server { bodyBytes, err := ioutil.ReadAll(r.Body) if err != nil { - log.Printf("[ERROR] %s", err) + log.Printf("[DEBUG] Error: %s", err) } log.Printf("[DEBUG] Mock server received %s request to %q; headers:\n%s\nrequest body: %q\n", r.Method, r.RequestURI, r.Header, string(bodyBytes)) @@ -76,22 +76,22 @@ func githubApiMock(responseSequence []*mockResponse) *httptest.Server { } if r.RequestURI != tc.ExpectedUri { - log.Printf("[ERROR] Expected URI: %q, given: %q", tc.ExpectedUri, r.RequestURI) + log.Printf("[DEBUG] Error: expected URI: %q, given: %q", tc.ExpectedUri, r.RequestURI) w.WriteHeader(400) return } if !headersMatch(r.Header, tc.ExpectedHeaders) { - log.Printf("[ERROR] Expected headers: %q, given: %q", tc.ExpectedHeaders, r.Header) + log.Printf("[DEBUG] Error: expected headers: %q, given: %q", tc.ExpectedHeaders, r.Header) w.WriteHeader(400) return } if tc.ExpectedMethod != "" && r.Method != tc.ExpectedMethod { - log.Printf("[ERROR] Expected method: %q, given: %q", tc.ExpectedMethod, r.Method) + log.Printf("[DEBUG] Error: expected method: %q, given: %q", tc.ExpectedMethod, r.Method) w.WriteHeader(400) return } if len(tc.ExpectedBody) > 0 && string(bodyBytes) != string(tc.ExpectedBody) { - log.Printf("[ERROR] Expected body: %q, given: %q", + log.Printf("[DEBUG] Error: expected body: %q, given: %q", string(tc.ExpectedBody), string(bodyBytes)) w.WriteHeader(400) return