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

Shared Dependencies: the LOGIC #2940

Merged
merged 46 commits into from Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
da807ac
first pass of moving logic into extendedbundle
schristoff Sep 29, 2023
7bd5e56
refried bean candle
schristoff Oct 9, 2023
868bc57
if installation is found logic
schristoff Oct 9, 2023
4255504
basic logic done?
schristoff Oct 9, 2023
e0f95f1
still need to connect up params and creds, clean up mess, finish tests
schristoff Oct 19, 2023
cb0a29c
Merge branch 'main' into schristoff_depsresolvelogic
schristoff Oct 19, 2023
65e18d0
It was at this point I realized that my implementation is wrong :(
schristoff Oct 22, 2023
c1b72d8
Create executev2, and we're going to have to refactor execute normal …
schristoff Oct 22, 2023
967e3e7
okay a little bit prettier now
schristoff Oct 23, 2023
d6ee7f1
need to get integ working, but executev2 looks... ok?
schristoff Oct 23, 2023
337eb29
delete bundles-with-shared-deps
schristoff Oct 23, 2023
b0476d5
root wp bundle is failing
schristoff Oct 23, 2023
e3dfbeb
oh i was double copying
schristoff Oct 23, 2023
14d3d3f
failed to solve process /bin/sh -c apt-get update && apt get install …
schristoff Nov 10, 2023
3dcfca5
Removed 12 out of the 20 cping of the same dir. This integ test needs…
schristoff Nov 22, 2023
45751c3
error pulling dependency: unable to pull bundle: failed to resolve bu…
schristoff Nov 25, 2023
1c9d11d
forward progress
schristoff Nov 28, 2023
d8e0768
and it was all yellow
schristoff Nov 28, 2023
c5fd64b
turn in to something beautiful 🦋
schristoff Nov 28, 2023
74be873
you know i know you so <3
schristoff Nov 28, 2023
da90ff0
coldplay commits is a sign for bed 😑
schristoff Nov 28, 2023
f731b96
Look how they shine for you, and all the code that youuu miss ✨
schristoff Nov 28, 2023
0288257
Merge branch 'main' into schristoff_depsresolvelogic
schristoff Nov 28, 2023
3cfb6fb
install works, actual magic. bug is in uninstall now :(
schristoff Dec 3, 2023
2890b66
test didnt error? it just says ok? what does it mean??
schristoff Dec 3, 2023
97764e4
fix failing unit, we should only do stuff with shared parentless deps…
schristoff Dec 4, 2023
049e220
i think... its solid?
schristoff Dec 4, 2023
da9ddba
fix the old deps test
schristoff Dec 5, 2023
8a48525
weird integ fail
schristoff Dec 5, 2023
1025c60
ado plz
schristoff Dec 5, 2023
7e6908a
ADOnt work
schristoff Dec 5, 2023
1a352ff
Update pkg/cnab/extended_bundle.go
schristoff Dec 5, 2023
3a07f9f
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
1c290f6
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
6db3301
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
b0f14b1
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
9b3a652
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
542e670
Merge branch 'main' into schristoff_depsresolvelogic
schristoff Dec 5, 2023
d0a8a29
upgrade
schristoff Dec 5, 2023
059d1d4
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
7fa5ca0
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
3e041d6
Update docs/content/docs/development/authoring-a-bundle/working-with-…
schristoff Dec 5, 2023
c9a5a62
better error
schristoff Dec 5, 2023
6685c58
what is dependening
schristoff Dec 5, 2023
95fca4f
make doc make sense
schristoff Dec 5, 2023
b10deda
update mysql version everywhere
schristoff Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/testdata/bundles/mysql/porter.yaml
@@ -1,6 +1,6 @@
schemaVersion: 1.0.0
schemaVersion: 1.0.1
name: mysql
version: 0.1.4
version: 0.1.0
registry: "localhost:5000"

mixins:
Expand Down Expand Up @@ -57,7 +57,7 @@ uninstall:
- exec:
command: echo
arguments:
- uninstalled
- uninstall mysql

outputs:
- name: mysql-password
Expand Down
2 changes: 1 addition & 1 deletion build/testdata/bundles/wordpress/porter.yaml
@@ -1,4 +1,4 @@
schemaVersion: 1.0.0
schemaVersion: 1.0.1
name: wordpress
version: 0.1.4
registry: "localhost:5000"
Expand Down
14 changes: 14 additions & 0 deletions build/testdata/bundles/wordpressv2/helpers.sh
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

install() {
mkdir -p /cnab/app/outputs
echo "topsecret-blog" >> /cnab/app/outputs/wordpress-password
}

ping() {
echo ping
}

# Call the requested function and pass the arguments as-is
"$@"
80 changes: 80 additions & 0 deletions build/testdata/bundles/wordpressv2/porter.yaml
@@ -0,0 +1,80 @@
schemaVersion: 1.1.0
name: wordpress
version: 0.1.4
registry: "localhost:5000"

mixins:
- exec
- helm3:
repositories:
bitnami:
url: "https://charts.bitnami.com/bitnami"

dependencies:
requires:
- name: mysql
bundle:
reference: localhost:5000/mysql:v0.1.0
sharing:
mode: true
group:
name: myapp
parameters:
database-name: wordpress
mysql-user: wordpress
namespace: wordpress

credentials:
- name: kubeconfig
path: /home/nonroot/.kube/config

parameters:
- name: wordpress-name
type: string
default: porter-ci-wordpress
env: WORDPRESS_NAME
- name: wordpress-password
type: string
sensitive: true
applyTo:
- install
- upgrade
- name: namespace
type: string
default: 'wordpress'

install:
- exec:
command: ./helpers.sh
arguments:
- install

upgrade:
- exec:
command: ./helpers.sh
arguments:
- install

ping:
- exec:
description: "Ping"
command: ./helpers.sh
arguments:
- ping

uninstall:
- exec:
command: echo
arguments:
- uninstall wordpress

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
Expand Up @@ -29,6 +29,53 @@ dependencies:
reference: getporter/mysql:v0.1.3
```

## Define dependencies v2 (Shared)

The second version of dependencies -- also called "shared dependencies" or DependenciesV2 -- is available under the [**experimental** flag](https://porter.sh/docs/configuration/configuration/#experimental-feature-flags), and therefore an experimental feature. Please proceed with caution.

You can enable the experimental flag, thus enabling DependenciesV2, by setting an environment variable as follows:
```
PORTER_EXPERIMENTAL=dependencies-v2
```

The configuration for DependenciesV2 is similar to that of the first version, except there is now a "sharing" section with the following required fields: `mode`, `group.name`.
`mode` is a boolean, and `group.name` is the identifier that will allow for certain bundles to share parameters and outputs between each other.

```yaml
dependencies:
requires:
- name: mysql
bundle:
reference: localhost:5000/mysql:v0.1.0
sharing:
mode: true
group:
name: myapp
parameters:
database-name: wordpress
mysql-user: wordpress
namespace: wordpress
```

If there is an existing dependency installed that the parent bundle should connect to, you must create a label for the existing dependency with the `sh.porter.SharingGroup` key, with the value of the group name specified in the parent bundle.

The existing dependency **must** be successfully installed. If it is uninstalled this key must be deleted by the users before the operation can proceed.

```
porter install --label sh.porter.SharingGroup=myapp
```

There are some safeguards in place to make it so other bundles depending on the dependency cannot be broken, therefore on the following actions this will occur:

**Install**: For the parent bundle on existing dependency, the dependency arguments will be passed to the parent. No further changes.

**Upgrade**: The parent bundle will execute the upgrade action, but it will not change anything about the existing dependency.

**Invoke**: Any changes that happen here **will** change the existing dependency. It will be on the user to handle propagating those changes to other parent bundles if needed.

**Uninstall**: The parent bundle will be uninstalled, but the existing dependency will not be and needs to be uninstalled in a separate command.


## Ordering of dependencies

If more than one dependency is declared, they will be installed in the order they are listed. For example, if both the `mysql` and
Expand Down
2 changes: 1 addition & 1 deletion pkg/cnab/config-adapter/adapter_test.go
Expand Up @@ -676,7 +676,7 @@ func TestManifestConverter_generateDependenciesv2(t *testing.T) {
},
},
Sharing: depsv2ext.SharingCriteria{
Mode: depsv2ext.SharingModeGroup,
Mode: true,
Group: depsv2ext.SharingGroup{Name: "myapp"},
},
Parameters: map[string]string{
Expand Down
Expand Up @@ -453,7 +453,6 @@
"db": {
"bundle": "localhost:5000/mydb:v0.1.0",
"sharing": {
"mode": "group",
"group": {}
},
"parameters": {
Expand Down
2 changes: 0 additions & 2 deletions pkg/cnab/config-adapter/testdata/myenv-depsv2.bundle.json
Expand Up @@ -137,7 +137,6 @@
"app": {
"bundle": "localhost:5000/myapp:v1.2.3",
"sharing": {
"mode": "group",
"group": {}
},
"parameters": {
Expand All @@ -153,7 +152,6 @@
"infra": {
"bundle": "localhost:5000/myinfra:v0.1.0",
"sharing": {
"mode": "group",
"group": {}
},
"parameters": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cnab/config-adapter/testdata/porter-with-depsv2.yaml
Expand Up @@ -26,7 +26,7 @@ dependencies:
description: "credential"
required: true
sharing:
mode: group
mode: true
group:
name: myapp
parameters:
Expand Down
2 changes: 0 additions & 2 deletions pkg/cnab/dependencies/v1/doc.go
schristoff marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/cnab/dependencies/v1/installations.go

This file was deleted.

117 changes: 0 additions & 117 deletions pkg/cnab/dependencies/v1/solver.go

This file was deleted.