Skip to content

Commit

Permalink
fix conflicts from 0.41.6
Browse files Browse the repository at this point in the history
  • Loading branch information
edo-aleix-penella committed Dec 13, 2022
2 parents 6ce07de + 5d6baeb commit 29d7d80
Show file tree
Hide file tree
Showing 40 changed files with 568 additions and 101 deletions.
17 changes: 2 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ env: &env
PACKER_VERSION: 1.7.4
TERRAGRUNT_VERSION: v0.36.0
OPA_VERSION: v0.33.1
GO_VERSION: 1.17
GO_VERSION: 1.18
GO111MODULE: auto
K8S_VERSION: v1.18.20 # Same as EKS
MINIKUBE_VERSION: v1.22.0
HELM_VERSION: v3.8.0
KUBECONFIG: /home/circleci/.kube/config
BIN_BUILD_PARALLELISM: 3
DOCKER_COMPOSE_VERSION: v2.5.0

defaults: &defaults
machine:
enabled: true
image: ubuntu-2004:202111-02
image: ubuntu-2004:2022.10.1
<<: *env

setup_minikube: &setup_minikube
Expand Down Expand Up @@ -75,16 +74,6 @@ install_docker_buildx: &install_docker_buildx
# Verify buildx is available
docker buildx create --use
# Installation script for the docker compose plugin. See: https://docs.docker.com/compose/install/#install-compose-on-linux-systems
install_docker_compose: &install_docker_compose
name: install docker compose
command: |
curl -sLO https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64
mkdir -p ~/.docker/cli-plugins
mv docker-compose-linux-x86_64 ~/.docker/cli-plugins/docker-compose
chmod a+x ~/.docker/cli-plugins/docker-compose
docker compose version
configure_environment_for_gcp: &configure_environment_for_gcp
name: configure environment for gcp
command: |
Expand Down Expand Up @@ -180,8 +169,6 @@ jobs:
<<: *install_gruntwork_utils
- run:
<<: *install_docker_buildx
- run:
<<: *install_docker_compose

# The weird way you have to set PATH in Circle 2.0
- run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/01_getting-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ custom_js:

Terratest uses the Go testing framework. To use Terratest, you need to install:

- [Go](https://golang.org/) (requires version >=1.17)
- [Go](https://golang.org/) (requires version >=1.18)

## Setting up your project

Expand Down
1 change: 1 addition & 0 deletions docs/_includes/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
<ul class="nav navbar-nav navbar-right">
<li><a href="https://gruntwork.io/careers"><span class="new-label">NEW</span>We're Hiring!</a></li>
<li><a href="{{site.baseurl}}/docs/getting-started/quick-start" ga-on="click" ga-event-category="nav-{{ page.path | slugify }}" ga-event-action="quick-start">Quick Start</a></li>
<li><a href="{{site.baseurl}}/docs/" ga-on="click" ga-event-category="nav-{{ page.path | slugify }}" ga-event-action="docs">Docs</a></li>
<li><a href="{{site.baseurl}}/examples/" ga-on="click" ga-event-category="nav-examples" ga-event-action="examples">Examples</a></li>
Expand Down
21 changes: 21 additions & 0 deletions docs/assets/css/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,27 @@ footer hr {
border-left: 2px solid #194C5F;
}

.navbar-nav {
li {
&:first-child {
a {
display: flex;
span {
margin-right: 12px;
padding: 0;
background: linear-gradient(101.84deg, #FE3162 2.31%, #FF4F47 98.56%);
border-radius: 3.5px;
font-weight: 600;
min-width: 52px;
display: flex;
align-items: center;
justify-content: center;
}
}
}
}
}

@media (min-width: 768px) {
.dropdown:hover .dropdown-menu {
display: block;
Expand Down
7 changes: 4 additions & 3 deletions docs/assets/css/pages/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ body.index-page {
margin-left: 15px;
}
}

@media all and (max-width: 450px) {
flex-direction: column;
min-width: auto;
Expand Down Expand Up @@ -281,7 +280,9 @@ body.index-page {
}

@media all and (max-width: 450px) {
.hide-on-cxs { display: none; }
.hide-on-cxs {
display: none;
}
}

}
Expand Down Expand Up @@ -318,7 +319,7 @@ body.index-page {
@media all and (max-width: 991px) {
.row.flex {
flex-direction: column;
& > .col-xs-12:first-child {
&>.col-xs-12:first-child {
margin-bottom: 50px;
max-width: 800px;
margin-left: auto;
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/gruntwork-io/terratest

go 1.17
go 1.18

require (
cloud.google.com/go v0.83.0
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
Expand Down Expand Up @@ -503,7 +502,6 @@ github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl/v2 v2.9.1 h1:eOy4gREY0/ZQHNItlfuEZqtcQbXIxzojlP301hDpnac=
github.com/hashicorp/hcl/v2 v2.9.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
Expand Down Expand Up @@ -1308,7 +1306,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
Expand Down
44 changes: 44 additions & 0 deletions modules/aws/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ecr"
"github.com/gruntwork-io/go-commons/errors"
"github.com/gruntwork-io/terratest/modules/logger"
"github.com/gruntwork-io/terratest/modules/testing"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -97,3 +98,46 @@ func NewECRClientE(t testing.TestingT, region string) (*ecr.ECR, error) {
}
return ecr.New(sess), nil
}

// GetECRRepoLifecyclePolicy gets the policies for the given ECR repository.
// This will fail the test and stop execution if there is an error.
func GetECRRepoLifecyclePolicy(t testing.TestingT, region string, repo *ecr.Repository) string {
policy, err := GetECRRepoLifecyclePolicyE(t, region, repo)
require.NoError(t, err)
return policy
}

// GetECRRepoLifecyclePolicyE gets the policies for the given ECR repository.
func GetECRRepoLifecyclePolicyE(t testing.TestingT, region string, repo *ecr.Repository) (string, error) {
client := NewECRClient(t, region)
resp, err := client.GetLifecyclePolicy(&ecr.GetLifecyclePolicyInput{RepositoryName: repo.RepositoryName})
if err != nil {
return "", err
}
return *resp.LifecyclePolicyText, nil
}

// PutECRRepoLifecyclePolicy puts the given policy for the given ECR repository.
// This will fail the test and stop execution if there is an error.
func PutECRRepoLifecyclePolicy(t testing.TestingT, region string, repo *ecr.Repository, policy string) {
err := PutECRRepoLifecyclePolicyE(t, region, repo, policy)
require.NoError(t, err)
}

// PutEcrRepoLifecyclePolicy puts the given policy for the given ECR repository.
func PutECRRepoLifecyclePolicyE(t testing.TestingT, region string, repo *ecr.Repository, policy string) error {
logger.Logf(t, "Applying policy for repository %s in %s", *repo.RepositoryName, region)

client, err := NewECRClientE(t, region)
if err != nil {
return err
}

input := &ecr.PutLifecyclePolicyInput{
RepositoryName: repo.RepositoryName,
LifecyclePolicyText: aws.String(policy),
}

_, err = client.PutLifecyclePolicy(input)
return err
}
49 changes: 49 additions & 0 deletions modules/aws/ecr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,52 @@ func TestEcrRepo(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, ecrRepoName, aws.StringValue(repo2.RepositoryName))
}

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

region := GetRandomStableRegion(t, nil, nil)
ecrRepoName := fmt.Sprintf("terratest%s", strings.ToLower(random.UniqueId()))
repo1, err := CreateECRRepoE(t, region, ecrRepoName)
defer DeleteECRRepo(t, region, repo1)
require.NoError(t, err)

assert.Equal(t, ecrRepoName, aws.StringValue(repo1.RepositoryName))

_, err = GetECRRepoLifecyclePolicyE(t, region, repo1)
require.Error(t, err)
}

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

region := GetRandomStableRegion(t, nil, nil)
ecrRepoName := fmt.Sprintf("terratest%s", strings.ToLower(random.UniqueId()))
repo1, err := CreateECRRepoE(t, region, ecrRepoName)
defer DeleteECRRepo(t, region, repo1)
require.NoError(t, err)

lifecyclePolicy := `{
"rules": [
{
"rulePriority": 1,
"description": "Expire images older than 14 days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 14
},
"action": {
"type": "expire"
}
}
]
}`

err = PutECRRepoLifecyclePolicyE(t, region, repo1, lifecyclePolicy)
require.NoError(t, err)

policy := GetECRRepoLifecyclePolicy(t, region, repo1)
assert.JSONEq(t, lifecyclePolicy, policy)
}
2 changes: 1 addition & 1 deletion modules/aws/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func GetS3BucketTags(t testing.TestingT, awsRegion string, bucket string) map[st
return tags
}

// GetS3BucketTagsE fetches the given bucket's tags and returns them as a string map of strings.
// GetS3BucketTagsE fetches the given bucket's tags and returns them as a string map of strings.
func GetS3BucketTagsE(t testing.TestingT, awsRegion string, bucket string) (map[string]string, error) {
s3Client, err := NewS3ClientE(t, awsRegion)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions modules/azure/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func GetMYSQLDBClientE(subscriptionID string) (*mysql.DatabasesClient, error) {
return &mysqlDBClient, nil
}

//GetMYSQLDB is a helper function that gets the database.
// GetMYSQLDB is a helper function that gets the database.
// This function would fail the test if there is an error.
func GetMYSQLDB(t testing.TestingT, resGroupName string, serverName string, dbName string, subscriptionID string) *mysql.Database {
database, err := GetMYSQLDBE(t, subscriptionID, resGroupName, serverName, dbName)
Expand All @@ -91,7 +91,7 @@ func GetMYSQLDB(t testing.TestingT, resGroupName string, serverName string, dbNa
return database
}

//GetMYSQLDBE is a helper function that gets the database.
// GetMYSQLDBE is a helper function that gets the database.
func GetMYSQLDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string, dbName string) (*mysql.Database, error) {
// Create a mySQl db client
mysqldbClient, err := GetMYSQLDBClientE(subscriptionID)
Expand All @@ -109,15 +109,15 @@ func GetMYSQLDBE(t testing.TestingT, subscriptionID string, resGroupName string,
return &mysqlDb, nil
}

//ListMySQLDB is a helper function that gets all databases per server.
// ListMySQLDB is a helper function that gets all databases per server.
func ListMySQLDB(t testing.TestingT, resGroupName string, serverName string, subscriptionID string) []mysql.Database {
dblist, err := ListMySQLDBE(t, subscriptionID, resGroupName, serverName)
require.NoError(t, err)

return dblist
}

//ListMySQLDBE is a helper function that gets all databases per server.
// ListMySQLDBE is a helper function that gets all databases per server.
func ListMySQLDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) ([]mysql.Database, error) {
// Create a mySQl db client
mysqldbClient, err := GetMYSQLDBClientE(subscriptionID)
Expand Down
8 changes: 4 additions & 4 deletions modules/azure/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func GetPostgreSQLDBClientE(subscriptionID string) (*postgresql.DatabasesClient,
return &postgresqlDBClient, nil
}

//GetPostgreSQLDB is a helper function that gets the database.
// GetPostgreSQLDB is a helper function that gets the database.
// This function would fail the test if there is an error.
func GetPostgreSQLDB(t testing.TestingT, resGroupName string, serverName string, dbName string, subscriptionID string) *postgresql.Database {
database, err := GetPostgreSQLDBE(t, subscriptionID, resGroupName, serverName, dbName)
Expand All @@ -90,7 +90,7 @@ func GetPostgreSQLDB(t testing.TestingT, resGroupName string, serverName string,
return database
}

//GetPostgreSQLDBE is a helper function that gets the database.
// GetPostgreSQLDBE is a helper function that gets the database.
func GetPostgreSQLDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string, dbName string) (*postgresql.Database, error) {
// Create a postgresql db client
postgresqldbClient, err := GetPostgreSQLDBClientE(subscriptionID)
Expand All @@ -108,15 +108,15 @@ func GetPostgreSQLDBE(t testing.TestingT, subscriptionID string, resGroupName st
return &postgresqlDb, nil
}

//ListPostgreSQLDB is a helper function that gets all databases per server.
// ListPostgreSQLDB is a helper function that gets all databases per server.
func ListPostgreSQLDB(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) []postgresql.Database {
dblist, err := ListPostgreSQLDBE(t, subscriptionID, resGroupName, serverName)
require.NoError(t, err)

return dblist
}

//ListPostgreSQLDBE is a helper function that gets all databases per server.
// ListPostgreSQLDBE is a helper function that gets all databases per server.
func ListPostgreSQLDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) ([]postgresql.Database, error) {
// Create a postgresql db client
postgresqldbClient, err := GetPostgreSQLDBClientE(subscriptionID)
Expand Down
4 changes: 2 additions & 2 deletions modules/azure/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ func GetDatabaseClient(subscriptionID string) (*sql.DatabasesClient, error) {
return &sqlDBClient, nil
}

//ListSQLServerDatabases is a helper function that gets a list of databases on a sql server
// ListSQLServerDatabases is a helper function that gets a list of databases on a sql server
func ListSQLServerDatabases(t testing.TestingT, resGroupName string, serverName string, subscriptionID string) *[]sql.Database {
dbList, err := ListSQLServerDatabasesE(t, resGroupName, serverName, subscriptionID)
require.NoError(t, err)

return dbList
}

//ListSQLServerDatabasesE is a helper function that gets a list of databases on a sql server
// ListSQLServerDatabasesE is a helper function that gets a list of databases on a sql server
func ListSQLServerDatabasesE(t testing.TestingT, resGroupName string, serverName string, subscriptionID string) (*[]sql.Database, error) {
// Create a SQl db client
sqlClient, err := CreateDatabaseClient(subscriptionID)
Expand Down
16 changes: 16 additions & 0 deletions modules/docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ type BuildOptions struct {
// solely focus on the most important ones.
OtherOptions []string

// Whether ot not to enable buildkit. You can find more information about buildkit here https://docs.docker.com/build/buildkit/#getting-started.
EnableBuildKit bool

// Additional environment variables to pass in when running docker build command.
Env map[string]string

// Set a logger that should be used. See the logger package for more info.
Logger *logger.Logger
}
Expand All @@ -64,10 +70,20 @@ func Build(t testing.TestingT, path string, options *BuildOptions) {
func BuildE(t testing.TestingT, path string, options *BuildOptions) error {
options.Logger.Logf(t, "Running 'docker build' in %s", path)

env := make(map[string]string)
if options.Env != nil {
env = options.Env
}

if options.EnableBuildKit {
env["DOCKER_BUILDKIT"] = "1"
}

cmd := shell.Command{
Command: "docker",
Args: formatDockerBuildArgs(path, options),
Logger: options.Logger,
Env: env,
}

if err := shell.RunCommandE(t, cmd); err != nil {
Expand Down
Loading

0 comments on commit 29d7d80

Please sign in to comment.