Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions controller/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,17 @@ func buildProvider(
if cfg.OCIAuthInstancePrincipal {
if len(cfg.OCICompartmentOCID) == 0 {
err = fmt.Errorf("instance principal authentication requested, but no compartment OCID provided")
} else {
authConfig := oci.OCIAuthConfig{UseInstancePrincipal: true}
config = &oci.OCIConfig{Auth: authConfig, CompartmentID: cfg.OCICompartmentOCID}
break
}
authConfig := oci.OCIAuthConfig{UseInstancePrincipal: true}
config = &oci.OCIConfig{Auth: authConfig, CompartmentID: cfg.OCICompartmentOCID}
} else {
config, err = oci.LoadOCIConfig(cfg.OCIConfigFile)
if config, err = oci.LoadOCIConfig(cfg.OCIConfigFile); err != nil {
break
}
}
config.ZoneCacheDuration = cfg.OCIZoneCacheDuration
if err == nil {
Copy link
Contributor

@jrosinsk jrosinsk Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the panic happens on the access to the non-existant ZoneCacheDuration.
another way to fix this would be to just protect that call when there is no config loaded:

`

         if err == nil {
                    config.ZoneCacheDuration = cfg.OCIZoneCacheDuration
                    p, err = oci.NewOCIProvider(*config, domainFilter, zoneIDFilter, cfg.OCIZoneScope, cfg.DryRun)
            }
    case "rfc2136":

`

Seems a bit more confusing with the break statements.

p, err = oci.NewOCIProvider(*config, domainFilter, zoneIDFilter, cfg.OCIZoneScope, cfg.DryRun)
}
p, err = oci.NewOCIProvider(*config, domainFilter, zoneIDFilter, cfg.OCIZoneScope, cfg.DryRun)
case "rfc2136":
tlsConfig := rfc2136.TLSConfig{
UseTLS: cfg.RFC2136UseTLS,
Expand Down
17 changes: 17 additions & 0 deletions controller/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,23 @@ func TestBuildProvider(t *testing.T) {
},
expectedType: "*provider.CachedProvider",
},
{
name: "oci provider instance principal without compartment OCID",
cfg: &externaldns.Config{
Provider: "oci",
OCIAuthInstancePrincipal: true,
OCICompartmentOCID: "",
},
expectedError: "instance principal authentication requested, but no compartment OCID provided",
},
{
name: "oci provider without config file",
cfg: &externaldns.Config{
Provider: "oci",
OCIConfigFile: "",
},
expectedError: "reading OCI config file",
},
{
name: "coredns provider",
cfg: &externaldns.Config{
Expand Down
Loading