Created
June 15, 2015 10:45
-
-
Save jordimassaguerpla/f5a7b7a20c0b08e7a0d0 to your computer and use it in GitHub Desktop.
get download link for a binary in open suse build service
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 "net/http" | |
import "fmt" | |
import "io/ioutil" | |
import "regexp" | |
func getLink(server string, project string, repo string, name string, arch string, extension string) string { | |
pattern := "href=\"" + name + "." + arch + ".*Build.*" + extension + "\"" | |
re := regexp.MustCompile(pattern) | |
resp, err := http.Get("http://" + server + "/repositories/" + project + "/" + repo) | |
if err != nil { | |
// handle error | |
} | |
defer resp.Body.Close() | |
body, err := ioutil.ReadAll(resp.Body) | |
link := re.FindString(string(body)) | |
return link | |
} | |
func main() { | |
server := "download.opensuse.org" | |
project := "Virtualization:/containers:/Portus" | |
repo := "images" | |
name := "PortusAppliance" | |
arch := "x86_64" | |
extension := "qcow2" | |
link := getLink(server, project, repo, name, arch, extension) | |
fmt.Printf(link) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment