Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PostgreSQL support as alternative data storage #3236

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
11 changes: 6 additions & 5 deletions cmd/porter/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"get.porter.sh/porter/pkg"
"get.porter.sh/porter/tests"

"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"get.porter.sh/porter/pkg/porter"
)

func TestValidateInstallCommand(t *testing.T) {
Expand All @@ -30,7 +31,7 @@ func TestValidateInstallCommand(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
var outBuf bytes.Buffer
p := buildRootCommand()
p := buildRootCommand(t)
p.SetOut(&outBuf)
p.SetErr(&outBuf)
osargs := strings.Split(tc.args, " ")
Expand Down Expand Up @@ -69,7 +70,7 @@ func TestValidateUninstallCommand(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
var outBuf bytes.Buffer
p := buildRootCommand()
p := buildRootCommand(t)
p.SetOut(&outBuf)
p.SetErr(&outBuf)
osargs := strings.Split(tc.args, " ")
Expand Down Expand Up @@ -105,7 +106,7 @@ func TestValidateInvokeCommand(t *testing.T) {

for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
p := buildRootCommand()
p := buildRootCommand(t)
osargs := strings.Split(tc.args, " ")
cmd, args, err := p.Find(osargs)
require.NoError(t, err)
Expand Down Expand Up @@ -136,7 +137,7 @@ func TestValidateInstallationListCommand(t *testing.T) {

for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
p := buildRootCommand()
p := buildRootCommand(t)
osargs := strings.Split(tc.args, " ")
cmd, args, err := p.Find(osargs)
require.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletions cmd/porter/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"os"
"testing"

"get.porter.sh/porter/pkg/porter"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"get.porter.sh/porter/pkg/porter"
)

func TestCompletion(t *testing.T) {
p := buildRootCommand()
p := buildRootCommand(t)

// Capture the output of the command.
var out bytes.Buffer
Expand Down
12 changes: 5 additions & 7 deletions cmd/porter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
"strconv"
"strings"

"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/config"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/config"
"get.porter.sh/porter/pkg/porter"
)

var includeDocsCommand = false
Expand All @@ -36,6 +37,7 @@ const (
func main() {
run := func() int {
p := porter.New()

ctx, cancel := handleInterrupt(context.Background(), p)
defer cancel()

Expand Down Expand Up @@ -158,10 +160,6 @@ func getCalledCommand(cmd *cobra.Command) (*cobra.Command, string, string) {
return calledCommand, calledCommandStr, formattedCommand
}

func buildRootCommand() *cobra.Command {
return buildRootCommandFrom(porter.New())
}

func buildRootCommandFrom(p *porter.Porter) *cobra.Command {
var printVersion bool

Expand Down
19 changes: 13 additions & 6 deletions cmd/porter/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ import (
"strings"
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"get.porter.sh/porter/pkg"
"get.porter.sh/porter/pkg/config"
"get.porter.sh/porter/pkg/experimental"
"get.porter.sh/porter/pkg/porter"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func buildRootCommand(_ *testing.T) *cobra.Command {
p := porter.New()
return buildRootCommandFrom(p)
}

func TestCommandWiring(t *testing.T) {
testcases := []string{
"build",
Expand All @@ -39,7 +46,7 @@ func TestCommandWiring(t *testing.T) {
t.Run(tc, func(t *testing.T) {
osargs := strings.Split(tc, " ")

rootCmd := buildRootCommand()
rootCmd := buildRootCommand(t)
cmd, _, err := rootCmd.Find(osargs)
assert.NoError(t, err)
assert.Equal(t, osargs[len(osargs)-1], cmd.Name())
Expand All @@ -50,7 +57,7 @@ func TestCommandWiring(t *testing.T) {
func TestHelp(t *testing.T) {
t.Run("no args", func(t *testing.T) {
var output bytes.Buffer
rootCmd := buildRootCommand()
rootCmd := buildRootCommand(t)
rootCmd.SetArgs([]string{})
rootCmd.SetOut(&output)

Expand All @@ -61,7 +68,7 @@ func TestHelp(t *testing.T) {

t.Run("help", func(t *testing.T) {
var output bytes.Buffer
rootCmd := buildRootCommand()
rootCmd := buildRootCommand(t)
rootCmd.SetArgs([]string{"help"})
rootCmd.SetOut(&output)

Expand All @@ -72,7 +79,7 @@ func TestHelp(t *testing.T) {

t.Run("--help", func(t *testing.T) {
var output bytes.Buffer
rootCmd := buildRootCommand()
rootCmd := buildRootCommand(t)
rootCmd.SetArgs([]string{"--help"})
rootCmd.SetOut(&output)

Expand Down
7 changes: 4 additions & 3 deletions cmd/porter/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import (
"os"
"testing"

"get.porter.sh/porter/pkg"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"get.porter.sh/porter/pkg"
)

func TestVersion(t *testing.T) {
pkg.Version = "v1.0.0"
pkg.Commit = "abc123"

t.Run("command", func(t *testing.T) {
p := buildRootCommand()
p := buildRootCommand(t)

// Capture output
var out bytes.Buffer
Expand All @@ -30,7 +31,7 @@ func TestVersion(t *testing.T) {
})

t.Run("flag", func(t *testing.T) {
p := buildRootCommand()
p := buildRootCommand(t)

// Capture output
var out bytes.Buffer
Expand Down
14 changes: 14 additions & 0 deletions docs/content/docs/references/examples/airgap.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ Porter handles tracking the image location for you, just use the template variab

[images]: /docs/bundle/manifest/#images

If using exec mixin, image digests can be passed via environmental variables or arguments.

```yaml
install:
- exec:
description: "Insall WhaleGap"
command: ./porter-scripts.sh
arguments:
- install
envs:
IMAGE_whalesayd: "${ bundle.images.whalesayd.repository }@${ bundle.images.whalesayd.digest }"
```


## Move the bundle across the airgap

Let's simulate moving the bundle across an airgap by publishing the bundle to a different registry.
Expand Down
31 changes: 22 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module get.porter.sh/porter

go 1.21
go 1.22.0

toolchain go1.21.3
toolchain go1.23.1

replace (
// See https://github.com/hashicorp/go-plugin/pull/127 and
Expand Down Expand Up @@ -55,7 +55,9 @@ require (
github.com/opencontainers/go-digest v1.0.0
github.com/osteele/liquid v1.4.0
github.com/pelletier/go-toml v1.9.5
github.com/pressly/goose/v3 v3.22.1
github.com/prometheus/client_golang v1.19.1
github.com/robinbraemer/devroach v0.0.0-20240607164754-44eb6d8f1cfc
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
Expand All @@ -74,12 +76,14 @@ require (
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
go.uber.org/zap v1.27.0
golang.org/x/sync v0.7.0
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.2
gopkg.in/AlecAivazis/survey.v1 v1.8.8
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.12
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
)

Expand Down Expand Up @@ -109,6 +113,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/cockroach-go/v2 v2.3.7 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/containerd/api v1.7.19 // indirect
github.com/containerd/continuity v0.4.2 // indirect
Expand Down Expand Up @@ -152,17 +157,24 @@ require (
github.com/imdario/mergo v0.3.16 // indirect
github.com/in-toto/in-toto-golang v0.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jeremywohl/flatten v1.0.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/kr/pty v1.1.5 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mholt/archiver/v3 v3.5.1 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
Expand Down Expand Up @@ -199,8 +211,9 @@ require (
github.com/rivo/uniseg v0.4.4 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.4.0 // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down Expand Up @@ -228,12 +241,12 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
Expand Down
Loading
Loading