prow/spyglass/gcsartifact_fetcher.go
func newGCSJobSource(src string) (*gcsJobSource, error) {
	gcsURL, err := url.Parse(fmt.Sprintf("gs://%s", src))
	if err != nil {
		return &gcsJobSource{}, ErrCannotParseSource
	}
	gcsPath := &gcs.Path{}
	err = gcsPath.SetURL(gcsURL)
	if err != nil {
		return &gcsJobSource{}, ErrCannotParseSource
	}

	tokens := strings.FieldsFunc(gcsPath.Object(), func(c rune) bool { return c == '/' })
	if len(tokens) < 2 {
		return &gcsJobSource{}, ErrCannotParseSource
	}
	buildID := tokens[len(tokens)-1]
	name := tokens[len(tokens)-2]
	return &gcsJobSource{
		source:     src,
		linkPrefix: "gs://",
		bucket:     gcsPath.Bucket(),
		jobPrefix:  path.Clean(gcsPath.Object()) + "/",
		jobName:    name,
		buildID:    buildID,
	}, nil
}
func newGCSJobSource(src string) (*gcsJobSource, error) {
	gcsURL, err := url.Parse(fmt.Sprintf("gs://%s", src))
	if err != nil {
		return &gcsJobSource{}, ErrCannotParseSource
	}
	gcsPath := &gcs.Path{}
	err = gcsPath.SetURL(gcsURL)
	if err != nil {
		return &gcsJobSource{}, ErrCannotParseSource
	}

	tokens := strings.FieldsFunc(gcsPath.Object(), func(c rune) bool { return c == '/' })
	if len(tokens) < 2 {
		return &gcsJobSource{}, ErrCannotParseSource
	}
	buildID := tokens[len(tokens)-1]
	name := tokens[len(tokens)-2]
	return &gcsJobSource{
		source:     src,
		linkPrefix: "gs://",
		bucket:     gcsPath.Bucket(),
		jobPrefix:  path.Clean(gcsPath.Object()) + "/",
		jobName:    name,
		buildID:    buildID,
	}, nil
}
func newGCSJobSource ( src string ) ( * gcsJobSource , error ) { gcsURL , err := url . Parse ( fmt . Sprintf ( " " , src ) ) if err != nil { return & gcsJobSource { } , ErrCannotParseSource } gcsPath := & gcs . Path { } err = gcsPath . SetURL ( gcsURL ) if err != nil { return & gcsJobSource { } , ErrCannotParseSource } tokens := strings . FieldsFunc ( gcsPath . Object ( ) , func ( c rune ) bool { return c == '/' } ) if len ( tokens ) < 2 { return & gcsJobSource { } , ErrCannotParseSource } buildID := tokens [ len ( tokens ) - 1 ] name := tokens [ len ( tokens ) - 2 ] return & gcsJobSource { source : src , linkPrefix : " " , bucket : gcsPath . Bucket ( ) , jobPrefix : path . Clean ( gcsPath . Object ( ) ) + " " , jobName : name , buildID : buildID , } , nil }
// newGCSJobSource creates a new gcsJobSource from a given bucket and jobPrefix
newGCSJobSource creates a new gcsJobSource from a given bucket and jobPrefix