Coder Social home page Coder Social logo

integrations / terraform-provider-github Goto Github PK

View Code? Open in Web Editor NEW
848.0 45.0 697.0 36.6 MB

Terraform GitHub provider

Home Page: https://www.terraform.io/docs/providers/github/

License: MIT License

Makefile 0.15% Go 98.58% Shell 0.03% HTML 1.25%
github terraform terraform-provider hacktoberfest

terraform-provider-github's Introduction

Terraform Provider GitHub

This project is used to manipulate GitHub resources (repositories, teams, files, etc.) using Terraform. Its Terraform Registry page can be found here.

Requirements

  • Terraform 0.10.x
  • Go 1.19.x (to build the provider plugin)

Usage

Detailed documentation for the GitHub provider can be found here.

Contributing

Detailed documentation for contributing to the GitHub provider can be found here.

Roadmap

This project uses Milestones to scope upcoming features and bug fixes. Issues that receive the most recent discussion or the most reactions will be more likely to be included in an upcoming release.

Support

This is a community-supported project. GitHub's SDK team triages issues and PRs each Monday and Friday. Please engage with the community via Issues for support, and PRs are always welcome!

terraform-provider-github's People

Contributors

angie44 avatar appilon avatar benj-fletch avatar bpaquet avatar david-bain avatar dependabot[bot] avatar elliottpope avatar felixlut avatar galargh avatar grubernaut avatar jakebiesinger-onduo avatar jcudit avatar kfcampbell avatar ksatirli avatar megan07 avatar nickfloyd avatar nmishin avatar o-sama avatar octokitbot avatar patrickmarabeas avatar paultyng avatar radeksimko avatar raphink avatar renovate[bot] avatar ryndaniels avatar sethvargo avatar sotanakajima avatar stack72 avatar tombuildsstuff avatar tracypholmes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-github's Issues

creating github repository

This issue was originally opened by @artsiom-tsaryonau as hashicorp/terraform#17446. It was migrated here as a result of the provider split. The original body of the issue is below.


Hi!

I am trying to create a repository on github using terraform. My .tf file looks like this

variable "github_token" {}

provider "github" {
    #create account and get token
    token = "${var.github_token}"
}

resource "github_repository" "sample-terraform-app" {
    name = "sample-terraform-app"
    description = "Sample terraform app demo"
    
    auto_init = true # initial commit provision
}

I wanted to create a basic open repository. Terraform execution plan looks like this (I provided token)

The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + github_repository.sample-terraform-app
      id:                 <computed>
      allow_merge_commit: "true"
      allow_rebase_merge: "true"
      allow_squash_merge: "true"
      auto_init:          "true"
      default_branch:     <computed>
      description:        "Sample terraform app demo"
      full_name:          <computed>
      git_clone_url:      <computed>
      http_clone_url:     <computed>
      name:               "sample-terraform-app"
      ssh_clone_url:      <computed>
      svn_url:            <computed>


Plan: 1 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

But upon execution I get this error

Error: Error applying plan:

1 error(s) occurred:

* github_repository.sample-terraform-app: 1 error(s) occurred:

* github_repository.sample-terraform-app: POST https://api.github.com/user/repos: 404 Not Found []

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

What's the problem?

[DOCUMENTATION] Manage issue tags

It is quite common in open source projects to have a lot of repos and rely heavily on issue/pr labels. I would like to be able to manage the labels via terraform so that we could make this an easily managed process without having to look at specialized tools for this.

Here is the relevant api documentation I found which validated that is is possible: https://developer.github.com/v3/issues/labels/

[FEATURE REQUEST] Data resource for query all repositories in a Github ORG

It would be useful if there was a terraform data resource to query the github org - specifically get a list of all repositories from the Github Org (or maybe even a user).

example

# Get all repositories that are part of example org 
data "github_repos" "example" {
  slug = "example-org"
}

# Get all repositories that are part of example user 
data "github_repos" "example" {
  slug = "example-user"
}

Using the output from that data resource, we can then iterate over them for actions like

  • attaching teams to a repository
  • setting a standardized github_branch_protection setting on all repositories.

Support multiple organizations

Terraform Version

Terraform v0.11.3

  • provider.github v0.1.1

Affected Resource(s)

  • github_*

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Expected Behavior

It should be possible to manage the resources of multiple github organizations by declaring the organization a resource belongs to.

Actual Behavior

The github provider currently does not support (optionally) setting the github organization for a resource. Instead, it takes the organization either from the github provider config or from the environment.

Crash with empty github_branch_protections restrictions block

This issue was originally opened by @jonathanio as hashicorp/terraform#14093. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.9.4

Affected Resource(s)

  • github_branch_protection

Terraform Configuration Files

resource "github_branch_protection" "master" {
  repository = "${github_repository.repo.name}"
  branch = "master"

  required_pull_request_reviews {
    include_admins = true
  }

  restrictions {
    teams = [""]
  }
}

# Note: Also applies to the following restriction blocks too:

  restrictions {
    teams = []
  }

  restrictions {
  }

Debug Output

https://gist.github.com/jonathanio/90a5020e5cff1848400ed35a1df99513

Panic Output

https://gist.github.com/jonathanio/90a5020e5cff1848400ed35a1df99513

Expected Behaviour

It should either throw up a warning (invalid/missing values), or correctly process the data and create the appropriate settings in Github. Given that it is possible to enable the restrictions setting within Github without adding any teams or users, I would expect the empty array and empty block configurations to work, but the empty value within the array to fail as an invalid value (or otherwise be accepted, and allow Github to reject it).

Actual Behaviour

Terraform fails to apply and reports a crash.

Steps to Reproduce

  1. terraform apply

Important Factoids

None.

References

None.

github_organization_webhook: 404s on API call

Terraform Version

$ terraform -v
Terraform v0.11.0
+ provider.github v0.1.1

Affected Resource(s)

  • github_organization_webhook

Terraform Configuration Files

resource "github_organization_webhook" "release" {
  name = "web"

  configuration {
    url          = "https://hooks.slack.com/services/REDACTED"
    content_type = "json"
    insecure_ssl = false
  }

  active = true
  events = ["release"]
}

Debug Output

Full run of terraform apply: https://gist.github.com/mbbroberg/a358253e6a1042c6abbe0901a7f80976

Expected Behavior

Creation of a webhook

Actual Behavior

404 error: * github_organization_webhook.release: POST https://api.github.com/orgs/sensu-plugins/hooks: 404 Not Found []

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. configure webhook
  2. terraform plan
  3. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?
Nothing exciting. Oh maybe that it's a private repository, but I have admin rights on it.

Cheers and happy almost ๐Ÿฆƒ day ๐ŸŽ‰

github_repository_deploy_key forces new resource

I'm getting a "forces new resource" every time I run terraform plan or terraform apply regardless of whether the key already exists.

Terraform Version

Terraform v0.11.2
+ provider.aws v1.6.0
+ provider.github v0.1.1

Affected Resource(s)

  • github_repository_deploy_key

Terraform Configuration Files

variable "github_token" {}

provider "github" { 
  organization = "SomeOrg"
  token = "${var.github_token}"
}

resource "github_repository_deploy_key" "webapp_repo_deploy_key" {
    title = "Deploy key"
    repository = "SomeRepo"
    key = "redacted"
    read_only = "true"
}

Expected Behavior

Once the deploy key exists, don't recreate it.

Actual Behavior

Terraform recreates the resource:

-/+ github_repository_deploy_key.webapp_repo_deploy_key (new resource required)
      id:         "SomeRepo:26817612" => <computed> (forces new resource)
      key:        "redacted" (forces new resource)
      read_only:  "true" => "true"
      repository: "SomeRepo" => "SomeRepo"
      title:      "Deploy key" => "Deploy key"


### Steps to Reproduce
1. `terraform plan`  (`terraform apply` does recreate the resource)

github_repository_collaborator: fails when adding a user as a collaborator

Terraform Version

$ terraform -v
Terraform v0.10.8

Affected Resource(s)

  • github_repository_collaborator

Target provider is running GitHub Enterprise 2.11.2.

Terraform Configuration Files

resource "github_repository" "myrepo" {                       
  provider = "github.myprovider"                                             
  name     = "myrepo"                                         
  private  = true                                                                                                             
}                                                                               
                                                                                
resource "github_repository_collaborator" "myrepo_johnsmith" {                                                                               
  repository = "${github_repository.myrepo.name}"             
  username   = "johnsmith"                                                     
  permission = "push"                                                           
}

Expected Behavior

The user johnsmith should of been added as a collaborator to the myrepo repository.

Actual Behavior

terraform failed to refresh the state:

Error: Error refreshing state: 1 error(s) occurred:

* github_repository_collaborator.myrepo_johnsmith: github_repository_collaborator.myrepo_johnsmith: GET https://REDACTED/api/v3/repos/REDACTED/myrepo/invitations?per_page=100: 415 If you would like to help us test the Repository Invitations during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details. []


Nothing to change.

I also observed an import failing with a similar error. After adding the user as a collaborator manually through the GitHub Enterprise interface

$ terraform import github_repository_collaborator.myrepo-johnsmith myrepo:johnsmith 
github_repository_collaborator.myrepo-johnsmith: Importing from ID "myrepo:johnsmith"...
github_repository_collaborator.myrepo-johnsmith: Import complete!
  Imported github_repository_collaborator (ID: myrepo:johnsmith)
github_repository_collaborator.myrepo-johnsmith: Refreshing state... (ID: myrepo:johnsmith)
Error importing: 1 error(s) occurred:

* github_repository_collaborator.myrepo-johnsmith (import id: myrepo:johnsmith): 1 error(s) occurred:

* import github_repository_collaborator.myrepo-johnsmith result: myrepo:johnsmith: github_repository_collaborator.myrepo-johnsmith: GET https://REDACTED/api/v3/repos/REDACTED/myrepo/invitations?per_page=100: 415 If you would like to help us test the Repository Invitations during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details. []

References

Not sure if has anything to do with the issue, though it looks like GitHub changed the way collaborators are added.

https://github.com/blog/2170-repository-invitations
octokit/octokit.net#1410

[Bug] Terraform panics when fetching lists of team IDs using data.github_team

Allow setting default_branch on create.

It appears in the code that you can't set default_branch on create; a sad limitation of the create API on GitHub it would seem.

Is there any reason why resourceGithubRepositoryUpdate couldn't be called from resourceGithubRepositoryCreate only in the case that default_branch is set to something other than master?

Support renaming of repositories

Terraform Version

v0.9.6

Affected Resource(s)

  • github_repository

Description

If I need to rename a repository, then I would like to be able to change the name without forcing a new resource. Forcing a new resource results in the deletion of the existing repository, including all code, branches, etc.

Steps to reproduce

Changing:

resource "github_repository" "fruit" {
  name = "apples-and-oranges"
}

To:

resource "github_repository" "fruit" {
  name = "apples-and-pears"
}

Results in:

-/+ github_repository.fruit
...
      name:   "apples-and-oranges" => "apples-and-pears" (forces new resource)

github_team --> json: cannot unmarshal object into Go struct field Organization.blog of type string

Terraform Version

Terraform v0.10.2

Affected Resource(s)

Please list the resources as a list, for example:

  • github_team

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "github_team" "foo" {
  name = "foo"
  description = "The FOO team"
  privacy = "closed"
}

Expected Behavior

Github team Foo should be created and the plan should continue to be applied.

Actual Behavior

Github team Foo is created, but terraform apply throws error and stops:
github_team.foo json: cannot unmarshal object into Go struct field Organization.blog of type string

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

This is the first time I have tried to create a new Github team since upgrading to tf 0.10.x. I have created multiple teams with no issues on 0.9.x

resource/github_team_membership: memberships are sometimes not written.

Terraform Version

  • Terraform v0.10.7
  • Github 0.1.1

Affected Resource(s)

  • github_team_membership

Terraform Configuration Files

resource "github_team_membership" "memberships" {
  count    = "${length(var.members)}"
  team_id  = "${github_team.team.id}"
  username = "${element(keys(var.members), count.index)}"
  role     = "${lookup(var.members, element(keys(var.members), count.index))}"
}

variable "members" {
  type = "map"
  default = {
    "a" = "member" # This is a new member. It will become slot 0.
    "b" = "member" # Previous slot 0
    "c" = "member"
    "d" = "member"
    "e" = "member"
    "f" = "member"
    "g" = "member"
    "h" = "member" # Was slot 6, should become slot 7
    "i" = "member"
    "j" = "member"
    "k" = "member" # Was slot 9, should become slot 10
  }
}

Debug Output

I missed the chance to get debugging output. Sorry.

Expected Behavior

When member "a" was added, it should have pushed everyone down one slot. When done, the membership list should have all 10 members.

Actual Behavior

Everyone was pushed down, but slot 7 and 10 were not written. Afterwards, when I did terraform plan, it showed it would only add slots 7 ("h") and 10 ("k").

Steps to Reproduce

It isn't reliable, but adding and removing the first user eventually triggers this.

Important Factoids

I'm using GitHub Enterprise, which is why the users names aren't valid.

github_team_repository not persisted to state?

This issue was originally opened by @publysher as hashicorp/terraform#9149. It was migrated here as part of the provider split. The original body of the issue is below.


My github_team_repository resources do not show up in terraform show. Whenever I create a fresh plan, they are indicated as new.

Terraform Version

Terraform v0.7.4

Affected Resource(s)

  • github_team_repository

Terraform Configuration Files

resource "github_team" "frontend" {
  name    = "Frontend"
  privacy = "closed"
}

resource "github_team_repository" "frontend_frontend" {
  team_id    = "${github_team.frontend.id}"
  repository = "frontend"
  permission = "push"
}

Expected Behavior

The first time, terraform plan should show:

+ github_team.frontend
+ github_team_repository.frontend_frontend

After applying, terraform plan should indicate that everything is in sync.

After applying, terraform show | grep frontend_frontend should show the github_team_repository resource.

Actual Behavior

After applying, terraform plan shows:

+ github_team_repository.frontend_frontend

terraform apply will re-create the resource.

terraform show does not show the resource.

[NEW FEATURE] GitHub Provider Scaffold Repository Resource

This issue was originally opened by @pantocrator27 as hashicorp/terraform#11343. It was migrated here as part of the provider split. The original body of the issue is below.


Would it be possible for the GitHub provider to provide a resource or extend a current resource that would effectively enable you to scaffold a repository upon its creation ... ? I am thinking the scaffolding code may be sourced from another GitHub repository or maybe files local to the GitHub configuration?

Add support for "require review from code owners"

GitHub added the ability to require reviews from code owners in July. It doesn't look like support for this has made it into terraform-provider-github quite yet.

It seems like a simple update to the PullRequestReviewsEnforcement and PullRequestReviewsEnforcementRequest to handle this additional field.

Terraform Version

Terraform v0.10.7

Affected Resource(s)

github_branch_protection

Terraform Configuration Files

Ideally, this would be supported.

resource "github_branch_protection" "foo_master" {
  repository = "foo"
  branch = "master"

  required_pull_request_reviews {
    require_code_owner_reviews = true
  }
}

References

https://developer.github.com/v3/repos/branches/#get-pull-request-review-enforcement-of-protected-branch

Import of github_membership won't work - Terraform crashes

Terraform version: Terraform v0.10.6
Plugin version: 0.1.1

terraform import github_membership.org_membership_Nowaker Nowaker

Most relevant error:

import github_membership.org_membership_Nowaker result: Nowaker: github_membership.org_membership_Nowaker: unexpected EOF
panic: runtime error: index out of range

Full output:

nowaker@nwkr-desktop ..old/devops/team-resources/company-wide (git)-[feature/terraform-for-github] % terraform import github_membership.org_membership_Nowaker Nowaker
github_membership.org_membership_Nowaker: Importing from ID "Nowaker"...
github_membership.org_membership_Nowaker: Import complete!
  Imported github_membership (ID: Nowaker)
github_membership.org_membership_Nowaker: Refreshing state... (ID: Nowaker)
Error importing: 1 error(s) occurred:

* github_membership.org_membership_Nowaker (import id: Nowaker): 1 error(s) occurred:

* import github_membership.org_membership_Nowaker result: Nowaker: github_membership.org_membership_Nowaker: unexpected EOF
panic: runtime error: index out of range
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: 
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: goroutine 34 [running]:
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: github.com/terraform-providers/terraform-provider-github/github.parseTwoPartID(0xc42028a524, 0x7, 0x0, 0x0, 0xc420282958, 0x9b7338)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-github/github/util.go:46 +0x9e
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: github.com/terraform-providers/terraform-provider-github/github.resourceGithubMembershipRead(0xc4202943f0, 0xa323a0, 0xc420270a20, 0x0, 0xf89b20)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-github/github/resource_github_membership.go:55 +0x81
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: github.com/terraform-providers/terraform-provider-github/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc42001aea0, 0xc420298370, 0xa323a0, 0xc420270a20, 0xc420202bf8, 0xc42027a901, 0x0)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-github/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:314 +0x21d
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: github.com/terraform-providers/terraform-provider-github/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Refresh(0xc420058a10, 0xc420298320, 0xc420298370, 0x7f86cf5dd2c0, 0x0, 0x0)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-github/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:267 +0x91
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: github.com/terraform-providers/terraform-provider-github/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Refresh(0xc4200d9f40, 0xc42028a370, 0xc42028a5b0, 0x0, 0x0)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-github/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:510 +0x4e
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: reflect.Value.call(0xc42011f560, 0xc4201161c8, 0x13, 0xb6b3a3, 0x4, 0xc420282f20, 0x3, 0x3, 0x437f0c, 0xc420035738, ...)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /usr/local/go/src/reflect/value.go:434 +0x91f
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: reflect.Value.Call(0xc42011f560, 0xc4201161c8, 0x13, 0xc420035720, 0x3, 0x3, 0x0, 0x180000, 0x0)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /usr/local/go/src/reflect/value.go:302 +0xa4
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: net/rpc.(*service).call(0xc420111a80, 0xc420111a40, 0xc42010de40, 0xc420119900, 0xc420270460, 0xa353e0, 0xc42028a370, 0x16, 0xa35420, 0xc42028a5b0, ...)
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /usr/local/go/src/net/rpc/server.go:387 +0x144
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4: created by net/rpc.(*Server).ServeCodec
2017-09-26T13:04:52.448-0500 [DEBUG] plugin.terraform-provider-github_v0.1.1_x4:        /usr/local/go/src/net/rpc/server.go:481 +0x404
2017/09/26 13:04:52 [ERROR] root: eval: *terraform.EvalRefresh, err: github_membership.org_membership_Nowaker: unexpected EOF
2017/09/26 13:04:52 [ERROR] root: eval: *terraform.EvalSequence, err: github_membership.org_membership_Nowaker: unexpected EOF
2017/09/26 13:04:52 [TRACE] [walkImport] Exiting eval tree: import github_membership.org_membership_Nowaker result: Nowaker
2017-09-26T13:04:52.448-0500 [DEBUG] plugin: plugin process exited: path=/home/nowaker/projekty/tenfold/devops/team-resources/company-wide/.terraform/plugins/linux_amd64/terraform-provider-github_v0.1.1_x4
2017/09/26 13:04:52 [TRACE] dag/walk: upstream errored, not walking "provider.github (close)"
2017/09/26 13:04:52 [TRACE] dag/walk: upstream errored, not walking "root"
2017/09/26 13:04:52 [DEBUG] plugin: waiting for all plugin processes to complete...
2017-09-26T13:04:52.449-0500 [WARN ] plugin: error closing client during Kill: err="connection is shut down"
2017-09-26T13:04:52.449-0500 [DEBUG] plugin: plugin process exited: path=/home/nowaker/projekty/tenfold/devops/team-resources/company-wide/.terraform/plugins/linux_amd64/terraform-provider-external_v1.0.0_x4



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

API error when using github_team data resource causes hard error.

Terraform Version

0.9.11

Affected Resource(s)

The github_team data resource.

Terraform Configuration Files

variable "GITHUB_TOKEN" {}

provider "github" {
  token        = "${var.GITHUB_TOKEN}"
  organization = "krux"
}

data "github_team" "ci" {
  slug = "ci"
}

output "name" {
  value = "${data.github_team.ci.name}"
}

Panic Output

https://gist.github.com/joestump/540e3ce37156715f0e08f38419c3c4c5

Expected Behavior

It should pull in the team's info.

Actual Behavior

TF crashes.

Steps to Reproduce

I haven't been able to 100% nail this down other than it works for teams when I'm an owner of an organization, but doesn't for another organization that I'm just a member of.

However...

When I use the same token GITHUB_TOKEN I pass to Terraform via curl it works:

# Returns a 200 and a list of teams. Identical request above in TF fails.
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/orgs/krux/teams

Important Factoids

I think what's happening is that the API call to list teams is failing for an unknown reason and then TF fails hard when it hits this line:

https://github.com/terraform-providers/terraform-provider-github/blob/master/github/data_source_github_team.go#L84

I don't believe team is defined there? It should probably be return nil, err? (Sorry, I'm not great at Go, so ignore if it's a red herring.)

Support personal repositories not only GitHub organization

Terraform Version

v0.9.5

Affected Resource(s)

  • github_repository

Terraform Configuration Files

provider "github" {
  token        = "${var.github_token}"
}

resource "github_repository" "otus-devops-terraform" {
  name        = "otus-devops-terraform"
  description = "Repository for public terraform code using in Otus DevOps course"
}

resource "github_repository" "practice-git-1" {
  name        = "practice-git-1"
  description = "Repository for practicing Git in Otus DevOps course"
}

resource "github_repository" "practice-git-2" {
  name        = "practice-git-2"
  has_issues  = true
  description = "Repository for practicing Git in Otus DevOps course"
}

Debug Output

terraform.tfstate

{
    "version": 3,
    "terraform_version": "0.9.5",
    "serial": 2,
    "lineage": "753781c3-ade7-4b8d-9723-2f7f9bbdb08b",
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {},
            "depends_on": []
        }
    ]
}

Expected Behavior

It should create repository under personal account and write state in terraform.tfstate

Actual Behavior

terraform asks Github oraganization when running with terraform apply. Also it returns 422 when running twice. So it isn't idempotent.

Steps to Reproduce

terraform apply

github_repository does not have attribute http_clone_url error

I want to create repository and initialize git locally after successful creation. Accoding to the doc providers/github there is the attribute http_clone_url. So my .tf file looks like this.

variable "github_token" {}

provider "github" {
    token = "${var.github_token}"
    organization = ""
}

resource "github_repository" "sandbox" {
    name = "sandbox-application"
    description = "sandbox application for testing functionality"
    
    auto_init = true
}

# move to github_repository provisioner if possible
resource "null_resource" "init_local" {
    depends_on = ["github_repository.sandbox"]
    
    provisioner "local-exec" {
        command = "git init && git remote add origin ${github_repository.sandbox.http_clone_url}"
    }
}

But when I run apply I get the error

* null_resource.init_local: 1 error(s) occurred:

* Resource 'github_repository.sandbox' does not have attribute 'http_clone_url' for variable 'github_repository.sandbox.
http_clone_url'

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

So it seems this attribute does not exist? Or I am doing something wrong?

Add GPG and SSH key to GitHub user data source and members to GitHub team data source

Add GPG and SSH key to GitHub user data source and members to GitHub team data source:

data "github_user" "mootpt" {
  username = "mootpt"
}

data "github_team" "foo" {
  slug = "foo"
}

output "mootpt-gpg" {
  value = "${data.github_user.mootpt.gpg_keys}"
}

output "mootpt-ssh" {
  value = "${data.github_user.mootpt.ssh_keys}"
}

output "foo-members" {
  value = "${data.github_team.foo.members}"
}

Added in https://github.com/terraform-providers/terraform-provider-github/pull/2

[Enhancement] github_team should provide Id

I would like to suggest that the GitHub_team data source should provide the id of the team in addition to the currently provided attributes. This would help remove the need to lookup the ID when using teams with other attributes.

support archived repositories

Terraform Version

Terraform v0.11.0

Affected Resource(s)

Please list the resources as a list, for example:

  • github_repository

Terraform Configuration Files

i.e.:

resource "github_repository" "project.beta" {
  name        = "project.beta"
  description = "outdated project - see product.v1"

  archived    = True
}

screen shot 2018-02-12 at 11 27 52 am

github_user data source causing TF panic

Terraform Version

0.9.10

Affected Resource(s)

  • data source github_user

Terraform Configuration Files

provider "github" {}

data "github_user" "snigl" {
  username = "snigl"
}

Panic Output

https://gist.github.com/sclausson/1dda72f7ab4ce4109f5ccd8a9d241c0d

Expected Behavior

Should return github_user data source info.

Actual Behavior

Crash!!!

[DEBUG] plugin: terraform: panic: runtime error: invalid memory address or nil pointer dereference

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

Important Factoids

The crash consistently occurs for some GitHub users: snigl, daseg, betajobot, and tomascarlqvist to name a few examples.

The data source consistently works as expected for other GitHub users: sclausson, antonbabenko, raphink to name a few examples.

So, this works fine

provider "github" {}

data "github_user" "antonbabenko" {
  username = "antonbabenko"
}

And this crashes

provider "github" {}

data "github_user" "daseg" {
  username = "daseg"
}

[NEW FEATURE] Allow forking other github repositories to init new repositories.

It is really typical for companies to use git repositories as project templates which are then forked into client projects. It would be very cool if terraform could initiate a fork from selected github repository.

Terraform Version

Terraform v0.9.11

Affected Resource(s)

  • github_repository

Terraform Configuration Files

This is just an example that I would want to see:

resource "github_repository" "client-project" {
  name        = "client-project"
  description = "My client project from template"
  
  # The fork directive could look something like this:
  fork_from_repository = "onnimonni/project-template"
}

References

This has some similarities from #7 but just initiating a new repo by forking it from another repo would be enough for me.

Plan output keeps changing randomly

Terraform Version

Terraform v0.10.7

Affected Resource(s)

  • github_team_repository

Terraform Configuration Files

The basic structure is a module that defines a team and the repos that team can access:

resource "github_team" "team" {
  name = "${var.team_name}"
}

resource "github_team_repository" "repos" {
  count      = "${length(var.team_repo_names)}"
  team_id    = "${github_team.team.id}"
  repository = "${element(var.team_repo_names, count.index)}"
  permission = "pull"
}

We use this module to manage ~40 teams, each with access to 10 - 50 repos.

Expected Behavior

Since all of the code has already been applied, I expect to see "no changes" when I run terraform plan.

Actual Behavior

Every time I run terraform plan, I get a completely different output. Sometimes it says it wants to create team foo and give it access to a bunch of repos, sometimes team bar, sometimes several teams, sometimes "no changes", etc.

Steps to Reproduce

  1. terraform apply
  2. terraform plan

Important Factoids

My best guess is that Terraform is making one API call for every (team, repo) pair, this results in way too many API calls, getting throttled, and Terraform is hiding the error message.

References

  • Perhaps #5?

Feature: GitHub Merge Types

This issue was originally opened by @taiidani as hashicorp/terraform#15183. It was migrated here as part of the provider split. The original body of the issue is below.


Version 0.9.6

Adding a feature request to add merge types to the resource_github_repository.

image

I plan to take a stab at this myself with a pull request but I welcome anyone else!

required_pull_request_reviews in github_branch_protection isn't applying

Hi there,

Terraform Version

0.9.11 (Last time I knew this worked was 0.9.5, but we upgraded and it started having this issue)

Affected Resource(s)

  • github_branch_protection

We are seeing a similar output with the vcd_vapp.ip, but I'm not sure that its the same issue. We aren't seeing it with any other resources.

Terraform Configuration Files

resource "github_branch_protection" "myrepo_master" {
    repository = "${github_repository.myrepo.name}"
    branch = "master"
    required_status_checks {
        include_admins = true
        strict = true
        contexts = []
    }
    required_pull_request_reviews {
        include_admins = true
    }

}

Debug Output

https://gist.github.com/gregswift/5a934aa4a638701ec1a73123b84fb788 (encrypted with hashicorp gpg key)

Panic Output

No panic

Expected Behavior

The configuration should be set in GitHub to require reviews and include admins.

Actual Behavior

The setting isn't taking so every time we run terraform apply it wants to re-apply the setting.

github_branch_protection.deployment-control_master: Modifying... (ID: myrepo:master)
  required_pull_request_reviews.#:                "0" => "1"
  required_pull_request_reviews.0.include_admins: "" => "true"

Steps to Reproduce

  1. Create github_branch_protection that matches the one above
  2. terraform apply

Important Factoids

This is against GitHub:Enterprise 2.8. The vcd_vapp thing I was talking about above is that we have it set to 'allocated', which is a thing in the documetnation that has worked for a while for us, but now it keeps storing the IP in the state and wanting to change it back to 'allocated' every run. This doesnt actually change anything as far as we can tell, whichs i why it appears simiar, in that it keeps wanting to apply the change. but here it isnt applying the change. With vcd_vapp it seems more of a statefile handling issue.

References

terraform-providers/terraform-provider-vcd#29 for that issue

resource/github_membership: do not remove self as org admin

Terraform Version

Terraform v0.11.2
+ provider.github v0.1.1

Affected Resource(s)

Please list the resources as a list, for example:

  • github_membership

Terraform Configuration Files

I migrated from

variable github_token {
  default = "token"
}

provider "github" {
  organization = "my-org"
  token        = "${var.github_token}"
}

resource "github_membership" "caarlos0" {
  username = "caarlos0"
  role     = "admin"
}

resource "github_membership" "otherusers" {
  username = "otherusers"
  role     = "admin"
}

to

variable github_token {
  default = "token"
}

variable admins {
  default = ["caarlos0", "otherusers"]
}

provider "github" {
  organization = "my-org"
  token        = "${var.github_token}"
}

resource "github_membership" "admins" {
  count      = "${length(var.admins)}"
  username = "${element(var.admins, count.index)}"
  role     = "admin"
}

Debug Output

do not have

Panic Output

Expected Behavior

Should not have removed myself.

Actual Behavior

Removed myself and tried to add again.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

References

Terraform Crashes when using github_user or github_team data source where attributes are missing

Terraform Crashes when using github_user data source where attributes are missing

Terraform Version

Terraform v0.10.0-dev (d587b6886360332df99b65e834e369e06889ee33)

Affected Resource(s)

  • github_user
  • github_team

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

provider "github" {
  token        = "03423423423423exampletoken"
  organization = "testorg"
  base_url     = "https://github.company.com/api/v3/"
}

data "github_user" "testuser" {
  username = "testuser"
}

Debug Output

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Panic Output

https://gist.github.com/mootpt/b0d5233fbf2c3985ac09fac20f75bc90

Expected Behavior

Should load user and team data source

Actual Behavior

fails to load user and/or team data source when attributes are missing

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

this is fixed in https://github.com/terraform-providers/terraform-provider-github/pull/2

[FEATURE REQUEST] Add Support for Repository Projects

GitHub has an option for managing projects in a repository:

Project boards on GitHub help you organize and prioritize your work. You can create project boards for specific feature work, comprehensive roadmaps, or even release checklists.

It would be nice to add support for this

resource/github_repository: Renaming forces new resource

Terraform Version

v0.10.2

Affected Resource(s)

github_repository

Terraform Configuration Files

resource "github_repository" "example" {
  name = "example-rename" # Change this
}

Expected Behavior

The repository should have been renamed without triggering the "forces new resource" behavior.

Actual Behavior

The plan shows the repository as requiring recreation.

Output

-/+ github_repository.example (new resource required)
      full_name:          "Example/example-rename" => "<computed>"
      git_clone_url:      "git://github.com/Example/example-rename.git" => "<computed>"
      http_clone_url:     "https://github.com/Example/example-rename.git" => "<computed>"
      name:               "example-rename" => "example" (forces new resource)

GitHub team membership fails to add administrator as team maintainer

This issue was originally opened by @davidalger as hashicorp/terraform#14323. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

v0.9.4

Affected Resource(s)

  • github_team_membership

Terraform Configuration Files

resource "github_team" "bug1" {
  name        = "Bug Test"
  privacy     = "closed"
}

resource "github_team_membership" "bug1-davidalger" {
  team_id  = "${github_team.bug1.id}"
  username = "davidalger"
  role     = "maintainer"
}

Expected Behavior

The team is created and the user assigned successfully per the following plan output:

+ github_team.bug1
    name:    "Bug Test"
    privacy: "closed"

+ github_team_membership.bug1-davidalger
    role:     "maintainer"
    team_id:  "${github_team.bug1.id}"
    username: "davidalger"

Actual Behavior

The following error message is output when running the plan:

Error applying plan:

1 error(s) occurred:

* github_team_membership.bug1-davidalger: 1 error(s) occurred:

* github_team_membership.bug1-davidalger: PUT https://api.github.com/teams/2355584/memberships/davidalger: 422 User is already an admin of this organization, so they can't be promoted to a team maintainer. [{Resource:TeamMember Field:user Code:already_org_admin Message:}]

Steps to Reproduce

  1. terraform apply

Important Factoids

  • The user 'davidalger' in the example above is an administrator of the GitHub organization
  • Commenting out role input on github_team_membership.bug1-davidalger allows the plan to apply successfully, but running plan immediately following then shows an imminent change:
-/+ github_team_membership.bug1-davidalger
    role:     "maintainer" => "member" (forces new resource)
    team_id:  "2355584" => "2355584"
    username: "davidalger" => "davidalger"

github_repository: unsafe when repository is renamed

Terraform Version

Terraform v0.10.8

Affected Resource(s)

  • github_repository

Terraform Configuration Files

resource "github_repository" "repo" {
  name               = "tf-repo-bug1"
  description        = "Testing for a bug in Terraform"
  private            = false
  has_issues         = false
  has_wiki           = false
  auto_init          = true
  allow_merge_commit = true
  allow_squash_merge = false
  allow_rebase_merge = false
}

Explanation of bug

If you run terraform apply (which creates a repository tf-repo-bug1) and then rename the repository to tf-repo-bug2 then terraform gets very confused.

The tfstate changes the stored full_name and the various clone URLs, but doesn't understand that the repository actually change its name which is being used as the id in the terraform file.

This is problematic because:

  1. It doesn't set the name of the repository back to what is expected.
  2. If another repository is created with the original name (tf-repo-bug2) then this magic "redirect" doesn't work anymore and terraform will delete the new repository.

The only solution I can see is to use GitHub's concept of an id (a number) instead of the name of the repository.

Fixing this will probably fix #55 as well.

Error applying branch protection

Terraform Version

0.9.8

Affected Resource(s)

github_branch_protection

Terraform Configuration Files

# Here is where the main parts of the module go, including resource definitions
resource "github_repository" "repo" {
  name = "${var.name}"
  description = "${var.description}"
  private = "${var.private}"
  has_issues = false
  has_wiki = false
  has_downloads = false
  auto_init = true
}
resource "github_branch_protection" "repo_master" {
  repository = "${github_repository.repo.name}"
  branch = "master"
  required_status_checks {
    include_admins = "${var.restrict_admins}"
    strict = true
  }
  required_pull_request_reviews {
    include_admins = "${var.restrict_admins}"
  }
}

resource "github_team_repository" "members" {
  count = "${length(var.members)}"
  team_id = "${element(var.members, count.index)}"
  role = "push"
}

resource "github_team_repository" "admins" {
  count = "${length(var.admins)}"
  team_id = "${element(var.admins, count.index)}"
  role = "admin"
}

Debug Output

https://gist.github.com/DWSR/c9a1a1c6eb4132b9d667764f01944fef#file-terraform-log

Panic Output

N/A

Expected Behavior

Terraform should apply a branch protection to the master branch

Actual Behavior

https://gist.github.com/DWSR/c9a1a1c6eb4132b9d667764f01944fef#file-error-txt

Steps to Reproduce

terraform apply

References

The request body doesn't seem to line up with the required contents, per https://developer.github.com/v3/repos/branches/#update-branch-protection

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.