Skip to content

Commit

Permalink
Merge pull request #1629 from chira99/dev
Browse files Browse the repository at this point in the history
Update "Add Connection Configuration" Section for New Component.yaml Descriptor Files
  • Loading branch information
Nashaath authored Oct 31, 2024
2 parents ae8e85c + 25e5601 commit 070959b
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 39 deletions.
1 change: 1 addition & 0 deletions en/.spelling
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buildpacks
Temurin
RabbitMQ
SalesOrderQueue
v1.1
1.x
12.x.x
14.x.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,63 +12,127 @@ You can consume a Choreo-deployed service within another service. Consuming conn

### Step 1: Add connection configurations

To integrate another service into your application, follow the steps below:
To integrate another service into your application, click the appropriate tab below based on your current configuration file and follow the step-by-step instructions:

1. Copy and paste the snippet from the in-line developer guide into the `component-config` file under the `spec` section.
=== "Component.yaml file"

1. Copy and paste the snippet from the in-line developer guide into the `component.yaml` file.
The following is a sample snippet:

The following is a sample snippet:
``` yaml

``` yaml
dependencies:
serviceReferences:
- name: <SERVICE_NAME>
connectionConfig: <CONNECTION_ID>
env:
- from: ServiceURL
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: ConsumerKey
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: ConsumerSecret
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: TokenURL
to: <YOUR_ENV_VARIABLE_NAME_HERE>

outbound:
serviceReferences:
- name: <SERVICE_NAME>
connectionConfig: <CONNECTION_ID>
env:
- from: ServiceURL
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: ConsumerKey
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: ConsumerSecret
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: TokenURL
to: <YOUR_ENV_VARIABLE_NAME_HERE>
```

| Field | Description |
|------------------|-------------------------------------------------------------|
| name | The name of the service you are connecting to. |
| connectionConfig | The unique connection identifier for the connection. |
| env | The environment variable mapping. |
| from | The key of the configuration entry. |
| to | The environment variable name to which Choreo will inject the value of the key.|


2. Replace `<YOUR_ENV_VARIABLE_NAME_HERE>` with an appropriate environment variable name of your choice. If you have previously added a service reference section under `dependencies`, append this as another item under `serviceReferences`.

Upon deploying the component, Choreo automatically creates a subscription if applicable and populates the specified environment variables with actual values.


The following table provides details on the configuration keys associated with the connection:

| Name | Type | Description |Optional | Sensitive |
|----------------|------------|---------------------------------------|---------------|--------------|
| ServiceURL | string | Service URL of the Choreo service | false | false |
| ConsumerKey | string | Consumer key of the Choreo service | false | false |
| ConsumerSecret | string | Consumer secret of the Choreo service | false | true |
| TokenURL | string | Token URL of the STS | false | false |

### Step 2: Read configurations within the application

Once you add the connection configuration snippet, you can proceed to read those configurations within your application. The steps to follow depend on the programming language you are using.

The following is a sample code snippet in NodeJS:

``` java
const serviceURL = process.env.SVC_URL;
```

| Field | Description |
|------------------|-------------------------------------------------------------|
| Name | The name of the service you are connecting to. |
| ConnectionConfig | The unique connection identifier for the connection. |
| env | The environment variable mapping. |
| from | The key of the configuration entry. |
| to | The environment variable name to which Choreo will inject the value of the key.|

=== "Component-config.yaml file"

2. Replace `<YOUR_ENV_VARIABLE_NAME_HERE>` with an appropriate environment variable name of your choice. If you have previously added an outbound service reference, append this as another item under `serviceReferences`.
!!! note
This `component-config.yaml` is a legacy configuration format. For new projects, we recommend using `component.yaml` for improved usability and features.

Upon deploying the component, Choreo automatically creates a subscription if applicable and populates the specified environment variables with actual values.
1. Copy and paste the snippet from the in-line developer guide into the `component-config` file under the `spec` section.

The following is a sample snippet:

The following table provides details on the configuration keys associated with the connection:
``` yaml

| Name | Type | Description |Optional | Sensitive |
|----------------|------------|---------------------------------------|---------------|--------------|
| ServiceURL | string | Service URL of the Choreo service | false | false |
| ConsumerKey | string | Consumer key of the Choreo service | false | false |
| ConsumerSecret | string | Consumer secret of the Choreo service | false | true |
| TokenURL | string | Token URL of the STS | false | false |
outbound:
serviceReferences:
- name: <SERVICE_NAME>
connectionConfig: <CONNECTION_ID>
env:
- from: ServiceURL
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: ConsumerKey
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: ConsumerSecret
to: <YOUR_ENV_VARIABLE_NAME_HERE>
- from: TokenURL
to: <YOUR_ENV_VARIABLE_NAME_HERE>

```

### Step 2: Read configurations within the application
| Field | Description |
|------------------|-------------------------------------------------------------|
| name | The name of the service you are connecting to. |
| connectionConfig | The unique connection identifier for the connection. |
| env | The environment variable mapping. |
| from | The key of the configuration entry. |
| to | The environment variable name to which Choreo will inject the value of the key.|

Once you add the connection configuration snippet, you can proceed to read those configurations within your application. The steps to follow depend on the programming language you are using.

The following is a sample code snippet in NodeJS:
2. Replace `<YOUR_ENV_VARIABLE_NAME_HERE>` with an appropriate environment variable name of your choice. If you have previously added an outbound service reference, append this as another item under `serviceReferences`.

Upon deploying the component, Choreo automatically creates a subscription if applicable and populates the specified environment variables with actual values.


The following table provides details on the configuration keys associated with the connection:

| Name | Type | Description |Optional | Sensitive |
|----------------|------------|---------------------------------------|---------------|--------------|
| ServiceURL | string | Service URL of the Choreo service | false | false |
| ConsumerKey | string | Consumer key of the Choreo service | false | false |
| ConsumerSecret | string | Consumer secret of the Choreo service | false | true |
| TokenURL | string | Token URL of the STS | false | false |

<h3> Step 2: Read configurations within the application </h3>

Once you add the connection configuration snippet, you can proceed to read those configurations within your application. The steps to follow depend on the programming language you are using.

The following is a sample code snippet in NodeJS:

``` java
const serviceURL = process.env.SVC_URL;
```


``` java
const serviceURL = process.env.SVC_URL;
```

### Step 3: Acquire an OAuth 2.0 access token

Expand Down

0 comments on commit 070959b

Please sign in to comment.