microsoft / terraform-provider-power-platform

Power Platform Terraform Provider
https://registry.terraform.io/providers/microsoft/power-platform/latest/docs
MIT License
35 stars 13 forks source link

Incorrect log output in provider.go for oidcRequestUrl and oidcRequestToken code blocks #339

Closed ianjensenisme closed 5 months ago

ianjensenisme commented 5 months ago

Describe the bug

There are debug outputs in the oidcRequestUrl and oidcRequestToken blocks of the provider code that state the opposite of what is actually happening in the code. These debug outputs are development artifacts and should be removed entirely.

To Reproduce

Either observe the incorrect log output or directly review lines 192 - 209 in provider.go.

Sample Terraform Code

Current:

    //Check for AzDO and GitHub environment variables
    oidcRequestUrl := ""
    envOidcRequestUrl := MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_URL", "ACTIONS_ID_TOKEN_REQUEST_URL"})
    if config.OidcRequestUrl.IsNull() {
        tflog.Debug(ctx, "OIDC request URL environment variable is null")
        oidcRequestUrl = envOidcRequestUrl
    } else {
        oidcRequestUrl = config.OidcRequestUrl.ValueString()
    }

    oidcRequestToken := ""
    envOidcRequestToken := MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_TOKEN", "ACTIONS_ID_TOKEN_REQUEST_TOKEN"})
    if config.OidcRequestToken.IsNull() {
        tflog.Debug(ctx, "OIDC request token environment variable is null")
        oidcRequestToken = envOidcRequestToken
    } else {
        oidcRequestToken = config.OidcRequestToken.ValueString()
    }

Fixed:

    //Check for AzDO and GitHub environment variables
    oidcRequestUrl := ""
    envOidcRequestUrl := MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_URL", "ACTIONS_ID_TOKEN_REQUEST_URL"})
    if config.OidcRequestUrl.IsNull() {
        oidcRequestUrl = envOidcRequestUrl
    } else {
        oidcRequestUrl = config.OidcRequestUrl.ValueString()
    }

    oidcRequestToken := ""
    envOidcRequestToken := MultiEnvDefaultFunc([]string{"ARM_OIDC_REQUEST_TOKEN", "ACTIONS_ID_TOKEN_REQUEST_TOKEN"})
    if config.OidcRequestToken.IsNull() {
        oidcRequestToken = envOidcRequestToken
    } else {
        oidcRequestToken = config.OidcRequestToken.ValueString()
    }

Expected behavior

Either correct log output, or ideally no log output from these blocks, given the other troubleshooting options available in the provider.

System Information

Contribution

Do you plan to raise a PR to address this issue? YES