Skip to content

Commit

Permalink
Merge branch 'main' into docs-update-invocation-images
Browse files Browse the repository at this point in the history
Signed-off-by: Salman Shah <[email protected]>
  • Loading branch information
sbshah97 authored Jan 6, 2024
2 parents d7c8f0d + 8b74d90 commit db9cf41
Show file tree
Hide file tree
Showing 33 changed files with 844 additions and 298 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ and we will add you. **All** contributors belong here. 💯
- [Chaiyapruek Muangsiri](https://github.com/cmppoon)
- [Xin Fu](https://github.com/imfing)
- [KallyDev](https://github.com/kallydev)
- [Salman Shah](https://github.com/sbshah97)
- [Salman Shah](https://github.com/sbshah97)
- [Ray Terrill](https://github.com/rayterrill)
4 changes: 2 additions & 2 deletions build/testdata/bundles/mysql/porter.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
schemaVersion: 1.0.0
schemaVersion: 1.0.1
name: mysql
version: 0.1.4
registry: "localhost:5000"
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.4
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
2 changes: 0 additions & 2 deletions docs/content/blog/share-a-cloud-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ author: "@bdegeeter"
tags: ["cnab"]
---

# So, You Want to Share a Cloud Application?

by [Brian DeGeeter](https://github.com/bdegeeter) and [Steven Gettys](https://github.com/sgettys)

We've all been there. You've done all the work to create a GitHub repo with the code needed to show off some cool new cloud application architecture. We all know there's never one tool to rule them all. It's a bit of Terraform, a healthy dose of Ansible, and of course some Bash to connect it all together.
Expand Down
Original file line number Diff line number Diff line change
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/build/buildkit/buildx.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (b *Builder) BuildInvocationImage(ctx context.Context, manifest *manifest.M
}

bldr, err := builder.New(cli,
builder.WithName("default"),
builder.WithName(cli.CurrentContext()),
builder.WithContextPathHash(b.Getwd()),
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cnab/config-adapter/adapter_test.go
Original file line number Diff line number Diff line change
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
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
2 changes: 0 additions & 2 deletions pkg/cnab/config-adapter/testdata/myenv-depsv2.bundle.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

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.

Loading

0 comments on commit db9cf41

Please sign in to comment.