diff --git a/client/project.go b/client/project.go index d27f678..c4c0c51 100644 --- a/client/project.go +++ b/client/project.go @@ -1,8 +1,8 @@ package client import ( - "fmt" "encoding/json" + "fmt" "log" "strconv" "strings" @@ -66,7 +66,7 @@ func expandCveAllowList(cveAllowlist []interface{}) models.CveAllowlistItems { } func (client *Client) UpdateStorageQuota(d *schema.ResourceData) (err error) { - resp, _, err := client.SendRequest("GET", models.PathConfig, nil, 200) + resp, _, _, err := client.SendRequest("GET", models.PathConfig, nil, 200) var jsonData models.ConfigBodyResponse err = json.Unmarshal([]byte(resp), &jsonData) @@ -82,7 +82,7 @@ func (client *Client) UpdateStorageQuota(d *schema.ResourceData) (err error) { for { quotasPath := fmt.Sprintf("/quotas/?page=%d&page_size=100", page) - resp, _, err := client.SendRequest("GET", quotasPath, nil, 200) + resp, _, _, err := client.SendRequest("GET", quotasPath, nil, 200) if err != nil { return err } @@ -109,7 +109,7 @@ func (client *Client) UpdateStorageQuota(d *schema.ResourceData) (err error) { } body := models.StorageQuota{quota} - _, _, err = client.SendRequest("PUT", quotaID, body, 200) + _, _, _, err = client.SendRequest("PUT", quotaID, body, 200) if err != nil { return err } diff --git a/provider/data_project.go b/provider/data_project.go index d2ca6cb..a173b72 100644 --- a/provider/data_project.go +++ b/provider/data_project.go @@ -39,7 +39,7 @@ func dataProjectRead(d *schema.ResourceData, m interface{}) error { name := d.Get("name").(string) projectPath := models.PathProjects + "?name=" + name - resp, _, err := apiClient.SendRequest("GET", projectPath, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", projectPath, nil, 200) if err != nil { return err } diff --git a/provider/data_registry.go b/provider/data_registry.go index a7b3873..ccc80d6 100644 --- a/provider/data_registry.go +++ b/provider/data_registry.go @@ -50,7 +50,7 @@ func dataRegistryRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) name := d.Get("name").(string) registryPath := models.PathRegistries + "?name=" + name - resp, _, err := apiClient.SendRequest("GET", registryPath, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", registryPath, nil, 200) if err != nil { return err } diff --git a/provider/provider_test.go b/provider/provider_test.go index 006ccb9..496e16a 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -29,12 +29,6 @@ func testProvider(t *testing.T) { func testAccPreCheck(t *testing.T) { - // apiClient := testAccProvider.Meta().(*client.Client) - // _, _, err := apiClient.SendRequest("GET", "/health", nil, 200) - // if err != nil { - // t.Fatal("Harbor instamce is not healthy") - // } - if v := os.Getenv("HARBOR_URL"); v == "" { t.Fatal("HARBOR_URL must be set for acceptance tests") } diff --git a/provider/resource_config_auth.go b/provider/resource_config_auth.go index 41d82eb..cc28a82 100644 --- a/provider/resource_config_auth.go +++ b/provider/resource_config_auth.go @@ -79,7 +79,7 @@ func resourceConfigAuth() *schema.Resource { Type: schema.TypeString, Optional: true, ConflictsWith: ldapConflictsWith(), - RequiredWith: ldapRequiredWith(), + RequiredWith: ldapRequiredWith(), }, "ldap_uid": { Type: schema.TypeString, @@ -155,7 +155,7 @@ func resourceConfigAuthCreate(d *schema.ResourceData, m interface{}) error { body := client.GetConfigAuth(d) - _, _, err := apiClient.SendRequest("PUT", models.PathConfig, body, 200) + _, _, _, err := apiClient.SendRequest("PUT", models.PathConfig, body, 200) if err != nil { return err } @@ -166,7 +166,7 @@ func resourceConfigAuthCreate(d *schema.ResourceData, m interface{}) error { func resourceConfigAuthRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", models.PathConfig, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", models.PathConfig, nil, 200) if err != nil { d.SetId("") return nil diff --git a/provider/resource_config_email.go b/provider/resource_config_email.go index c098e6a..e039865 100644 --- a/provider/resource_config_email.go +++ b/provider/resource_config_email.go @@ -56,7 +56,7 @@ func resourceConfigEmailCreate(d *schema.ResourceData, m interface{}) error { body := client.GetConfigEmail(d) - _, _, err := apiClient.SendRequest("PUT", models.PathConfig, body, 200) + _, _, _, err := apiClient.SendRequest("PUT", models.PathConfig, body, 200) if err != nil { return err } @@ -67,7 +67,7 @@ func resourceConfigEmailCreate(d *schema.ResourceData, m interface{}) error { func resourceConfigEmailRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", models.PathConfig, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", models.PathConfig, nil, 200) if err != nil { d.SetId("") return nil diff --git a/provider/resource_config_system.go b/provider/resource_config_system.go index 52218b7..642c185 100644 --- a/provider/resource_config_system.go +++ b/provider/resource_config_system.go @@ -41,7 +41,7 @@ func resourceConfigSystemCreate(d *schema.ResourceData, m interface{}) error { body := client.GetConfigSystem(d) - _, _, err := apiClient.SendRequest("PUT", models.PathConfig, body, 200) + _, _, _, err := apiClient.SendRequest("PUT", models.PathConfig, body, 200) if err != nil { return err } @@ -54,19 +54,6 @@ func resourceConfigSystemRead(d *schema.ResourceData, m interface{}) error { return nil } -// func resourceConfigSystemUpdate(d *schema.ResourceData, m interface{}) error { -// apiClient := m.(*client.Client) - -// body := client.GetConfigSystem(d) - -// _, _, err := apiClient.SendRequest("PUT", models.PathConfig, body, 200) -// if err != nil { -// return err -// } - -// return resourceConfigSystemRead(d, m) -// } - func resourceConfigSystemDelete(d *schema.ResourceData, m interface{}) error { return nil } diff --git a/provider/resource_garbage_collection.go b/provider/resource_garbage_collection.go index b41902a..4197a03 100644 --- a/provider/resource_garbage_collection.go +++ b/provider/resource_garbage_collection.go @@ -43,7 +43,7 @@ func resourceGCCreate(d *schema.ResourceData, m interface{}) error { func resourceGCRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", models.PathGC, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", models.PathGC, nil, 200) if err != nil { d.SetId("") return nil @@ -80,7 +80,7 @@ func resourceGCDelete(d *schema.ResourceData, m interface{}) error { body.Schedule.Type = "None" body.Parameters.DeleteUntagged = false - _, _, err := apiClient.SendRequest("PUT", models.PathGC, body, 200) + _, _, _, err := apiClient.SendRequest("PUT", models.PathGC, body, 200) if err != nil { return err } diff --git a/provider/resource_garbage_collection_test.go b/provider/resource_garbage_collection_test.go index 44519bc..e8801a2 100644 --- a/provider/resource_garbage_collection_test.go +++ b/provider/resource_garbage_collection_test.go @@ -1,3 +1,4 @@ +//go:build external_auth // +build external_auth package provider @@ -21,7 +22,7 @@ func testAccCheckGCDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 200) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_group.go b/provider/resource_group.go index b49af52..2335880 100644 --- a/provider/resource_group.go +++ b/provider/resource_group.go @@ -17,10 +17,10 @@ func resourceGroup() *schema.Resource { Required: true, ForceNew: true, }, - "group_type": { - Type: schema.TypeInt, - Required: true, - }, + "group_type": { + Type: schema.TypeInt, + Required: true, + }, }, Create: resourceGroupCreate, Read: resourceGroupRead, @@ -37,7 +37,7 @@ func resourceGroupCreate(d *schema.ResourceData, m interface{}) error { body := client.GroupBody(d) - _, header, err := apiClient.SendRequest("POST", models.PathGroups, &body, 201) + _, header, _, err := apiClient.SendRequest("POST", models.PathGroups, &body, 201) if err != nil { return err } @@ -53,7 +53,7 @@ func resourceGroupCreate(d *schema.ResourceData, m interface{}) error { func resourceGroupRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { return err } @@ -76,7 +76,7 @@ func resourceGroupUpdate(d *schema.ResourceData, m interface{}) error { func resourceGroupDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_harbor_project_webhook.go b/provider/resource_harbor_project_webhook.go index f6ae016..3c9f116 100644 --- a/provider/resource_harbor_project_webhook.go +++ b/provider/resource_harbor_project_webhook.go @@ -71,7 +71,7 @@ func resourceProjectWebhookCreate(d *schema.ResourceData, m interface{}) error { body := client.ProjectWebhookBody(d) url := d.Get("project_id").(string) + "/webhook/policies" - _, headers, err := apiClient.SendRequest("POST", url, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", url, body, 201) if err != nil { return err } @@ -84,7 +84,7 @@ func resourceProjectWebhookCreate(d *schema.ResourceData, m interface{}) error { func resourceProjectWebhookRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { d.SetId("") return nil @@ -111,7 +111,7 @@ func resourceProjectWebhookUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.ProjectWebhookBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } @@ -122,7 +122,7 @@ func resourceProjectWebhookUpdate(d *schema.ResourceData, m interface{}) error { func resourceProjectWebhookDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_harbor_project_webhook_test.go b/provider/resource_harbor_project_webhook_test.go index 2c01954..58a201d 100644 --- a/provider/resource_harbor_project_webhook_test.go +++ b/provider/resource_harbor_project_webhook_test.go @@ -58,7 +58,7 @@ func testAccCheckProjectWebhookDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_immutable_tag_rule.go b/provider/resource_immutable_tag_rule.go index 8b36645..0f55b5c 100644 --- a/provider/resource_immutable_tag_rule.go +++ b/provider/resource_immutable_tag_rule.go @@ -65,7 +65,7 @@ func resourceImmutableTagRuleCreate(d *schema.ResourceData, m interface{}) error body := client.GetImmutableTagRuleBody(d) id := "" - _, headers, err := apiClient.SendRequest("POST", path, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", path, body, 201) if err != nil { return err } @@ -86,7 +86,7 @@ func resourceImmutableTagRuleRead(d *schema.ResourceData, m interface{}) error { } log.Printf("[DEBUG] Path to immutable tag rules: %+v\n", projectImmutableTagRulePath) - resp, _, err := apiClient.SendRequest("GET", projectImmutableTagRulePath, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", projectImmutableTagRulePath, nil, 200) if err != nil { return fmt.Errorf("Resource not found %s", projectImmutableTagRulePath) } @@ -128,7 +128,7 @@ func resourceImmutableTagRuleUpdate(d *schema.ResourceData, m interface{}) error body := client.GetImmutableTagRuleBody(d) id := d.Id() log.Printf("[DEBUG] Update Id: %+v\n", id) - _, _, err := apiClient.SendRequest("PUT", id, body, 200) + _, _, _, err := apiClient.SendRequest("PUT", id, body, 200) if err != nil { return err } @@ -139,7 +139,7 @@ func resourceImmutableTagRuleUpdate(d *schema.ResourceData, m interface{}) error func resourceImmutableTagRuleDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_interrogation_services.go b/provider/resource_interrogation_services.go index 3e34c8c..8ab9e60 100644 --- a/provider/resource_interrogation_services.go +++ b/provider/resource_interrogation_services.go @@ -53,7 +53,7 @@ func resourceVulnDelete(d *schema.ResourceData, m interface{}) error { body.Schedule.Cron = "" body.Schedule.Type = "None" - _, _, err := apiClient.SendRequest("PUT", models.PathVuln, body, 200) + _, _, _, err := apiClient.SendRequest("PUT", models.PathVuln, body, 200) if err != nil { return err } diff --git a/provider/resource_labels.go b/provider/resource_labels.go index 294fb83..6b90905 100644 --- a/provider/resource_labels.go +++ b/provider/resource_labels.go @@ -49,7 +49,7 @@ func resourceLabelCreate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.LabelsBody(d) - _, headers, err := apiClient.SendRequest("POST", models.PathLabel, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", models.PathLabel, body, 201) if err != nil { return err } @@ -62,7 +62,7 @@ func resourceLabelCreate(d *schema.ResourceData, m interface{}) error { func resourceLabelRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { d.SetId("") return nil @@ -86,7 +86,7 @@ func resourceLabelUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.LabelsBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } @@ -97,7 +97,7 @@ func resourceLabelUpdate(d *schema.ResourceData, m interface{}) error { func resourceLabelDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_labels_test.go b/provider/resource_labels_test.go index d93606b..90cf964 100644 --- a/provider/resource_labels_test.go +++ b/provider/resource_labels_test.go @@ -20,7 +20,7 @@ func testAccCheckLabelDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_project.go b/provider/resource_project.go index 2e15cdc..868efa5 100644 --- a/provider/resource_project.go +++ b/provider/resource_project.go @@ -79,7 +79,7 @@ func resourceProjectCreate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.ProjectBody(d) - _, headers, err := apiClient.SendRequest("POST", models.PathProjects, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", models.PathProjects, body, 201) if err != nil { return err } @@ -92,7 +92,7 @@ func resourceProjectCreate(d *schema.ResourceData, m interface{}) error { func resourceProjectRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { d.SetId("") return nil @@ -140,7 +140,7 @@ func resourceProjectUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.ProjectBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } @@ -166,7 +166,7 @@ func resourceProjectDelete(d *schema.ResourceData, m interface{}) error { } } - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_project_member_group.go b/provider/resource_project_member_group.go index 7a4800f..edc8f2c 100644 --- a/provider/resource_project_member_group.go +++ b/provider/resource_project_member_group.go @@ -81,7 +81,7 @@ func resourceMembersGroupCreate(d *schema.ResourceData, m interface{}) error { body := client.ProjectMembersGroupBody(d) - _, headers, err := apiClient.SendRequest("POST", path, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", path, body, 201) if err != nil { return err } @@ -98,7 +98,7 @@ func resourceMembersGroupCreate(d *schema.ResourceData, m interface{}) error { func resourceMembersGroupRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { d.SetId("") return nil @@ -120,7 +120,7 @@ func resourceMembersGroupUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.ProjectMembersGroupBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { fmt.Println(err) } @@ -131,7 +131,7 @@ func resourceMembersGroupUpdate(d *schema.ResourceData, m interface{}) error { func resourceMembersGroupDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { fmt.Println(err) } diff --git a/provider/resource_project_member_group_test.go b/provider/resource_project_member_group_test.go index bce3519..97b0fef 100644 --- a/provider/resource_project_member_group_test.go +++ b/provider/resource_project_member_group_test.go @@ -23,7 +23,7 @@ func testAccCheckMemberGroupDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_project_member_user.go b/provider/resource_project_member_user.go index e04a95c..d06226e 100644 --- a/provider/resource_project_member_user.go +++ b/provider/resource_project_member_user.go @@ -60,7 +60,7 @@ func resourceMembersUserCreate(d *schema.ResourceData, m interface{}) error { body := client.ProjectMembersUserBody(d) - _, headers, err := apiClient.SendRequest("POST", path, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", path, body, 201) if err != nil { return err } @@ -77,7 +77,7 @@ func resourceMembersUserCreate(d *schema.ResourceData, m interface{}) error { func resourceMembersUserRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { d.SetId("") return nil @@ -99,7 +99,7 @@ func resourceMembersUserUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.ProjectMembersUserBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { fmt.Println(err) } @@ -110,7 +110,7 @@ func resourceMembersUserUpdate(d *schema.ResourceData, m interface{}) error { func resourceMembersUserDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { fmt.Println(err) } diff --git a/provider/resource_project_member_user_test.go b/provider/resource_project_member_user_test.go index 13b82aa..fa96768 100644 --- a/provider/resource_project_member_user_test.go +++ b/provider/resource_project_member_user_test.go @@ -1,3 +1,4 @@ +//go:build internal_auth // +build internal_auth package provider @@ -21,7 +22,7 @@ func testAccCheckMemberUserDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_project_test.go b/provider/resource_project_test.go index b80b567..46cfcc4 100644 --- a/provider/resource_project_test.go +++ b/provider/resource_project_test.go @@ -21,7 +21,7 @@ func testAccCheckProjectDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_registry.go b/provider/resource_registry.go index 7a7d305..567e790 100644 --- a/provider/resource_registry.go +++ b/provider/resource_registry.go @@ -67,7 +67,7 @@ func resourceRegistryCreate(d *schema.ResourceData, m interface{}) error { body := client.GetRegistryBody(d) - _, headers, err := apiClient.SendRequest("POST", models.PathRegistries, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", models.PathRegistries, body, 201) if err != nil { return err } @@ -84,7 +84,7 @@ func resourceRegistryCreate(d *schema.ResourceData, m interface{}) error { func resourceRegistryRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { d.SetId("") return nil @@ -115,7 +115,7 @@ func resourceRegistryUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.GetRegistryBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } @@ -126,7 +126,7 @@ func resourceRegistryUpdate(d *schema.ResourceData, m interface{}) error { func resourceRegistryDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_registry_test.go b/provider/resource_registry_test.go index 280b2af..0c172d4 100644 --- a/provider/resource_registry_test.go +++ b/provider/resource_registry_test.go @@ -47,7 +47,7 @@ func testAccCheckRegistryDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_replication.go b/provider/resource_replication.go index 420209a..6c021fe 100644 --- a/provider/resource_replication.go +++ b/provider/resource_replication.go @@ -104,7 +104,7 @@ func resourceReplicationCreate(d *schema.ResourceData, m interface{}) error { body := client.GetReplicationBody(d) - _, headers, err := apiClient.SendRequest("POST", models.PathReplication, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", models.PathReplication, body, 201) if err != nil { return err } @@ -121,7 +121,7 @@ func resourceReplicationCreate(d *schema.ResourceData, m interface{}) error { func resourceReplicationRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { d.SetId("") return nil @@ -151,12 +151,12 @@ func resourceReplicationRead(d *schema.ResourceData, m interface{}) error { } switch jsonDataReplication.Trigger.Type { - case "scheduled": - d.Set("schedule", jsonDataReplication.Trigger.TriggerSettings.Cron) - case "event_based": - d.Set("schedule", "event_based") - default: - d.Set("schedule", "manual") + case "scheduled": + d.Set("schedule", jsonDataReplication.Trigger.TriggerSettings.Cron) + case "event_based": + d.Set("schedule", "event_based") + default: + d.Set("schedule", "manual") } d.Set("replication_policy_id", jsonDataReplication.ID) @@ -172,7 +172,7 @@ func resourceReplicationUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.GetReplicationBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } @@ -183,7 +183,7 @@ func resourceReplicationUpdate(d *schema.ResourceData, m interface{}) error { func resourceReplicationDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_replication_test.go b/provider/resource_replication_test.go index 168e7ea..2d821a6 100644 --- a/provider/resource_replication_test.go +++ b/provider/resource_replication_test.go @@ -53,7 +53,7 @@ func testAccCheckReplicationDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_retention_policy.go b/provider/resource_retention_policy.go index e650ac9..bd5589b 100644 --- a/provider/resource_retention_policy.go +++ b/provider/resource_retention_policy.go @@ -104,10 +104,10 @@ func resourceRetentionCreate(d *schema.ResourceData, m interface{}) error { body := client.GetRententionBody(d) id := "" - _, headers, err := apiClient.SendRequest("POST", models.PathRetentions, body, 201) + _, headers, _, err := apiClient.SendRequest("POST", models.PathRetentions, body, 201) if err != nil { project_id := strconv.Itoa(body.Scope.Ref) - resp, _, err := apiClient.SendRequest("GET", models.PathProjects+"/"+project_id, nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", models.PathProjects+"/"+project_id, nil, 200) var jsonData models.ProjectsBodyResponses err = json.Unmarshal([]byte(resp), &jsonData) @@ -115,7 +115,7 @@ func resourceRetentionCreate(d *schema.ResourceData, m interface{}) error { if err != nil { return err } - _, headers, err = apiClient.SendRequest("PUT", models.PathRetentions+"/"+jsonData.Metadata.RetentionId, body, 200) + _, headers, _, err = apiClient.SendRequest("PUT", models.PathRetentions+"/"+jsonData.Metadata.RetentionId, body, 200) if err != nil { return err } @@ -132,7 +132,7 @@ func resourceRetentionRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) log.Printf("[DEBUG] Id: %+v\n", d.Id()) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { return err } @@ -169,7 +169,7 @@ func resourceRetentionUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.GetRententionBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } @@ -202,7 +202,7 @@ func resourceRetentionDelete(d *schema.ResourceData, m interface{}) error { Id: retention_id, } - _, _, err = apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err = apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } diff --git a/provider/resource_retention_policy_test.go b/provider/resource_retention_policy_test.go index a367fd5..7ac59fe 100644 --- a/provider/resource_retention_policy_test.go +++ b/provider/resource_retention_policy_test.go @@ -9,25 +9,6 @@ import ( const resourceHarborRetentionMain = "harbor_retention_policy.main" -// func testAccCheckRetentionDestroy(s *terraform.State) error { -// apiClient := testAccProvider.Meta().(*client.Client) -// r := "harbor_retention_policy" - -// for _, rs := range s.RootModule().Resources { -// if rs.Type != r { -// continue -// } - -// resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) -// if err != nil { -// return fmt.Errorf("Resouse was not delete \n %s", resp) -// } - -// } - -// return nil -// } - func TestAccRetentionUpdate(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/provider/resource_robot_account.go b/provider/resource_robot_account.go index 5b666b8..51308b6 100755 --- a/provider/resource_robot_account.go +++ b/provider/resource_robot_account.go @@ -115,7 +115,7 @@ func resourceRobotAccountCreate(d *schema.ResourceData, m interface{}) error { body := client.RobotBody(d) - resp, headers, err := apiClient.SendRequest("POST", "/robots", body, 201) + resp, headers, _, err := apiClient.SendRequest("POST", "/robots", body, 201) if err != nil { return err } @@ -136,7 +136,7 @@ func resourceRobotAccountCreate(d *schema.ResourceData, m interface{}) error { secret := models.RobotSecret{ Secret: d.Get("secret").(string), } - _, _, err := apiClient.SendRequest("PATCH", "/robots/"+robotID, secret, 200) + _, _, _, err := apiClient.SendRequest("PATCH", "/robots/"+robotID, secret, 200) if err != nil { return err } @@ -178,7 +178,7 @@ func resourceRobotAccountUpdate(d *schema.ResourceData, m interface{}) error { body.Name = robot.Name } - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } @@ -187,7 +187,7 @@ func resourceRobotAccountUpdate(d *schema.ResourceData, m interface{}) error { secret := models.RobotSecret{ Secret: d.Get("secret").(string), } - _, _, err := apiClient.SendRequest("PATCH", d.Id(), secret, 200) + _, _, _, err := apiClient.SendRequest("PATCH", d.Id(), secret, 200) if err != nil { return err } @@ -198,7 +198,7 @@ func resourceRobotAccountUpdate(d *schema.ResourceData, m interface{}) error { func resourceRobotAccountDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } @@ -206,7 +206,7 @@ func resourceRobotAccountDelete(d *schema.ResourceData, m interface{}) error { } func getRobot(d *schema.ResourceData, apiClient *client.Client) (models.RobotBody, error) { - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { return models.RobotBody{}, err } diff --git a/provider/resource_robot_account_test.go b/provider/resource_robot_account_test.go index 725141e..35f7328 100644 --- a/provider/resource_robot_account_test.go +++ b/provider/resource_robot_account_test.go @@ -67,7 +67,7 @@ func testAccCheckRobotDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) } diff --git a/provider/resource_tasks.go b/provider/resource_tasks.go index 51f6390..7d67ff6 100644 --- a/provider/resource_tasks.go +++ b/provider/resource_tasks.go @@ -58,7 +58,7 @@ func resourceTasksCreate(d *schema.ResourceData, m interface{}) error { }, } - resp, _, err := apiClient.SendRequest("GET", pathVuln, nil, 0) + resp, _, _, err := apiClient.SendRequest("GET", pathVuln, nil, 0) if err != nil { return err } @@ -74,7 +74,7 @@ func resourceTasksCreate(d *schema.ResourceData, m interface{}) error { } else { log.Printf("No schedule found performing POST request") } - _, _, err = apiClient.SendRequest(requestType, pathVuln, body, 0) + _, _, _, err = apiClient.SendRequest(requestType, pathVuln, body, 0) if err != nil { return err diff --git a/provider/resource_user.go b/provider/resource_user.go index e939fba..4607351 100644 --- a/provider/resource_user.go +++ b/provider/resource_user.go @@ -55,7 +55,7 @@ func resourceUserCreate(d *schema.ResourceData, m interface{}) error { body := client.UserBody(d) - _, header, err := apiClient.SendRequest("POST", models.PathUsers, &body, 201) + _, header, _, err := apiClient.SendRequest("POST", models.PathUsers, &body, 201) if err != nil { return err } @@ -71,7 +71,7 @@ func resourceUserCreate(d *schema.ResourceData, m interface{}) error { func resourceUserRead(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) + resp, _, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200) if err != nil { return err } @@ -94,18 +94,18 @@ func resourceUserUpdate(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) body := client.UserBody(d) - _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) + _, _, _, err := apiClient.SendRequest("PUT", d.Id(), body, 200) if err != nil { return err } - _, _, err = apiClient.SendRequest("PUT", d.Id()+"/sysadmin", body, 200) + _, _, _, err = apiClient.SendRequest("PUT", d.Id()+"/sysadmin", body, 200) if err != nil { return err } if d.HasChange("password") == true { - _, _, err = apiClient.SendRequest("PUT", d.Id()+"/password", body, 200) + _, _, _, err = apiClient.SendRequest("PUT", d.Id()+"/password", body, 200) if err != nil { return err } @@ -117,7 +117,7 @@ func resourceUserUpdate(d *schema.ResourceData, m interface{}) error { func resourceUserDelete(d *schema.ResourceData, m interface{}) error { apiClient := m.(*client.Client) - _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) + _, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200) if err != nil { return err } diff --git a/provider/resource_user_test.go b/provider/resource_user_test.go index a594176..ff747e0 100644 --- a/provider/resource_user_test.go +++ b/provider/resource_user_test.go @@ -1,3 +1,4 @@ +//go:build internal_auth // +build internal_auth package provider @@ -21,7 +22,7 @@ func testAccCheckUserDestroy(s *terraform.State) error { continue } - resp, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) + resp, _, _, err := apiClient.SendRequest("GET", rs.Primary.ID, nil, 404) if err != nil { return fmt.Errorf("Resouse was not delete \n %s", resp) }