Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure DevOps repo clone with GIT_USERNAME from coder_external_auth #12436

Closed
wf1-brandon-grant opened this issue Mar 6, 2024 · 4 comments
Closed
Labels
bug Used to filter all bug issues

Comments

@wf1-brandon-grant
Copy link

Hi there,

I am trying to clone a repo from a private Azure DevOps repository.
The user has authenticated using OAUTH2 via the Coder external_auth documentation
image

I am then using the template in the repo and injecting the external auth as a data object in Terraform

data "coder_external_auth" "azure_devops" {
  id = "primary-devops"
}

resource "kubernetes_deployment" "workspace" {
  metadata {
    name      = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
    namespace = var.namespace
    labels = {
      ...
    }
  }
  spec {
    replicas = data.coder_workspace.me.start_count
    selector {
      match_labels = {
        "coder.workspace_id" = data.coder_workspace.me.id
      }
    }
    strategy {
      type = "Recreate"
    }
    template {
      ...
      }
      spec {
        container {
          name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
          # Find the latest version here:
          # https://github.com/coder/envbuilder/tags
          image = "ghcr.io/coder/envbuilder:0.2.7"
          env {
            name  = "CODER_AGENT_TOKEN"
            value = coder_agent.main.token
          }
          env {
            name  = "CODER_AGENT_URL"
            value = replace(data.coder_workspace.me.access_url, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")
          }
          env {
            name  = "GIT_URL"
            value = data.coder_parameter.repo.value == "custom" ? data.coder_parameter.custom_repo_url.value : data.coder_parameter.repo.value
          }
          env {
            name  = "GIT_USERNAME"
            value = data.coder_external_auth.azure_devops.access_token
          }
          env {
            name  = "INIT_SCRIPT"
            value = replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")
          }
          env {
            name  = "FALLBACK_IMAGE"
            value = "codercom/enterprise-base:ubuntu"
          }
          volume_mount {
            name       = "workspaces"
            mount_path = "/workspaces"
          }
        }
        volume {
          name = "workspaces"
          persistent_volume_claim {
            claim_name = kubernetes_persistent_volume_claim.workspaces.metadata.0.name
          }
        }
      }
    }
  }
}

When it get's to checking out the repo, the terraform throws a pretty unhelpful error:

#1: 📦 Cloning https://<our_org>@dev.azure.com/<our_org>/build-automation/_git/devcontainers to /workspaces/devcontainers...
Failed to clone repository: clone "https://<access_token_I_presume>:@dev.azure.com/<our_org>/build-automation/_git/devcontainers": unexpected client error: unexpected requesting
Falling back to the default image...

Am I missing something or is there something I can test?

@coder-labeler coder-labeler bot added the bug Used to filter all bug issues label Mar 6, 2024
@wf1-brandon-grant wf1-brandon-grant closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2024
@kylecarbs
Copy link
Member

@wf1-brandon-grant did you figure this out?

@wf1-brandon-grant
Copy link
Author

@kylecarbs I realised that it would be more appropriate in the envbuilder repo, so I recreated the issue there.
Sorry for the noise

@kylecarbs
Copy link
Member

@wf1-brandon-grant not a problem at all -- just wanted to make sure you weren't blocked.

@wf1-brandon-grant
Copy link
Author

@kylecarbs thanks! Still running into the issue I'm afraid. But it seems related to the git clone implementation in envbuilder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to filter all bug issues
Projects
None yet
Development

No branches or pull requests

2 participants