@@ -450,6 +450,7 @@ var (
450
450
KeyHostName : true ,
451
451
KeyIP : true ,
452
452
KeyIP6 : true ,
453
+ KeyLabel : true ,
453
454
KeyNetwork : true ,
454
455
KeyNetworkAlias : true ,
455
456
KeyPodName : true ,
@@ -1622,17 +1623,19 @@ func getServiceName(quadletUnitFile *parser.UnitFile, groupName string, defaultE
1622
1623
return removeExtension (quadletUnitFile .Filename , "" , defaultExtraSuffix )
1623
1624
}
1624
1625
1625
- func ConvertPod (podUnit * parser.UnitFile , name string , unitsInfoMap map [string ]* UnitInfo , isUser bool ) (* parser.UnitFile , error ) {
1626
+ func ConvertPod (podUnit * parser.UnitFile , name string , unitsInfoMap map [string ]* UnitInfo , isUser bool ) (* parser.UnitFile , error , error ) {
1627
+ var warn , warnings error
1628
+
1626
1629
unitInfo , ok := unitsInfoMap [podUnit .Filename ]
1627
1630
if ! ok {
1628
- return nil , fmt .Errorf ("internal error while processing pod %s" , podUnit .Filename )
1631
+ return nil , warnings , fmt .Errorf ("internal error while processing pod %s" , podUnit .Filename )
1629
1632
}
1630
1633
1631
1634
service := podUnit .Dup ()
1632
1635
service .Filename = unitInfo .ServiceFileName ()
1633
1636
1634
1637
if err := translateUnitDependencies (service , unitsInfoMap ); err != nil {
1635
- return nil , err
1638
+ return nil , warnings , err
1636
1639
}
1637
1640
1638
1641
addDefaultDependencies (service , isUser )
@@ -1642,7 +1645,7 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
1642
1645
}
1643
1646
1644
1647
if err := checkForUnknownKeys (podUnit , PodGroup , supportedPodKeys ); err != nil {
1645
- return nil , err
1648
+ return nil , warnings , err
1646
1649
}
1647
1650
1648
1651
// Derive pod name from unit name (with added prefix), or use user-provided name.
@@ -1701,13 +1704,17 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
1701
1704
)
1702
1705
1703
1706
if err := handleUserMappings (podUnit , PodGroup , execStartPre , true ); err != nil {
1704
- return nil , err
1707
+ return nil , warnings , err
1705
1708
}
1706
1709
1707
1710
handlePublishPorts (podUnit , PodGroup , execStartPre )
1708
1711
1712
+ labels , warn := podUnit .LookupAllKeyVal (PodGroup , KeyLabel )
1713
+ warnings = errors .Join (warnings , warn )
1714
+ execStartPre .addLabels (labels )
1715
+
1709
1716
if err := addNetworks (podUnit , PodGroup , service , unitsInfoMap , execStartPre ); err != nil {
1710
- return nil , err
1717
+ return nil , warnings , err
1711
1718
}
1712
1719
1713
1720
stringsKeys := map [string ]string {
@@ -1728,7 +1735,7 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
1728
1735
lookupAndAddAllStrings (podUnit , PodGroup , allStringsKeys , execStartPre )
1729
1736
1730
1737
if err := addVolumes (podUnit , service , PodGroup , unitsInfoMap , execStartPre ); err != nil {
1731
- return nil , err
1738
+ return nil , warnings , err
1732
1739
}
1733
1740
1734
1741
execStartPre .add ("--infra-name" , fmt .Sprintf ("%s-infra" , podName ))
@@ -1745,7 +1752,7 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
1745
1752
"PIDFile" , "%t/%N.pid" ,
1746
1753
)
1747
1754
1748
- return service , nil
1755
+ return service , warnings , nil
1749
1756
}
1750
1757
1751
1758
func handleUser (unitFile * parser.UnitFile , groupName string , podman * PodmanCmdline ) error {
0 commit comments