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 c633526
Show file tree
Hide file tree
Showing 5 changed files with 13 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
9 changes: 9 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,11 @@ 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{
FullPath: gitlab.Ptr("group/project"),
PermanentlyRemove: gitlab.Ptr(true),
}
}

0 comments on commit c633526

Please sign in to comment.