-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into dependabot/go_modules/golang.org/x/net-0.…
…17.0
- Loading branch information
Showing
104 changed files
with
6,819 additions
and
2,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Run Integration Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
integ-tests: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: prod | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: allows us to build arm64 images | ||
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
- name: run integration tests | ||
run: make integ-tests-with-docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"go.amzn.com/lambda/fatalerror" | ||
"go.amzn.com/lambda/interop" | ||
"go.amzn.com/lambda/rapidcore/env" | ||
) | ||
|
||
// the type implement a simpler version of the Bootstrap | ||
// this is useful in the Standalone Core implementation. | ||
type simpleBootstrap struct { | ||
cmd []string | ||
workingDir string | ||
} | ||
|
||
func NewSimpleBootstrap(cmd []string, currentWorkingDir string) interop.Bootstrap { | ||
if currentWorkingDir == "" { | ||
// use the root directory as the default working directory | ||
currentWorkingDir = "/" | ||
} | ||
|
||
// a single candidate command makes it automatically valid | ||
return &simpleBootstrap{ | ||
cmd: cmd, | ||
workingDir: currentWorkingDir, | ||
} | ||
} | ||
|
||
func (b *simpleBootstrap) Cmd() ([]string, error) { | ||
return b.cmd, nil | ||
} | ||
|
||
// Cwd returns the working directory of the bootstrap process | ||
// The path is validated against the chroot identified by `root` | ||
func (b *simpleBootstrap) Cwd() (string, error) { | ||
if !filepath.IsAbs(b.workingDir) { | ||
return "", fmt.Errorf("the working directory '%s' is invalid, it needs to be an absolute path", b.workingDir) | ||
} | ||
|
||
// evaluate the path relatively to the domain's mnt namespace root | ||
if _, err := os.Stat(b.workingDir); os.IsNotExist(err) { | ||
return "", fmt.Errorf("the working directory doesn't exist: %s", b.workingDir) | ||
} | ||
|
||
return b.workingDir, nil | ||
} | ||
|
||
// Env returns the environment variables available to | ||
// the bootstrap process | ||
func (b *simpleBootstrap) Env(e *env.Environment) map[string]string { | ||
return e.RuntimeExecEnv() | ||
} | ||
|
||
// ExtraFiles returns the extra file descriptors apart from 1 & 2 to be passed to runtime | ||
func (b *simpleBootstrap) ExtraFiles() []*os.File { | ||
return make([]*os.File, 0) | ||
} | ||
|
||
func (b *simpleBootstrap) CachedFatalError(err error) (fatalerror.ErrorType, string, bool) { | ||
// not implemented as it is not needed in Core but we need to fullfil the interface anyway | ||
return fatalerror.ErrorType(""), "", false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"reflect" | ||
"testing" | ||
|
||
"go.amzn.com/lambda/rapidcore/env" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSimpleBootstrap(t *testing.T) { | ||
tmpFile, err := os.CreateTemp("", "oci-test-bootstrap") | ||
assert.NoError(t, err) | ||
defer os.Remove(tmpFile.Name()) | ||
|
||
// Setup single cmd candidate | ||
file := []string{tmpFile.Name(), "--arg1 s", "foo"} | ||
cmdCandidate := file | ||
|
||
// Setup working dir | ||
cwd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
|
||
// Setup environment | ||
environment := env.NewEnvironment() | ||
environment.StoreRuntimeAPIEnvironmentVariable("host:port") | ||
environment.StoreEnvironmentVariablesFromInit(map[string]string{}, "", "", "", "", "", "") | ||
|
||
// Test | ||
b := NewSimpleBootstrap(cmdCandidate, cwd) | ||
bCwd, err := b.Cwd() | ||
assert.NoError(t, err) | ||
assert.Equal(t, cwd, bCwd) | ||
assert.True(t, reflect.DeepEqual(environment.RuntimeExecEnv(), b.Env(environment))) | ||
|
||
cmd, err := b.Cmd() | ||
assert.NoError(t, err) | ||
assert.Equal(t, file, cmd) | ||
} | ||
|
||
func TestSimpleBootstrapCmdNonExistingCandidate(t *testing.T) { | ||
// Setup inexistent single cmd candidate | ||
file := []string{"/foo/bar", "--arg1 s", "foo"} | ||
cmdCandidate := file | ||
|
||
// Setup working dir | ||
cwd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
|
||
// Setup environment | ||
environment := env.NewEnvironment() | ||
environment.StoreRuntimeAPIEnvironmentVariable("host:port") | ||
environment.StoreEnvironmentVariablesFromInit(map[string]string{}, "", "", "", "", "", "") | ||
|
||
// Test | ||
b := NewSimpleBootstrap(cmdCandidate, cwd) | ||
bCwd, err := b.Cwd() | ||
assert.NoError(t, err) | ||
assert.Equal(t, cwd, bCwd) | ||
assert.True(t, reflect.DeepEqual(environment.RuntimeExecEnv(), b.Env(environment))) | ||
|
||
// No validations run against single candidates | ||
cmd, err := b.Cmd() | ||
assert.NoError(t, err) | ||
assert.Equal(t, file, cmd) | ||
} | ||
|
||
func TestSimpleBootstrapCmdDefaultWorkingDir(t *testing.T) { | ||
b := NewSimpleBootstrap([]string{}, "") | ||
bCwd, err := b.Cwd() | ||
assert.NoError(t, err) | ||
assert.Equal(t, "/", bCwd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
module go.amzn.com | ||
|
||
go 1.19 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/aws/aws-lambda-go v1.41.0 | ||
github.com/go-chi/chi v4.1.2+incompatible | ||
github.com/google/uuid v1.3.0 | ||
github.com/aws/aws-lambda-go v1.46.0 | ||
github.com/go-chi/chi v1.5.5 | ||
github.com/google/uuid v1.6.0 | ||
github.com/jessevdk/go-flags v1.5.0 | ||
github.com/sirupsen/logrus v1.9.3 | ||
github.com/stretchr/testify v1.8.4 | ||
golang.org/x/sync v0.2.0 | ||
github.com/stretchr/testify v1.9.0 | ||
golang.org/x/sync v0.6.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/objx v0.5.0 // indirect | ||
golang.org/x/net v0.17.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
github.com/stretchr/objx v0.5.2 // indirect | ||
golang.org/x/sys v0.14.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.