-
Notifications
You must be signed in to change notification settings - Fork 982
Error when creating a deploy key with extras/0-cicd-github #1317
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
Comments
For the record, I removed the organization from the |
As you found out, repository names cannot contain the organization name which is passed via the dedicated variable. I'm closing this but feel free to reopen if our documentation is unclear and we can make a better job of explaining this point. |
Thanks for your answer @ludoo ! However, I'm sorry but I think I need to reopen this issue because the documentation explicitly states that I forked the organization = "myorg"
modules_config = {
repository_name = "myorg/cloud-foundation-fabric"
module_prefix = "modules/"
key_config = {
create_key = true
create_secrets = true
}
}
repositories = {
fast_00_bootstrap = {
create_options = {
description = "Bootstrap stage for FAST."
}
populate_from = "../../stages/0-bootstrap"
}
fast_01_resman = {
create_options = {
description = "Resource management stage for FAST."
}
populate_from = "../../stages/1-resman"
}
}
pull_request_config = {
create = true
title = "FAST: initial loading or update"
body = ""
base_ref = "main"
head_ref = "fast-loader"
} All ressources are created correctly, except the Then, if I don't include the organization in modules_config = {
repository_name = "cloud-foundation-fabric"
module_prefix = "modules/"
key_config = {
create_key = true
create_secrets = true
}
} all resources are created correctly, including the deploy key. However, the generated files all use When I try to
Then again, I may have misunderstood how to run this stage and I'm sorry for taking some of your time with this but I feel this needs some clarification. Best, |
I see your point, and sorry for making this harder than it should have been (I was also on vacation so lagging a bit). WDYT about removing the interpolated org from where |
Checking the code, we don't interpolate the org in the repo name used for key creation which is defined in this local modules_repo = try(var.modules_config.repository_name, null) and then reused directly in the resource resource "github_repository_deploy_key" "default" {
count = (
try(var.modules_config.key_config.create_key, null) == true ? 1 : 0
)
title = "Modules repository access"
repository = local.modules_repo What I think is happening is the GitHub provider injecting the configured owner in the API URL. So it appears that deploy key repos need to belong to the same org configured in the provider, which makes sense. I see two options
I would prefer the second option, as it would allow passing in a repo external to the org for substitutions (and then skip deploy key creation of course). I'll send a PR that implements it, let me know if this works for you. |
Thanks for the quick reply and sorry for bothering you on your vacation ! Your solution works perfectly well for me, thank you. I'll try it out during the day and get back to you if there is an issue. Cheers ! |
Hello,
I'm running into an error when creating the deploy key with the
0-cicd
extra stage, namely:My organization name
myorg
is included twice in the API call.Here is my
terraform.tfvars
file for this stage:As mentioned in the documentation, I'm writing the complete name of the repository in
modules_config.repository_name
. However, I think theorganization
is added a 2nd time because of thegithub
provider being declared asI looked at the source code of the Terraform Google provider and the repository name is taken from the
repository
field of thegithub_repository_deploy_key
resource - i.e.myorg/cloud-foundation-fabric
here - but the owner is taken, I assume, from what is declared in theprovider
- i.e.myorg
.Finally, in
CreateKey
, the URL is built using bothowner
andrepoName
which would explain why the organization name is duplicated:Please let me know if I'm mistaken. Otherwise, I think this could be solved by requiring only the repository name (without the organization) in the
modules_config
and updating thegithub_repository_file
resource to also takevar.organization
when replacing thesource
path.I can submit a PR for this if this solution works for you.
The text was updated successfully, but these errors were encountered: