Skip to content

Commit

Permalink
Merge pull request #56 from mineiros-io/mariux/tf14
Browse files Browse the repository at this point in the history
feat: Add support for terraform v0.14.x
  • Loading branch information
mariux committed Dec 24, 2020
2 parents 18a704b + 4f435f4 commit 0b86db8
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 169 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.6.0]

### Added

- Add support for Terraform v0.14.x

## [0.5.1]

### Fixed
Expand Down Expand Up @@ -177,11 +183,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- markdown-link-check-disable -->

[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.5.1...HEAD
[0.5.1]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.5.0...v0.5.1
[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.6.0...HEAD
[0.6.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.5.1...v0.6.0

<!-- markdown-link-check-enable -->

[0.5.1]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.4.2...v0.5.0
[0.4.2]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.4.1...v0.4.2
[0.4.1]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.4.0...v0.4.1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Set default shell to bash
SHELL := /bin/bash -o pipefail

BUILD_TOOLS_VERSION ?= v0.6.1
BUILD_TOOLS_VERSION ?= v0.7.0
BUILD_TOOLS_DOCKER_REPO ?= mineiros/build-tools
BUILD_TOOLS_DOCKER_IMAGE ?= ${BUILD_TOOLS_DOCKER_REPO}:${BUILD_TOOLS_VERSION}

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

A [Terraform] module for creating a public or private repository on [Github].

**_This module supports Terraform v0.13 as well as v0.12.9 and above
and is compatible with the Terraform Github Provider v3 as well as v2.6 and above._**
*This module supports Terraform v0.14, v0.13 as well as v0.12.9 and above
and is compatible with the Terraform Github Provider v3 as well as v2.6 and above.*

- [Module Features](#module-features)
- [Getting Started](#getting-started)
Expand Down Expand Up @@ -86,7 +86,7 @@ Most basic usage creating a new private github repository.
```hcl
module "repository" {
source = "mineiros-io/repository/github"
version = "~> 0.5.0"
version = "~> 0.6.0"
name = "terraform-github-repository"
license_template = "apache-2.0"
Expand Down Expand Up @@ -720,7 +720,7 @@ Copyright &copy; 2020 [Mineiros GmbH][homepage]
[badge-build]: https://github.com/mineiros-io/terraform-github-repository/workflows/CI/CD%20Pipeline/badge.svg
[badge-semver]: https://img.shields.io/github/v/tag/mineiros-io/terraform-github-repository.svg?label=latest&sort=semver
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.13%20and%200.12.9+-623CE4.svg?logo=terraform
[badge-terraform]: https://img.shields.io/badge/terraform-0.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack
[badge-tf-gh]: https://img.shields.io/badge/GH-3%20and%202.6+-F8991D.svg?logo=terraform
[releases-github-provider]: https://github.com/terraform-providers/terraform-provider-github/releases
Expand Down
2 changes: 1 addition & 1 deletion examples/public-repository/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ branch protection.
```hcl
module "repository" {
source = "mineiros-io/repository/github"
version = "~> 0.5.0"
version = "~> 0.6.0"
module_depends_on = [
github_team.team
Expand Down
2 changes: 1 addition & 1 deletion examples/public-repository/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

module "repository" {
source = "mineiros-io/repository/github"
version = "~> 0.5.0"
version = "~> 0.6.0"

module_depends_on = [
github_team.team
Expand Down
53 changes: 0 additions & 53 deletions test/public_repository_complete_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,12 @@ import (
"testing"

"github.com/gruntwork-io/terratest/modules/random"

"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/require"
)

func TestGithubPublicRepositoryCompleteExample(t *testing.T) {
t.Parallel()

const OutputTeamName = "team_name"
const OutputRepositoryDefaults = "repository_defaults"
const OutputRepositoryName = "repository_name"
const OutputRepositoryWithDefaultsName = "repository_with_defaults_name"

githubOrganization := checkIfEnvironmentVariablesAreSet()

// Set the names for the repositories this test should create
expectedRepositoryNameA := fmt.Sprintf("test-public-repository-complete-example-A-%s", random.UniqueId())
expectedRepositoryNameB := fmt.Sprintf("test-public-repository-complete-example-B-%s", random.UniqueId())
Expand Down Expand Up @@ -75,48 +66,4 @@ func TestGithubPublicRepositoryCompleteExample(t *testing.T) {

// This will run `terraform init` and `terraform apply` and fail the test if there are any errors
terraform.InitAndApply(t, terraformOptions)

// Retrieve all outputs from Terraform
out := terraform.OutputAll(t, terraformOptions)

// Validate that the name of the created team matches the one we defined as a variable
teamName, ok := out[OutputTeamName].(string)
require.True(t, ok, fmt.Sprintf(
"Wrong data type for '%s', expected string, got %T",
OutputTeamName,
out[OutputTeamName]))

require.Equal(t, expectedTeamName, teamName, "String %q should match %q",
expectedTeamName, teamName)

// Validate that the type of the outputs for the defaults is correct
repositoryDefaults, ok := out[OutputRepositoryDefaults].(map[string]interface{})
require.True(t, ok, fmt.Sprintf(
"Wrong data type for '%s', expected map[string], got %T",
OutputRepositoryDefaults,
out[OutputRepositoryDefaults]))

// Validate that the returned map of repository defaults
require.Equal(t, expectedRepositoryDefaults, repositoryDefaults, "Map item %q should match %q",
expectedRepositoryDefaults, repositoryDefaults)

// Validate that the names of the created repositories match the ones we passed as variables
repositoryNameA, ok := out[OutputRepositoryName].(string)
require.True(t, ok, fmt.Sprintf("Wrong data type for '%s', expected string, got %T",
OutputRepositoryName,
out[OutputRepositoryName]))

expectedFullRepositoryNameA := fmt.Sprintf("%s/%s", githubOrganization, expectedRepositoryNameA)
require.Equal(t, expectedFullRepositoryNameA, repositoryNameA, "String %q should match %q",
expectedFullRepositoryNameA, repositoryNameA)

repositoryNameB, ok := out[OutputRepositoryWithDefaultsName].(string)
require.True(t, ok, fmt.Sprintf(
"Wrong data type for '%s', expected string, got %T",
OutputRepositoryWithDefaultsName,
out[OutputRepositoryWithDefaultsName]))

expectedFullRepositoryNameB := fmt.Sprintf("%s/%s", githubOrganization, expectedRepositoryNameB)
require.Equal(t, expectedFullRepositoryNameB, repositoryNameB, "String %q should match %q",
expectedFullRepositoryNameB, repositoryNameB)
}
34 changes: 0 additions & 34 deletions test/public_repository_with_collaborators_test.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
package test

import (
"crypto/tls"
"fmt"
"testing"
"time"

http_helper "github.com/gruntwork-io/terratest/modules/http-helper"

"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/require"

"github.com/gruntwork-io/terratest/modules/terraform"
)

func TestGithubPublicRepositoryWithCollaborators(t *testing.T) {
t.Parallel()

const OutputRepositoryName = "repository_name"
const OutputRepositoryURL = "repository_url"

GithubOrganization := checkIfEnvironmentVariablesAreSet()

expectedRepositoryName := fmt.Sprintf("test-public-repository-with-collaborators-%s", random.UniqueId())

terraformOptions := &terraform.Options{
Expand All @@ -38,27 +27,4 @@ func TestGithubPublicRepositoryWithCollaborators(t *testing.T) {

// This will run `terraform init` and `terraform apply` and fail the test if there are any errors
terraform.InitAndApply(t, terraformOptions)

repositoryName := terraform.OutputRequired(t, terraformOptions, OutputRepositoryName)
require.Equal(t, fmt.Sprintf("%s/%s", GithubOrganization, expectedRepositoryName),
repositoryName, "Name of repository %q should match %q",
fmt.Sprintf("%s/%s", GithubOrganization, expectedRepositoryName), repositoryName)

// Retrieve the repository URL from the outputs
repositoryURL := terraform.OutputRequired(t, terraformOptions, OutputRepositoryURL)

// Check if the created repository is available through HTTP
status := 200
retries := 15
sleep := 5 * time.Second
tlsConfig := tls.Config{}
http_helper.HttpGetWithRetryWithCustomValidation(
t,
repositoryURL,
&tlsConfig,
retries,
sleep,
func(statusCode int, body string) bool {
return statusCode == status
})
}
54 changes: 0 additions & 54 deletions test/public_repository_with_webhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,12 @@ import (
"testing"

"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/require"

"github.com/gruntwork-io/terratest/modules/terraform"
)

func TestGithubPublicRepositoryWithWebhook(t *testing.T) {
t.Parallel()

const OutputRepositoryName = "repository_name"
// const OutputRepositoryURL = "repository_url"
const OutputWebhookContentType = "webhook_content_type"
const OutputWebhookInsecureSsl = "webhook_insecure_ssl"
const OutputWebhookSecret = "webhook_secret"
const OutputWebhookActive = "webhook_active"
const OutputWebhookEvents = "webhook_events"
const OutputWebhookURL = "webhook_url"

GithubOrganization := checkIfEnvironmentVariablesAreSet()

// Set the name for the repository this test should create
expectedRepositoryName := fmt.Sprintf("test-public-repository-with-webhook-%s", random.UniqueId())

Expand Down Expand Up @@ -56,45 +43,4 @@ func TestGithubPublicRepositoryWithWebhook(t *testing.T) {
// This will run `terraform init` and `terraform apply` and fail the test if there are any errors
terraform.InitAndApply(t, terraformOptions)

// Validate the name of the created repository matches the on we passed in as a variable
repositoryName := terraform.OutputRequired(t, terraformOptions, OutputRepositoryName)
require.Equal(t, fmt.Sprintf("%s/%s", GithubOrganization, expectedRepositoryName),
repositoryName, "Name of repository %q should match %q",
fmt.Sprintf("%s/%s", GithubOrganization, expectedRepositoryName), repositoryName)

// Validate the content-type of the created webhook matches the on we passed in as a variable
webhookContentType := terraform.OutputRequired(t, terraformOptions, OutputWebhookContentType)
require.Equal(t, expectedWebhookContentType,
webhookContentType, "Webhook content-type %q should match %q",
expectedWebhookContentType, webhookContentType)

// Validate the insecure SSL setting of the created webhook matches the on we passed in as a variable
webhookInsecureSsl := terraform.OutputRequired(t, terraformOptions, OutputWebhookInsecureSsl)
require.Equal(t, expectedWebhookInsecureSsl,
webhookInsecureSsl, "Webhook insecure SSL setting %q should match %q",
expectedWebhookInsecureSsl, webhookInsecureSsl)

// Validate the secret of the created webhook matches the on we passed in as a variable
webhookSecret := terraform.OutputRequired(t, terraformOptions, OutputWebhookSecret)
require.Equal(t, expectedWebhookSecret,
webhookSecret, "Webhook secret %q should match %q",
expectedWebhookSecret, webhookSecret)

// Validate the active status of the created webhook matches the on we passed in as a variable
webhookActive := terraform.OutputRequired(t, terraformOptions, OutputWebhookActive)
require.Equal(t, expectedWebhookActive,
webhookActive, "Webhook active status %q should match %q",
expectedWebhookActive, webhookActive)

// Validate the events that trigger the created webhook matches the on we passed in as a variable
webhookEvents := terraform.OutputList(t, terraformOptions, OutputWebhookEvents)
require.ElementsMatch(t, expectedWebHookEvents,
webhookEvents, "Elements of webhook events %q should match elements of %q",
expectedWebHookEvents, webhookEvents)

// Validate the URL of the created webhook matches the on we passed in as a variable
webhookURL := terraform.OutputRequired(t, terraformOptions, OutputWebhookURL)
require.Equal(t, expectedWebhookURL,
webhookURL, "Webhook URL %q should match %q",
expectedWebhookURL, webhookURL)
}
18 changes: 0 additions & 18 deletions test/test_helpers.go

This file was deleted.

2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ---------------------------------------------------------------------------------------------------------------------

terraform {
required_version = ">= 0.12.20, < 0.14"
required_version = ">= 0.12.20, < 0.15"

required_providers {
github = ">= 2.6, < 4.0, != 3.1.0"
Expand Down

0 comments on commit 0b86db8

Please sign in to comment.