Skip to content

Commit

Permalink
Put feature behind experimental flag
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Christensen <kimworking@gmail.com>
  • Loading branch information
kichristensen committed May 4, 2024
1 parent 75dc2c2 commit b002fa5
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 99 deletions.
2 changes: 1 addition & 1 deletion pkg/porter/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (p *Porter) Run(ctx context.Context, opts RunOptions) error {
return span.Error(err)
}

runtimeCfg := runtime.NewConfigFor(p.Context)
runtimeCfg := runtime.NewConfigFor(p.Config)
runtimeCfg.DebugMode = opts.DebugMode
r := runtime.NewPorterRuntime(runtimeCfg, p.Mixins)
runtimeManifest := r.NewRuntimeManifest(opts.Action, m)
Expand Down
13 changes: 6 additions & 7 deletions pkg/runtime/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@ import (
"strconv"

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

// RuntimeConfig is a specialized portercontext.Context with additional runtime-specific settings.
// RuntimeConfig is a specialized config.Config with additional runtime-specific settings.
type RuntimeConfig struct {
*portercontext.Context
*config.Config

// DebugMode indicates if the bundle is running in debug mode.
DebugMode bool
}

// NewConfig returns an initialized RuntimeConfig
func NewConfig() RuntimeConfig {
return NewConfigFor(portercontext.New())
return NewConfigFor(config.New())
}

// NewConfigFor returns an initialized RuntimeConfig using the specified context.
func NewConfigFor(porterCtx *portercontext.Context) RuntimeConfig {
debug, _ := strconv.ParseBool(porterCtx.Getenv("PORTER_DEBUG"))
func NewConfigFor(config *config.Config) RuntimeConfig {
debug, _ := strconv.ParseBool(config.Getenv("PORTER_DEBUG"))
return RuntimeConfig{
Context: porterCtx,
DebugMode: debug,
Config: config,
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/runtime/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package runtime
import (
"testing"

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

Expand All @@ -23,9 +23,9 @@ func TestRuntimeConfig_DebugMode(t *testing.T) {
t.Run(tc.debugEnv, func(t *testing.T) {
t.Parallel()

pctx := portercontext.New()
pctx.Setenv("PORTER_DEBUG", tc.debugEnv)
c := NewConfigFor(pctx)
config := config.NewTestConfig(t)
config.Setenv("PORTER_DEBUG", tc.debugEnv)
c := NewConfigFor(config.Config)
assert.Equal(t, tc.wantDebug, c.DebugMode)
})
}
Expand Down
17 changes: 9 additions & 8 deletions pkg/runtime/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package runtime
import (
"testing"

"get.porter.sh/porter/pkg/config"
"get.porter.sh/porter/pkg/mixin"
"get.porter.sh/porter/pkg/portercontext"
)
Expand All @@ -13,15 +14,15 @@ type TestPorterRuntime struct {
}

func NewTestPorterRuntime(t *testing.T) *TestPorterRuntime {
cxt := portercontext.NewTestContext(t)
cxt.Setenv("PORTER_DEBUG", "true")
testConfig := config.NewTestConfig(t)
testConfig.Setenv("PORTER_DEBUG", "true")

mixins := mixin.NewTestMixinProvider()
cfg := NewConfigFor(cxt.Context)
cfg := NewConfigFor(testConfig.Config)
pr := NewPorterRuntime(cfg, mixins)

return &TestPorterRuntime{
TestContext: cxt,
TestContext: testConfig.TestContext,
PorterRuntime: pr,
}
}
Expand All @@ -32,11 +33,11 @@ type TestRuntimeConfig struct {
}

func NewTestRuntimeConfig(t *testing.T) TestRuntimeConfig {
porterCtx := portercontext.NewTestContext(t)
porterCtx.Setenv("PORTER_DEBUG", "true")
runtimeCfg := NewConfigFor(porterCtx.Context)
testConfig := config.NewTestConfig(t)
testConfig.Setenv("PORTER_DEBUG", "true")
runtimeCfg := NewConfigFor(testConfig.Config)
return TestRuntimeConfig{
RuntimeConfig: runtimeCfg,
TestContext: porterCtx,
TestContext: testConfig.TestContext,
}
}
9 changes: 6 additions & 3 deletions pkg/runtime/runtime_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"get.porter.sh/porter/pkg"
"get.porter.sh/porter/pkg/cnab"
"get.porter.sh/porter/pkg/config"
"get.porter.sh/porter/pkg/experimental"
"get.porter.sh/porter/pkg/manifest"
"get.porter.sh/porter/pkg/tracing"
"get.porter.sh/porter/pkg/yaml"
Expand Down Expand Up @@ -454,9 +455,11 @@ func (m *RuntimeManifest) ResolveStep(ctx context.Context, stepIndex int, step *

mustache.AllowMissingVariables = false

err = m.buildAndResolveMappedDependencyOutputs(sourceData)
if err != nil {
return log.Errorf("unable to build and resolve mapped dependency outputs: %w", err)
if m.config.IsFeatureEnabled(experimental.FlagDependenciesV2) {
err = m.buildAndResolveMappedDependencyOutputs(sourceData)
if err != nil {
return log.Errorf("unable to build and resolve mapped dependency outputs: %w", err)
}
}

// Get the original yaml for the current step
Expand Down
Loading

0 comments on commit b002fa5

Please sign in to comment.