@@ -1607,6 +1607,97 @@ func TestGetUpdateOptsForNodeSecureBoot(t *testing.T) {
16071607 }
16081608}
16091609
1610+ func TestGetUpdateOptsForNodeOCIWithPullSecret (t * testing.T ) {
1611+ eventPublisher := func (reason , message string ) {}
1612+ auth := clients.AuthConfig {Type : clients .NoAuth }
1613+
1614+ host := makeHost ()
1615+ host .Spec .Image .URL = "oci://quay.io/test/image:latest"
1616+ host .Spec .Image .Checksum = ""
1617+ host .Spec .Image .ChecksumType = ""
1618+
1619+ prov , err := newProvisionerWithSettings (host , bmc.Credentials {}, eventPublisher , "https://ironic.test" , auth )
1620+ if err != nil {
1621+ t .Fatal (err )
1622+ }
1623+ ironicNode := & nodes.Node {}
1624+
1625+ provData := provisioner.ProvisionData {
1626+ Image : * host .Spec .Image ,
1627+ BootMode : metal3api .DefaultBootMode ,
1628+ ImagePullSecret : "dXNlcjpwYXNz" ,
1629+ }
1630+ patches := prov .getInstanceUpdateOpts (ironicNode , provData ).Updates
1631+
1632+ t .Logf ("patches: %v" , patches )
1633+
1634+ expected := []struct {
1635+ Path string
1636+ Value any
1637+ }{
1638+ {
1639+ Path : "/instance_info/image_source" ,
1640+ Value : "oci://quay.io/test/image:latest" ,
1641+ },
1642+ {
1643+ Path : "/instance_info/image_pull_secret" ,
1644+ Value : "dXNlcjpwYXNz" ,
1645+ },
1646+ }
1647+
1648+ for _ , e := range expected {
1649+ t .Run (e .Path , func (t * testing.T ) {
1650+ var update nodes.UpdateOperation
1651+ for _ , patch := range patches {
1652+ u , ok := patch .(nodes.UpdateOperation )
1653+ require .True (t , ok , "expected patch to be UpdateOperation" )
1654+ if u .Path == e .Path {
1655+ update = u
1656+ break
1657+ }
1658+ }
1659+ if update .Path != e .Path {
1660+ t .Errorf ("did not find %q in updates" , e .Path )
1661+ return
1662+ }
1663+ assert .Equal (t , e .Value , update .Value , "%s does not match" , e .Path )
1664+ })
1665+ }
1666+ }
1667+
1668+ func TestGetUpdateOptsForNodeOCIWithoutPullSecret (t * testing.T ) {
1669+ eventPublisher := func (reason , message string ) {}
1670+ auth := clients.AuthConfig {Type : clients .NoAuth }
1671+
1672+ host := makeHost ()
1673+ host .Spec .Image .URL = "oci://quay.io/test/image:latest"
1674+ host .Spec .Image .Checksum = ""
1675+ host .Spec .Image .ChecksumType = ""
1676+
1677+ prov , err := newProvisionerWithSettings (host , bmc.Credentials {}, eventPublisher , "https://ironic.test" , auth )
1678+ if err != nil {
1679+ t .Fatal (err )
1680+ }
1681+ ironicNode := & nodes.Node {}
1682+
1683+ provData := provisioner.ProvisionData {
1684+ Image : * host .Spec .Image ,
1685+ BootMode : metal3api .DefaultBootMode ,
1686+ }
1687+ patches := prov .getInstanceUpdateOpts (ironicNode , provData ).Updates
1688+
1689+ t .Logf ("patches: %v" , patches )
1690+
1691+ for _ , patch := range patches {
1692+ update , ok := patch .(nodes.UpdateOperation )
1693+ require .True (t , ok , "expected patch to be UpdateOperation" )
1694+ if update .Path == "/instance_info/image_pull_secret" {
1695+ assert .Nil (t , update .Value , "image_pull_secret should be nil when no secret is provided" )
1696+ return
1697+ }
1698+ }
1699+ }
1700+
16101701func TestBuildCleanStepsForUpdateFirmware (t * testing.T ) {
16111702 nodeUUID := "eec38659-4c68-7431-9535-d10766f07a58"
16121703 cases := []struct {
0 commit comments