github.com/kyma-project/kyma-environment-broker@v0.0.1/common/director/query.go (about)

     1  package director
     2  
     3  import "fmt"
     4  
     5  const (
     6  	instanceIDLabelKey = "broker_instance_id"
     7  )
     8  
     9  type queryProvider struct{}
    10  
    11  func (qp queryProvider) Runtime(runtimeID string) string {
    12  	return fmt.Sprintf(`query {
    13  	result: runtime(id: "%s") {
    14  	%s
    15  	}
    16  }`, runtimeID, runtimeStatusData())
    17  }
    18  
    19  func (qp queryProvider) SetRuntimeLabel(runtimeId, key, value string) string {
    20  	return fmt.Sprintf(`mutation {
    21  		result: setRuntimeLabel(runtimeID: "%s", key: "%s", value: "%s") {
    22  			%s
    23  		}
    24  	}`, runtimeId, key, value, labelData())
    25  }
    26  
    27  func (qp queryProvider) RuntimeForInstanceId(instanceID string) string {
    28  	return fmt.Sprintf(`query {
    29  	result: runtimes(filter: { key: "%s" query: "\"%s\"" }) {
    30      data {
    31        id
    32  	}
    33  }
    34  }`, instanceIDLabelKey, instanceID)
    35  }
    36  
    37  func runtimeStatusData() string {
    38  	return `id
    39  			status{
    40  				condition
    41  			}`
    42  }
    43  
    44  func labelData() string {
    45  	return `key
    46  			value`
    47  }