Skip to content

Commit

Permalink
fix: always disable Ryuk
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpivkin committed Feb 28, 2024
1 parent 557177b commit 46bf2fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
6 changes: 6 additions & 0 deletions internal/testutil/localstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ package testutil
import (
"context"
"fmt"
"os"

dockercontainer "github.com/docker/docker/api/types/container"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/localstack"
)

func SetupLocalStack(ctx context.Context, version string) (*localstack.LocalStackContainer, string, error) {

if err := os.Setenv("TESTCONTAINERS_RYUK_DISABLED", "true"); err != nil {
return nil, "", err
}

container, err := localstack.RunContainer(ctx, testcontainers.CustomizeRequest(
testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Expand Down
6 changes: 0 additions & 6 deletions magefiles/terraformplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ const (
)

func fixtureTerraformPlanSnapshots(ctx context.Context) error {

if err := os.Setenv("TESTCONTAINERS_RYUK_DISABLED", "true"); err != nil {
return err
}

localstackC, addr, err := testutil.SetupLocalStack(ctx, "3.1.0")
if err != nil {
return err
Expand Down Expand Up @@ -100,7 +95,6 @@ func fixtureTerraformPlanSnapshots(ctx context.Context) error {
}

return g.Wait()

}

func generatePlan(ctx context.Context, execPath, workingDir string) error {
Expand Down
9 changes: 2 additions & 7 deletions pkg/x/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@ func NewReadSeekerAtWithSize(r io.Reader) (ReadSeekerAt, int64, error) {
return rsa, br.Size(), nil
}

size, err := getSize(r)
size, err := getSeekerSize(rsa)
if err != nil {
return nil, 0, xerrors.Errorf("get size error: %w", err)
}
return rsa, size, nil
}

func getSize(r io.Reader) (int64, error) {
s, ok := r.(io.Seeker)
if !ok {
return 0, xerrors.New("reader does not support seeking for size")
}

func getSeekerSize(s io.Seeker) (int64, error) {
size, err := s.Seek(0, io.SeekEnd)
if err != nil {
return 0, xerrors.Errorf("seek error: %w", err)
Expand Down

0 comments on commit 46bf2fc

Please sign in to comment.