Skip to content

Commit

Permalink
forward progress
Browse files Browse the repository at this point in the history
Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com>
  • Loading branch information
schristoff committed Nov 28, 2023
1 parent 45751c3 commit 1c9d11d
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 79 deletions.
20 changes: 10 additions & 10 deletions build/testdata/bundles/wordpress/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ uninstall:
arguments:
- uninstalled

outputs:
- name: wordpress-password
description: "The Wordpress installation password"
type: string
default: "default-password"
applyTo:
- "install"
- "upgrade"
sensitive: true
path: /cnab/app/outputs/wordpress-password
# outputs:
# - name: wordpress-password
# description: "The Wordpress installation password"
# type: string
# default: "default-password"
# applyTo:
# - "install"
# - "upgrade"
# sensitive: true
# path: /cnab/app/outputs/wordpress-password
5 changes: 2 additions & 3 deletions build/testdata/bundles/wordpressv2/porter.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
schemaVersion: 1.0.1
schemaVersion: 1.1.0
name: wordpress
version: 0.1.4
registry: "localhost:5000"
Expand All @@ -14,8 +14,7 @@ dependencies:
requires:
- name: mysql
bundle:
reference: localhost:5000/mysql
version: v0.1.0
reference: localhost:5000/mysql:v0.1.0
sharing:
mode: true
group:
Expand Down
1 change: 0 additions & 1 deletion pkg/cnab/config-adapter/testdata/mybuns-depsv2.bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@
"db": {
"bundle": "localhost:5000/mydb:v0.1.0",
"sharing": {
"mode": "group",
"group": {}
},
"parameters": {
Expand Down
3 changes: 3 additions & 0 deletions pkg/cnab/dependencies_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func (b ExtendedBundle) DependencyV2Reader() (interface{}, error) {
return nil, fmt.Errorf("could not marshal the untyped %s extension data %q: %w", DependenciesV2ExtensionKey, string(dataB), err)
}

//Note: For depedency.Name to be set properly ReadDependencyV2
// *must* be called.
//todo: make it so that ReadDependencyV2 is only able to be exported.
deps := v2.Dependencies{}
err = json.Unmarshal(dataB, &deps)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cnab/extended_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ func (b *ExtendedBundle) ResolveSharedDeps(bun ExtendedBundle) ([]DependencyLock
}

q := make([]DependencyLock, 0, len(v2.Requires))
for _, d := range v2.Requires {
for name, d := range v2.Requires {
d.Name = name

//todo(schristoff): We should 100% move this logic into
// the bundle validator area
Expand Down
3 changes: 2 additions & 1 deletion pkg/porter/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ func (e *dependencyExecutioner) identifyDependencies(ctx context.Context) error
}

bun = cachedBundle.Definition

} else if e.parentOpts.Name != "" {

c, err := e.Installations.GetLastRun(ctx, e.parentOpts.Namespace, e.parentOpts.Name)
if err != nil {
return err
Expand Down Expand Up @@ -317,7 +319,6 @@ func (e *dependencyExecutioner) executeDependencyv2(ctx context.Context, dep *qu
if err != nil {
if errors.Is(err, storage.ErrNotFound{}) {
depInstallation = storage.NewInstallation(e.parentOpts.Namespace, dep.Alias)
//tood(schristoff): not sure if we still want to have parents here
depInstallation.SetLabel("sh.porter.parentInstallation", e.parentArgs.Installation.String())
depInstallation.SetLabel("sh.porter.SharingGroup", dep.SharingGroup)

Expand Down
63 changes: 0 additions & 63 deletions tests/integration/dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"

"get.porter.sh/porter/pkg/cnab"
"get.porter.sh/porter/pkg/experimental"
"get.porter.sh/porter/pkg/porter"
"get.porter.sh/porter/pkg/secrets"
"get.porter.sh/porter/pkg/storage"
Expand Down Expand Up @@ -246,33 +245,6 @@ func uninstallWordpressBundle(ctx context.Context, p *porter.TestPorter, namespa

}

func TestSharedDependencies(t *testing.T) {
t.Parallel()

p := porter.NewTestPorter(t)
p.Config.SetExperimentalFlags(experimental.FlagDependenciesV2)

bunDir, err := os.MkdirTemp("", "porter-mysqlv2-")
require.NoError(p.T(), err, "could not create temp directory at all")

defer os.RemoveAll(bunDir)

mysqldir := p.AddTestBundleDir(p.RepoRoot+"/build/testdata/bundles/mysql", false)

wpdir := p.AddTestBundleDir(p.RepoRoot+"/build/testdata/bundles/wordpress", false)
ctx := p.SetupIntegrationTest()

namespace := p.RandomString(10)
p.Chdir(mysqldir)
publishMySQLBundle(ctx, p)

installMySQLbundle(ctx, p, namespace)

p.Chdir(wpdir)
installWordpressBundlev2(ctx, p, namespace, "mysql")

}

func installMySQLbundle(ctx context.Context, p *porter.TestPorter, namespace string) {
p.CopyDirectory(filepath.Join(p.RepoRoot, "build/testdata/bundles/mysql"), ".", false)
installOpts := porter.NewInstallOptions()
Expand All @@ -292,38 +264,3 @@ func installMySQLbundle(ctx context.Context, p *porter.TestPorter, namespace str
mysqlinst.SetLabel("sh.porter.SharingGroup", "myapp")

}

func installWordpressBundlev2(ctx context.Context, p *porter.TestPorter, namespace string, mysqlName string) {

// Install the bundle that has dependencies
err := p.CopyDirectory(filepath.Join(p.RepoRoot, "build/testdata/bundles/wordpressv2"), ".", false)
require.NoError(p.T(), err, "copy of build/testdata/bundles/wordpressv2 failed")

namespace = p.RandomString(10)
installOpts := porter.NewInstallOptions()
installOpts.Namespace = namespace
installOpts.CredentialIdentifiers = []string{"ci"} // Use the ci credential set, porter should remember this for later
installOpts.Params = []string{
"wordpress-password=mypassword",
"namespace=" + namespace,
"mysql#namespace=" + namespace,
}

// Add a supplemental parameter set to vet dep param resolution
installOpts.ParameterSets = []string{"myparam"}
testParamSets := storage.NewParameterSet(namespace, "myparam", secrets.SourceMap{
Name: "mysql#probe-timeout",
Source: secrets.Source{
Strategy: host.SourceValue,
Hint: "2",
},
})

p.TestParameters.InsertParameterSet(ctx, testParamSets)

err = installOpts.Validate(ctx, []string{}, p.Porter)
require.NoError(p.T(), err, "validation of install opts for root bundle failed")

err = p.InstallBundle(ctx, installOpts)
require.NoError(p.T(), err, "install of root bundle failed namespace %s", namespace)
}
Loading

0 comments on commit 1c9d11d

Please sign in to comment.