Created
January 25, 2019 09:03
-
-
Save scriptonist/139603c751aef37f8c14c4fd2b5d1e42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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