github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/k8s/labels.go (about) 1 package k8s 2 3 import ( 4 "k8s.io/apimachinery/pkg/labels" 5 6 "github.com/tilt-dev/tilt/pkg/model" 7 ) 8 9 // https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ 10 const ManagedByLabel = "app.kubernetes.io/managed-by" 11 const ManagedByValue = "tilt" 12 13 const ManifestNameLabel = "tilt-manifest" 14 15 func TiltManagedByLabel() model.LabelPair { 16 return model.LabelPair{ 17 Key: ManagedByLabel, 18 Value: ManagedByValue, 19 } 20 } 21 22 func ManagedByTiltSelector() labels.Selector { 23 return labels.Set{ManagedByLabel: ManagedByValue}.AsSelector() 24 } 25 26 func NewTiltLabelMap() map[string]string { 27 return map[string]string{ 28 ManagedByLabel: ManagedByValue, 29 } 30 } 31 32 func LabelPairsToSelector(lps []model.LabelPair) labels.Selector { 33 ls := labels.Set{} 34 for _, lp := range lps { 35 ls[lp.Key] = lp.Value 36 } 37 return ls.AsSelector() 38 }