Skip to content

Commit

Permalink
Merge branch 'main' into feature/postgres-ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
bearrito committed Apr 26, 2024
2 parents e28361a + 14d6929 commit 8502649
Show file tree
Hide file tree
Showing 230 changed files with 5,478 additions and 2,190 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [testcontainers]
2 changes: 2 additions & 0 deletions .github/workflows/ci-test-go.yml
Expand Up @@ -50,6 +50,8 @@ jobs:
continue-on-error: ${{ !inputs.fail-fast }}
env:
TESTCONTAINERS_RYUK_DISABLED: "${{ inputs.ryuk-disabled }}"
RYUK_CONNECTION_TIMEOUT: "${{ inputs.project-directory == 'modules/compose' && '5m' || '60s' }}"
RYUK_RECONNECTION_TIMEOUT: "${{ inputs.project-directory == 'modules/compose' && '30s' || '10s' }}"
steps:
- name: Setup rootless Docker
if: ${{ inputs.rootless-docker }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -94,7 +94,7 @@ jobs:
matrix:
go-version: [1.21.x, 1.x]
platform: [ubuntu-latest]
module: [artemis, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, elasticsearch, gcloud, inbucket, influxdb, k3s, k6, kafka, localstack, mariadb, milvus, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, ollama, openfga, openldap, opensearch, postgres, pulsar, qdrant, rabbitmq, redis, redpanda, registry, surrealdb, vault, weaviate]
module: [artemis, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, dolt, elasticsearch, gcloud, inbucket, influxdb, k3s, k6, kafka, localstack, mariadb, milvus, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, ollama, openfga, openldap, opensearch, postgres, pulsar, qdrant, rabbitmq, redis, redpanda, registry, surrealdb, vault, weaviate]
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Expand Up @@ -53,7 +53,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -67,7 +67,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
uses: github/codeql-action/autobuild@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -80,6 +80,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Expand Up @@ -51,6 +51,6 @@ jobs:

# required for Code scanning alerts
- name: "Upload SARIF results to code scanning"
uses: github/codeql-action/upload-sarif@1500a131381b66de0c52ac28abb13cd79f4b7ecc # v2.22.12
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
sarif_file: results.sarif
1 change: 1 addition & 0 deletions .golangci.yml
Expand Up @@ -7,6 +7,7 @@ linters:
- misspell
- nonamedreturns
- testifylint
- errcheck

linters-settings:
errorlint:
Expand Down
4 changes: 4 additions & 0 deletions .vscode/.testcontainers-go.code-workspace
Expand Up @@ -45,6 +45,10 @@
"name": "module / couchbase",
"path": "../modules/couchbase"
},
{
"name": "module / dolt",
"path": "../modules/dolt"
},
{
"name": "module / elasticsearch",
"path": "../modules/elasticsearch"
Expand Down
7 changes: 4 additions & 3 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions container.go
Expand Up @@ -121,6 +121,7 @@ func (c *ContainerFile) validate() error {
// ContainerRequest represents the parameters used to get a running container
type ContainerRequest struct {
FromDockerfile
HostAccessPorts []int
Image string
ImageSubstitutors []ImageSubstitutor
Entrypoint []string
Expand Down Expand Up @@ -221,13 +222,17 @@ func (c *ContainerRequest) GetContext() (io.Reader, error) {
}
c.Context = abs

excluded, err := parseDockerIgnore(abs)
dockerIgnoreExists, excluded, err := parseDockerIgnore(abs)
if err != nil {
return nil, err
}

dockerIgnoreLocation := filepath.Join(abs, ".dockerignore")
includes = append(includes, dockerIgnoreLocation, c.GetDockerfile())
if dockerIgnoreExists {
// only add .dockerignore if it exists
includes = append(includes, ".dockerignore")
}

includes = append(includes, c.GetDockerfile())

buildContext, err := archive.TarWithOptions(
c.Context,
Expand All @@ -240,18 +245,24 @@ func (c *ContainerRequest) GetContext() (io.Reader, error) {
return buildContext, nil
}

func parseDockerIgnore(targetDir string) ([]string, error) {
// parseDockerIgnore returns if the file exists, the excluded files and an error if any
func parseDockerIgnore(targetDir string) (bool, []string, error) {
// based on https://github.com/docker/cli/blob/master/cli/command/image/build/dockerignore.go#L14
fileLocation := filepath.Join(targetDir, ".dockerignore")
var excluded []string
exists := false
if f, openErr := os.Open(fileLocation); openErr == nil {
defer f.Close()

exists = true

var err error
excluded, err = ignorefile.ReadAll(f)
if err != nil {
return excluded, fmt.Errorf("error reading .dockerignore: %w", err)
return true, excluded, fmt.Errorf("error reading .dockerignore: %w", err)
}
}
return excluded, nil
return exists, excluded, nil
}

// GetBuildArgs returns the env args to be used when creating from Dockerfile
Expand Down
11 changes: 10 additions & 1 deletion container_ignore_test.go
Expand Up @@ -11,23 +11,32 @@ import (
func TestParseDockerIgnore(t *testing.T) {
testCases := []struct {
filePath string
exists bool
expectedErr error
expectedExcluded []string
}{
{
filePath: "./testdata/dockerignore",
expectedErr: nil,
exists: true,
expectedExcluded: []string{"vendor", "foo", "bar"},
},
{
filePath: "./testdata",
expectedErr: nil,
exists: true,
expectedExcluded: []string{"Dockerfile", "echo.Dockerfile"},
},
{
filePath: "./testdata/data",
expectedErr: nil,
expectedExcluded: nil, // it's nil because the parseDockerIgnore function uses the zero value of a slice
},
}

for _, testCase := range testCases {
excluded, err := parseDockerIgnore(testCase.filePath)
exists, excluded, err := parseDockerIgnore(testCase.filePath)
assert.Equal(t, testCase.exists, exists)
assert.Equal(t, testCase.expectedErr, err)
assert.Equal(t, testCase.expectedExcluded, excluded)
}
Expand Down

0 comments on commit 8502649

Please sign in to comment.