Skip to content

Commit

Permalink
added reponse code var
Browse files Browse the repository at this point in the history
  • Loading branch information
wrighbr committed May 17, 2022
1 parent 036d79a commit a023c3b
Show file tree
Hide file tree
Showing 33 changed files with 93 additions and 128 deletions.
8 changes: 4 additions & 4 deletions client/project.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package client

import (
"fmt"
"encoding/json"
"fmt"
"log"
"strconv"
"strings"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion provider/data_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion provider/data_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 0 additions & 6 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
6 changes: 3 additions & 3 deletions provider/resource_config_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func resourceConfigAuth() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ConflictsWith: ldapConflictsWith(),
RequiredWith: ldapRequiredWith(),
RequiredWith: ldapRequiredWith(),
},
"ldap_uid": {
Type: schema.TypeString,
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions provider/resource_config_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
15 changes: 1 addition & 14 deletions provider/resource_config_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions provider/resource_garbage_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion provider/resource_garbage_collection_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build external_auth
// +build external_auth

package provider
Expand All @@ -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)
}
Expand Down
14 changes: 7 additions & 7 deletions provider/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions provider/resource_harbor_project_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_harbor_project_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions provider/resource_immutable_tag_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_interrogation_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions provider/resource_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions provider/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Loading

0 comments on commit a023c3b

Please sign in to comment.