Skip to content

Instantly share code, notes, and snippets.

@scriptonist
Created January 25, 2019 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scriptonist/139603c751aef37f8c14c4fd2b5d1e42 to your computer and use it in GitHub Desktop.
Save scriptonist/139603c751aef37f8c14c4fd2b5d1e42 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"os"
gitlab "github.com/xanzy/go-gitlab"
)
func main() {
token := os.Getenv("GITLAB_TOKEN")
if token == "" {
fmt.Println("Please set GITLAB_TOKEN environment variable with your token")
os.Exit(0)
}
git := gitlab.NewClient(nil, token)
v := true
projects, _, err := git.Projects.ListProjects(&gitlab.ListProjectsOptions{
Owned: &v,
ListOptions: gitlab.ListOptions{
PerPage: 500,
},
}, nil)
if err != nil {
log.Fatal(err)
}
for _, project := range projects {
r, err := git.Projects.DeleteProject(project.ID, nil)
if err != nil {
log.Println("Failed deleting ", project.Name)
}
log.Println("deleted ", project.Name, r.StatusCode)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment