Created
January 13, 2014 18:20
-
-
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.
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 ( | |
"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