Skip to content

Commit

Permalink
refactor for go-gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Nov 1, 2024
1 parent a9c161a commit 774f6ef
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (gl *GitLabClient) AddFileToProject(file []byte) {
}

func (gl *GitLabClient) DeleteProject() {
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
if resp.StatusCode != 404 && err != nil {
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (gl *GitLabClient) AddFileToProject(file []byte) {
}

func (gl *GitLabClient) DeleteProject() {
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
if err != nil {
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (gl *GitLabClient) CreateProject() {
}

func (gl *GitLabClient) DeleteProject() {
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
if resp.StatusCode != 404 && err != nil {
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (gl *GitLabClient) AddFileToProject(file []byte) {
}

func (gl *GitLabClient) DeleteProject() {
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName())
resp, err := gl.client.Projects.DeleteProject(gl.ProjectName(), utils.GetDeleteProjectOptions())
if resp.StatusCode != 404 && err != nil {
gl.t.Errorf("error deleting project with status %s and error %s", resp.Status, err.Error())
}
Expand Down
8 changes: 8 additions & 0 deletions test/integration/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
"github.com/xanzy/go-gitlab"
)

// GetRandomStringFromSetup gets a random string output variable setup.
Expand All @@ -44,3 +45,10 @@ func GetFileContents(t *testing.T, path string) []byte {
func LastElement(str, sep string) string {
return strings.Split(str, sep)[len(strings.Split(str, sep))-1]
}

// GetDeleteProjectOptions returns default DeleteProjectOptions
func GetDeleteProjectOptions() *gitlab.DeleteProjectOptions {
return &gitlab.DeleteProjectOptions{
PermanentlyRemove: gitlab.Ptr(true),
}
}

0 comments on commit 774f6ef

Please sign in to comment.