Skip to content

Commit

Permalink
Nest Interface Policy under interface field (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok authored Feb 4, 2022
1 parent c2ca803 commit ece1019
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 288 deletions.
41 changes: 21 additions & 20 deletions docs/content-development/generating.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This document describes how to generate Manifests from existing Helm Charts and
- [Capact CLI](../cli/getting-started.mdx#install) at least v0.5.0 installed.
> **NOTE:** Install the latest Capact CLI version from the `main` branch.
- Capact cluster. For example, [local instance](../installation/local.mdx).

> **NOTE:** Use `--capact-overrides=hub-public.populator.enabled=false` flag, as you will manually upload your OCF manifests into Hub.
## Generating Interface
Expand Down Expand Up @@ -358,7 +358,7 @@ To test generated manifests you need to:
cat > /tmp/install-input.yaml << ENDOFFILE
input-parameters:
name: redis-test
ENDOFFILE
```

Expand All @@ -377,24 +377,25 @@ To test generated manifests you need to:
AWS_VPC_ID="{Your VPC ID}"
AWS_SUBNET_ID="{Your VPC subnet id}"
cat > /tmp/aws-policy.yaml << ENDOFFILE
rules:
- interface:
path: cap.interface.database.redis.install
oneOf:
- implementationConstraints:
path: "cap.implementation.aws.redis.install"
inject:
requiredTypeInstances:
- id: "${AWS_TI_ID}"
description: "AWS credentials"
additionalParameters:
- name: additional-parameters
value:
vpc_id: "${AWS_VPC_ID}"
subnet_ids:
- "${AWS_SUBNET_ID}"
number_cache_clusters: 1
node_type: cache.t3.small
interface:
rules:
- interface:
path: cap.interface.database.redis.install
oneOf:
- implementationConstraints:
path: "cap.implementation.aws.redis.install"
inject:
requiredTypeInstances:
- id: "${AWS_TI_ID}"
description: "AWS credentials"
additionalParameters:
- name: additional-parameters
value:
vpc_id: "${AWS_VPC_ID}"
subnet_ids:
- "${AWS_SUBNET_ID}"
number_cache_clusters: 1
node_type: cache.t3.small
ENDOFFILE
```

Expand Down
25 changes: 13 additions & 12 deletions docs/content-development/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ metadata:
spec:
input:
parameters: # the Interface requires `input-parameters` of Type "cap.type.productivity.mattermost.install-input"
input-parameters:
input-parameters:
typeRef:
name: cap.type.productivity.mattermost.install-input
revision: 0.1.0

output:
typeInstances: # the Interface outputs TypeInstance of Type "cap.type.productivity.mattermost.config"
mattermost-config:
mattermost-config:
typeRef:
path: cap.type.productivity.mattermost.config
revision: 0.1.0
Expand Down Expand Up @@ -442,7 +442,7 @@ spec:
path: "/"
annotations:
"cert-manager.io/cluster-issuer": letsencrypt
hosts:
hosts:
- <@ host | default("mattermost.example.com") @>
tls:
- hosts:
Expand Down Expand Up @@ -549,13 +549,14 @@ Let's go through the **Implementation** and try to understand, what is happening
> name: install-db
> capact-when: postgresql == nil
> capact-policy:
> rules:
> - interface:
> path: cap.interface.database.postgresql.install
> oneOf:
> - implementationConstraints:
> path: "cap.implementation.bitnami.postgresql.install
> ```
> interface:
> rules:
> - interface:
> path: cap.interface.database.postgresql.install
> oneOf:
> - implementationConstraints:
> path: "cap.implementation.bitnami.postgresql.install
> ```
> You can read more about policies on the [Policy overview](../feature/policies/overview.md) page.

In the next step we are creating a database for the Mattermost server. If you look at the **Interface** definition of [`cap.interface.database.postgresql.create-db`](https://github.com/capactio/hub-manifests/tree/main/manifests/interface/database/postgresql/create-db.yaml), you will see, that it requires a `postgresql` **TypeInstance** of **Type** [`cap.type.database.postgresql.config`](https://github.com/capactio/hub-manifests/tree/main/manifests/type/database/postgresql/config.yaml) and input parameters [`cap.type.database.postgresql.database-input`](https://github.com/capactio/hub-manifests/tree/main/manifests/type/database/postgresql/database-input.yaml), and outputs a `database` **TypeInstance** of **Type** [`cap.type.database.postgresql.database`](https://github.com/capactio/hub-manifests/tree/main/manifests/type/database/postgresql/database.yaml). In the step, we are providing the inputs to the **Interface** via the `.arguments.artifacts` field. We also have to map the output of this step to our output definitions in `additionalOutput` and the implemented **Interface** in the `capact-outputTypeInstances` field.
Expand Down Expand Up @@ -599,7 +600,7 @@ After we have the manifests ready, we can start our local Capact environment. Fo
capact install --capact-overrides=hub-public.populator.enabled=false
```

This can take a few minutes. Next, [populate the manifests to Public Hub](../example/public-hub-content.mdx#populate-the-manifests-into-hub).
This can take a few minutes. Next, [populate the manifests to Public Hub](../example/public-hub-content.mdx#populate-the-manifests-into-hub).

## Create and run your Action

Expand All @@ -609,7 +610,7 @@ Use the Capact CLI to run your Action.

```bash
export CAPACT_DOMAIN_NAME={domain_name} # e.g. capact.local
```
```

1. Create a file with installation parameters:

Expand Down
29 changes: 15 additions & 14 deletions docs/content-development/terraform-manifests.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes how to prepare content which uses Terraform Runner.

- [MinIO client](https://min.io/download)
- [Capact local cluster](../installation/local.mdx)

> **NOTE:** Use `--capact-overrides=hub-public.populator.enabled=false` flag, as you will manually upload your OCF manifests into Hub.
## MinIO access configuration
Expand Down Expand Up @@ -80,7 +80,7 @@ In this example, we have them all already defined for PostgreSQL installation. T
- [InterfaceGroup](https://github.com/capactio/hub-manifests/tree/main/manifests/interface/database/postgresql.yaml)
- [Interface](https://github.com/capactio/hub-manifests/tree/main/manifests/interface/database/postgresql/install.yaml)
- [Implementation](https://github.com/capactio/hub-manifests/blob/main/manifests/implementation/gcp/cloudsql/postgresql/install-0.2.0.yaml). The manifest uses Terraform Runner.
Instead of using GCS as module source, you can use internal MinIO URL, such as `http://argo-minio.argo:9000/terraform/cloudsql/cloudsql.tgz`.
- [Input Type](https://github.com/capactio/hub-manifests/tree/main/manifests/type/database/postgresql/install-input.yaml)
Expand All @@ -99,16 +99,17 @@ To make sure the Terraform-based Implementation is selected, you may use additio
```yaml
# (...)
rules:
cap.interface.database.postgresql.install:
oneOf:
- implementationConstraints:
attributes:
- path: "cap.attribute.cloud.provider.gcp"
- path: "cap.attribute.infra.iac.terraform" # Add this line
requires:
- path: "cap.type.gcp.auth.service-account"
inject:
requiredTypeInstances:
# (...)
interface:
rules:
cap.interface.database.postgresql.install:
oneOf:
- implementationConstraints:
attributes:
- path: "cap.attribute.cloud.provider.gcp"
- path: "cap.attribute.infra.iac.terraform" # Add this line
requires:
- path: "cap.type.gcp.auth.service-account"
inject:
requiredTypeInstances:
# (...)
```
Loading

0 comments on commit ece1019

Please sign in to comment.