github.com/stevenmatthewt/agent@v3.5.4+incompatible/agent/artifact_searcher.go (about)

     1  package agent
     2  
     3  import (
     4  	"github.com/buildkite/agent/api"
     5  	"github.com/buildkite/agent/logger"
     6  )
     7  
     8  type ArtifactSearcher struct {
     9  	// The APIClient that will be used when uploading jobs
    10  	APIClient *api.Client
    11  
    12  	// The ID of the Build that these artifacts belong to
    13  	BuildID string
    14  }
    15  
    16  func (a *ArtifactSearcher) Search(query string, scope string) ([]*api.Artifact, error) {
    17  	if scope == "" {
    18  		logger.Info("Searching for artifacts: \"%s\"", query)
    19  	} else {
    20  		logger.Info("Searching for artifacts: \"%s\" within step: \"%s\"", query, scope)
    21  	}
    22  
    23  	options := &api.ArtifactSearchOptions{Query: query, Scope: scope}
    24  	artifacts, _, err := a.APIClient.Artifacts.Search(a.BuildID, options)
    25  
    26  	return artifacts, err
    27  }