coder / coder/internal

Git Flow: terraform-provider-coder: create new `coder_git_repo` data source

オープン
#404 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
m
主要言語
言語のデータがありません
スター
3
フォーク
0
PR マージ指標
30日以内にマージされた PR はありません

説明

Create a new `coder_git_repo` Coder data source to support the following use-cases:

1. Pre-defined Git repo with hard-coded branch:
```
data "coder_git_repo" "repo" {
provider = "my-github"
url = "git@github.com:coder/coder.git"
}

module "git-clone" {
url = data.coder_git_repo.repo.url
branch_name = "main"
git_providers = {
"git@github.com": "my-github"
}
}
```

2. Pre-defined Git repo with configurable branch:

```
data "coder_git_repo" "repo" {
provider = "my-github"
url = "git@github.com:coder/coder.git"
}

data "coder_parameter" "git_branch" {
type = "string"
default = data.coder_git_repo.repo.default_branch
}

module "git-clone" {
url = data.coder_git_repo.repo.url
branch_name = data.coder_parameter.git_branch.value
git_providers = {
"git@github.com": "my-github"
}
}
```

2. Configurable Git repo with configurable branch:

```
data "coder_parameter" "git_repo" {
type = "string"
default = "git@github.com:coder/coder.git"
}

data "coder_git_repo" "repo" {
provider = "my-github"
url = data.coder_parameter.git_repo.value
}

data "coder_parameter" "git_branch" {
type = "string"
default = data.coder_git_repo.repo.default_branch
}

module "git-clone" {
url = data.coder_git_repo.repo.url
branch_name = data.coder_parameter.git_branch.value
git_providers = {
"git@github.com": "my-github"
}
}
```

Implementation Notes:
* `coderd` will be responsible for querying the remote repository and setting the required data in the data source based on user inputs. We need to be using the existing user's oauth2 tokens to authenticate with the Git provider. Doing this in the provider means that typographical errors or issues cloning the repo will only be discovered at plan/apply time, and not while the user is still filling out the form.
* If possible, we should only allow one `coder_git_repo` data source per template.
* If possible, we should ensure that all `coder_parameter` references to this data source are immutable. Rationale: if a user later changes the git repo linked to their workspace, the expected behaviour is not clear.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず、既存のterraform-provider-coderのdata sourceパターンと、実装ノートに記載されているcoderdの責務を確認します。3つの例について、data sourceのURL、provider、default_branchの動作を定義し、そのうえでOAuthに基づくリポジトリ検索、単一data sourceの制限、イミュータブルなパラメータ参照が、記載されたユースケースを満たしていることを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
terraform
領域
infrastructure
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。