Skip to content

Instantly share code, notes, and snippets.

@imjasonh
Created January 13, 2014 18:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imjasonh/8405302 to your computer and use it in GitHub Desktop.
Save imjasonh/8405302 to your computer and use it in GitHub Desktop.
Simple script to list all GoogleCloudPlatform repos on GitHub and check for those which do not define a top-level app.yaml file.
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
)
func main() {
resp, err := http.Get("https://api.github.com/users/GoogleCloudPlatform/repos")
if err != nil {
log.Fatalf("get:", err)
}
var r response
err = json.NewDecoder(resp.Body).Decode(&r)
if err != nil {
log.Fatalf("decode:", err)
}
log.Printf("Found %d repos\n", len(r))
for _, repo := range r {
url := strings.Replace(repo.ContentsURL, "{+path}", "app.yaml", -1)
resp, err = http.Get(url)
if err != nil {
log.Fatalf("get %s:", url, err)
}
if resp.StatusCode == http.StatusNotFound {
fmt.Println(repo.FullName)
}
}
}
type response []struct {
FullName string `json:"full_name"`
ContentsURL string `json:"contents_url"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment