Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/hashicorp/t…
Browse files Browse the repository at this point in the history
…erraform-plugin-sdk/v2-2.28.0
  • Loading branch information
flbla authored Sep 29, 2023
2 parents 35b65f5 + 773a1fd commit 9e038cc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
- '1.2.*'
- '1.3.*'
- '1.4.*'
- '1.5.*'
steps:

- name: Check out code into the Go module directory
Expand All @@ -86,16 +87,16 @@ jobs:
- name: Setup Docker
uses: docker-practice/actions-setup-docker@v1
with:
docker_version: "20.10"
docker_version: "24.0"
docker_channel: stable
docker_daemon_json: '{"insecure-registries":["0.0.0.0/0"]}'

- name: Create kind cluster
uses: helm/[email protected]
with:
version: v0.11.1
node_image: kindest/node:v1.22.0
cluster_name: kind-cluster-v1.22.0
version: v0.20.0
node_image: kindest/node:v1.28.0
cluster_name: kind-cluster-v1.28.0
config: kind-cluster.yaml

- name: Install Nginx ingress controller
Expand Down Expand Up @@ -126,17 +127,20 @@ jobs:
- name: Wait for harbor to be ready
run: |
attempt_counter=0
max_attempts=120 # Max wait will be 10m
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $HARBOR_URL)" != "401" ]]; do
max_attempts=25 # Max wait will be 2m
while [[ "$(curl -k -s -o /dev/null -w ''%{http_code}'' $HARBOR_URL/api/v2.0/configurations -u $HARBOR_USERNAME:$HARBOR_PASSWORD)" != "200" ]]; do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "Max attempts reached"
kubectl get pods -A
curl -v $HARBOR_URL
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 5
done
sleep 5
- name: Set up Go
uses: actions/setup-go@v4
Expand Down
15 changes: 8 additions & 7 deletions provider/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func resourceProjectCreate(d *schema.ResourceData, m interface{}) error {
return err
}

id, err := client.GetID(headers)
id, _ := client.GetID(headers)
d.SetId(id)
return resourceProjectRead(d, m)
}
Expand All @@ -100,15 +100,16 @@ func resourceProjectRead(d *schema.ResourceData, m interface{}) error {
resp, _, respCode, err := apiClient.SendRequest("GET", d.Id(), nil, 200)
if respCode == 404 && err != nil {
d.SetId("")
return fmt.Errorf("Resource not found %s", d.Id())
return nil
} else if err != nil {
return fmt.Errorf("resource not found %s", d.Id())
}

var jsonData models.ProjectsBodyResponses
err = json.Unmarshal([]byte(resp), &jsonData)
if err != nil {
return fmt.Errorf("Resource not found %s", d.Id())
return fmt.Errorf("resource not found %s", d.Id())
}

autoScan := jsonData.Metadata.AutoScan
var vuln bool
if autoScan == "" {
Expand Down Expand Up @@ -186,12 +187,12 @@ func resourceProjectDelete(d *schema.ResourceData, m interface{}) error {
projectName := d.Get("name").(string)
repos, _ := apiClient.GetProjectRepositories(projectName)
if len(repos) != 0 {
return fmt.Errorf("Project %s is not empty, please set force_delete to TRUE to clean all repositories", projectName)
return fmt.Errorf("project %s is not empty, please set force_delete to TRUE to clean all repositories", projectName)
}
}

_, _, _, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200)
if err != nil {
_, _, respCode, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200)
if respCode != 404 && err != nil { // We can't delete something that doesn't exist. Hence the 404-check
return err
}
return nil
Expand Down
13 changes: 7 additions & 6 deletions provider/resource_project_member_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ func resourceMembersGroupRead(d *schema.ResourceData, m interface{}) error {
resp, _, respCode, err := apiClient.SendRequest("GET", d.Id(), nil, 200)
if respCode == 404 && err != nil {
d.SetId("")
return fmt.Errorf("Resource not found %s", d.Id())
return nil
} else if err != nil {
return fmt.Errorf("resource not found %s", d.Id())
}

var jsonData models.ProjectMembersBodyResponses
err = json.Unmarshal([]byte(resp), &jsonData)
if err != nil {
return fmt.Errorf("Resource not found %s", d.Id())
return fmt.Errorf("resource not found %s", d.Id())
}

d.Set("role", client.RoleTypeNumber(jsonData.RoleID))
d.Set("project_id", checkProjectid(strconv.Itoa(jsonData.ProjectID)))
d.Set("group_name", jsonData.EntityName)
Expand All @@ -131,9 +132,9 @@ 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)
if err != nil {
fmt.Println(err)
_, _, respCode, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200)
if respCode != 404 && err != nil { // We can't delete something that doesn't exist. Hence the 404-check
return err
}
return nil
}
15 changes: 9 additions & 6 deletions provider/resource_project_member_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,20 @@ func resourceMembersUserRead(d *schema.ResourceData, m interface{}) error {
resp, _, respCode, err := apiClient.SendRequest("GET", d.Id(), nil, 200)
if respCode == 404 && err != nil {
d.SetId("")
return fmt.Errorf("Resource not found %s", d.Id())
return nil
} else if err != nil {
return fmt.Errorf("resource not found %s", d.Id())
}

var jsonData models.ProjectMembersBodyResponses
err = json.Unmarshal([]byte(resp), &jsonData)
if err != nil {
return fmt.Errorf("Resource not found %s", d.Id())
return fmt.Errorf("resource not found %s", d.Id())
}

d.Set("role", client.RoleTypeNumber(jsonData.RoleID))
d.Set("project_id", checkProjectid(strconv.Itoa(jsonData.ProjectID)))
d.Set("user_name", jsonData.EntityName)

return nil
}

Expand All @@ -109,9 +112,9 @@ 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)
if err != nil {
fmt.Println(err)
_, _, respCode, err := apiClient.SendRequest("DELETE", d.Id(), nil, 200)
if respCode != 404 && err != nil { // We can't delete something that doesn't exist. Hence the 404-check
return err
}
return nil
}
4 changes: 2 additions & 2 deletions provider/resource_replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func testAccCheckReplicationUpdate() string {
}

func TestDestinationNamespace(t *testing.T) {
var scheduleType = "* 0/15 * * * *"
var scheduleType = "0 0/15 * * * *"
var destNamepace = "gcp-project"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -125,7 +125,7 @@ func TestDestinationNamespace(t *testing.T) {
}

func TestDestinationNamespaceReplaceCount(t *testing.T) {
var scheduleType = "* 0/15 * * * *"
var scheduleType = "0 0/15 * * * *"
var destNamespaceReplaceCount = 0

resource.Test(t, resource.TestCase{
Expand Down

0 comments on commit 9e038cc

Please sign in to comment.