...

Source file src/edge-infra.dev/pkg/edge/constants/api/workload/workload.go

Documentation: edge-infra.dev/pkg/edge/constants/api/workload

     1  // Package workload defines the API constants + validation functions for workload.edge.ncr.com
     2  package workload
     3  
     4  import (
     5  	"fmt"
     6  
     7  	"edge-infra.dev/pkg/edge/constants"
     8  )
     9  
    10  // Label is the string key used to store workload information as labels
    11  // on K8s resources / KRMs
    12  const Label = "workload." + constants.Domain
    13  const SIEMLabel = "siem.edge.ncr.com"
    14  
    15  // Consts for Logging Related Namespace Labels
    16  const (
    17  	HelmEdgeIDLabel       = SIEMLabel + "/helm-edge-id"
    18  	HelmChartVersionLabel = SIEMLabel + "/helm-chart-version"
    19  	HelmChartNameLabel    = SIEMLabel + "/helm-chart-name"
    20  )
    21  
    22  // WorkloadType a set of permissible string values for the Workload label
    23  type Type string
    24  
    25  // WorkloadType enum values
    26  const (
    27  	Platform = Type("platform")
    28  	NCR      = Type("ncr")
    29  	Tenant   = Type("tenant")
    30  	Helm     = Type("helm")
    31  )
    32  
    33  var types = []Type{Platform, NCR, Tenant, Helm}
    34  
    35  var ErrInvalidType = fmt.Errorf("invalid workload type, expected %v", types)
    36  
    37  // IsValid checks that a workload Type is valid based on the workload Type enum
    38  func (wt Type) IsValid() error {
    39  	found := false
    40  	for _, wlType := range types {
    41  		if wt == wlType {
    42  			found = true
    43  		}
    44  	}
    45  	if found {
    46  		return nil
    47  	}
    48  	return fmt.Errorf("%v: %w", wt, ErrInvalidType)
    49  }
    50  

View as plain text