github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/worker/runtime/properties.go (about)

     1  package runtime
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"code.cloudfoundry.org/garden"
     7  )
     8  
     9  // propertiesToFilterList converts a set of garden properties to a list of
    10  // filters as expected by containerd.
    11  //
    12  // containerd filters are in the form of
    13  //
    14  //           <what>.<field><operator><value>
    15  //
    16  // which, in our very specific case of properties, means
    17  //
    18  //           labels.foo==bar
    19  //           |      |  | value
    20  //           |      |  equality
    21  //           |      key
    22  //           what
    23  //
    24  func propertiesToFilterList(properties garden.Properties) (filters []string, err error) {
    25  	filters = make([]string, len(properties))
    26  
    27  	idx := 0
    28  	for k, v := range properties {
    29  		if k == "" || v == "" {
    30  			err = fmt.Errorf("key or value must not be empty")
    31  			return
    32  		}
    33  
    34  		filters[idx] = "labels." + k + "==" + v
    35  		idx++
    36  	}
    37  
    38  	return
    39  }