Skip to content

Commit

Permalink
Merge remote-tracking branch 'internal/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
jvallexm committed Feb 28, 2024
2 parents 234ac65 + b5a83d9 commit 8a89c88
Show file tree
Hide file tree
Showing 34 changed files with 1,575 additions and 537 deletions.
27 changes: 24 additions & 3 deletions .docs/craig-code-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,38 @@ The Code Engine image build and application settings can be used to manage the C
### Background
You can bring your own existing Power VS workspace into CRAIG which allows you to choose custom images for Power VSIs.

The IBM Code Engine deployment script will automatically create Power VS workspaces for CRAIG use when using the `-z` parameter. The script also allows specifying environment variables with the workspace IDs in a file with the `-e` parameter. In both cases the Power VS workspace zones and corresponding workspace IDs are placed in a Code Engine configmap.
The IBM Code Engine deployment script will automatically create Power VS workspaces in every Power VS zone worldwide for CRAIG's use when using the `-z` parameter.

If you do not want Power VS workspaces created in every zone, you can create the Power VS Workspaces in your chosen zone(s) using the Clould console, CLI, or other means. The [generate-env.sh](../generate-env.sh) script can generate an environment file that can be used with the `deploy.sh` script to configure CRAIG to use the workspaces.

#### generate-env.sh prerequisites
- [jq](https://jqlang.github.io/jq/) v1.7 or higher
- ibmcloud CLI
- Bash version 4 or higher

To generate an env containing all of the workspaces in your account, you can run the following command:

```
./generate-env.sh env
```

The `env` file should then be modified to remove or comment out any workspaces that CRAIG should not use, and to ensure it contains only one workspace per zone.

The `env` file can then be used on the `deploy.sh` script:

```
./deploy.sh -e env
```

### Modifying the configmap
If you want to bring your own workspace after CRAIG deployment in Code Engine you can update the configmap with the GUID of your workspace.

To find the GUIDs and locations of your workspaces, the following IBM Cloud CLI command can be run in a terminal window or an IBM Cloud Shell:
To find the GUIDs and locations of your workspaces, the following IBM Cloud CLI command can be run in a terminal window or an IBM Cloud Shell:

```
ibmcloud resource service-instances --service-name power-iaas --output json | jq -r '.[]? | "\(.guid), \(.name), \(.region_id)"'
```

To modify the configmap to add your workspace GUID, click on `Secrets and configmaps` on left navigation pane of the Code Engine project. Click on the `craig-env` Configmap. Find the key that matches your workspace's zone and set your workspace's GUID as the value for the key. Click the `Save` button. The CRAIG instance can then be [redeployed](#redeploying-the-craig-instance) to pick up the configmap change.

If CRAIG was deployed without specifying `-z` or `-e`, a configmap can be manually created and set with the correct key-value for the zone. See the [.example.env](../.example.env) for the possible keys and the [IBM Code Engine documentation](https://cloud.ibm.com/docs/codeengine?topic=codeengine-configmap) for how to create the configmap and add the reference to the `craig` application.
If CRAIG was deployed without specifying `-z` or `-e`, a configmap can be manually created and set with the correct key-value for the zone. See the [.env.example](../.env.example) for the possible keys and the [IBM Code Engine documentation](https://cloud.ibm.com/docs/codeengine?topic=codeengine-configmap) for how to create the configmap and add the reference to the `craig` application.
18 changes: 10 additions & 8 deletions .docs/power-vs-workspace-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To dynamically fetch Power VS images and storage pools within CRAIG, the IBM Pow

## Automated Deployment

The `terraform.sh` script found in the `/deploy` folder of the CRAIG root directory provisions a Power VS Workspace in each zone and sets the needed environment variables with the format of `POWER_WORKSPACE_<zone>=<workspace-guid>`.
The `terraform.sh` script found in the `/deploy` folder of the CRAIG root directory provisions a Power VS Workspace in each zone worldwide and sets the needed environment variables with the format of `POWER_WORKSPACE_<zone>=<workspace-guid>`.

Use the following command to run the script:
```shell
Expand All @@ -26,16 +26,18 @@ This will produce a file named `.env` that can be passed to the `deploy.sh` scri

#### Bring Your Own Workspace

To bring your own Power VS Workspace into CRAIG to fetch images, you will need to set a field in your `.env` with the following format. To see an example, see [.env.example](../.env.example)
If you do not want Power VS workspaces created in every zone or if you want to use custom images you can bring your own Power VS Workspace into CRAIG. The [generate-env.sh](../generate-env.sh) script can generate a `.env` environment file containing all of the workspaces in your account.

```
POWER_WORKSPACE_<zone-of-workspace>=<workspace-guid>
```
#### generate-env.sh prerequisites
- [jq](https://jqlang.github.io/jq/) v1.7 or higher
- [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cli-getting-started)
- Bash version 4 or higher

To find the GUIDs and locations of your workspaces, the following IBM Cloud CLI command can be run in a terminal window or an IBM Cloud Shell:
To generate a `.env` file containing all of the workspaces in your account, you can run the following command:

```
ibmcloud resource service-instances --service-name power-iaas --output json | jq -r '.[]? | "\(.guid), \(.name), \(.region_id)"'
./generate-env.sh .env
```

*For instructions on how to install the IBM Cloud CLI, click [here](https://cloud.ibm.com/docs/cli?topic=cli-getting-started)*
The `.env` file should then be modified to remove or comment out any workspaces that CRAIG should not use, and to ensure it contains only one workspace per zone. The `API_KEY` key and value should also be added to the file, see [.env.example](../.env.example) for more information.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file.

## 1.12.1

### Upgrade Notes


### Features

- Users can now use the `Trial` plan for secrets manager

### Fixes

- Fixed an issue causing the VPN Server page to crash when opening the creation modal

## 1.12.0

### Upgrade Notes
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,19 @@ chmod 755 deploy.sh

By default the script will securely prompt you for your API key. It may also be read from an environment variable or specified as a command line argument. See the `deploy.sh -h` usage for more information.

If CRAIG is used for Power VS configuration, the Power VS workspaces must be created. The deploy script can create the Power Virtual Server workspaces and automatically integrate them with the CRAIG deployment. The deploy script uses a Schematics workspace and Terraform to drive the creation and deletion of the Power Virtual Server workspaces. Specify the `-z` parameter to automatically create the Power Virtual Server workspaces:
If CRAIG is used for Power VS configuration, Power VS workspaces must exist in the zones that CRAIG projects will use. The deploy script can create the Power Virtual Server workspaces in every Power VS zone worldwide and automatically integrate them with the CRAIG deployment. The deploy script uses a Schematics workspace and Terraform to drive the creation and deletion of the Power Virtual Server workspaces. Specify the `-z` parameter to automatically create the Power Virtual Server workspaces:

```bash
./deploy.sh -z
```

If CRAIG is used for Power VS configuration and you do not want Power VS workspaces created in every zone, you can bring your own existing Power VS workspace into CRAIG. This also allows you to choose custom images for Power VSIs. See [Bring Your Own Power VS Workspace](.docs/craig-code-engine.md#bring-your-own-power-vs-workspace) for more information.

If CRAIG will not be used for Power VS configuration, `deploy.sh` can be run without parameters to deploy CRAIG into Code Engine:

```bash
./deploy.sh
```

You can bring your own existing Power VS workspace into CRAIG which allows you to choose custom images for Power VSIs. To bring your own workspace you can update the Code Engine configuration after deployment. See [Bring Your Own Power VS Workspace](.docs/craig-code-engine.md#bring-your-own-power-vs-workspace) for more information.

For the full list of parameters which allows full customization of the IBM Code Engine deployment, specify the `-h` parameter:

```
Expand Down
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "craig",
"version": "1.12.0",
"version": "1.12.1",
"private": true,
"license": "Apache-2.0",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/pages/CraigForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,9 @@ function craigForms(craig) {
{
name: craig.secrets_manager.name,
resource_group: craig.secrets_manager.resource_group,
},
{
plan: craig.secrets_manager.plan,
encryption_key: craig.secrets_manager.encryption_key,
},
],
Expand Down
8 changes: 8 additions & 0 deletions client/src/lib/docs/release-notes.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"version": "1.12.1",
"features": ["Users can now use the `Trial` plan for secrets manager"],
"fixes": [
"Fixed an issue causing the VPN Server page to crash when opening the creation modal"
],
"upgrade_notes": []
},
{
"version": "1.12.0",
"features": [
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/forms/dynamic-form-fields/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function dynamicSelectProps(props, isMounted, stateData) {

// state value
let stateValue = props.field.onRender
? props.field.onRender(props.parentState)
? props.field.onRender(props.parentState, props.parentProps)
: props.parentState[props.name];

let groups = groupsEvaluatesToArrayCheck(
Expand Down
28 changes: 2 additions & 26 deletions client/src/lib/forms/filters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { distinct, contains, isEmpty } = require("lazy-z");
const { contains, isEmpty } = require("lazy-z");

/**
* Filters docs obj to render defaults for specific template only.
Expand Down Expand Up @@ -40,28 +40,4 @@ function filterDocs(template, field, docs) {
return doc;
}

/*
* filter vpcs with connections to extant tgws
* @param {*} craig
* @returns {Array<string>} list of vpcs not currently
*/
function tgwVpcFilter(craig) {
let unconnectedVpcs = [];
let allTgwVpcs = [];
craig.store.json.transit_gateways.forEach((tgw) => {
let connectionVpcs = [];
tgw.connections.forEach((connection) => {
if (connection.vpc) {
// not using splat to avoid picking up `null` for crn connections
connectionVpcs.push(connection.vpc);
}
});
allTgwVpcs = distinct(allTgwVpcs.concat(connectionVpcs));
});
craig.store.vpcList.forEach((vpc) => {
if (!contains(allTgwVpcs, vpc)) unconnectedVpcs.push(vpc);
});
return unconnectedVpcs;
}

module.exports = { filterDocs, tgwVpcFilter };
module.exports = { filterDocs };
2 changes: 0 additions & 2 deletions client/src/lib/forms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const {
const {
invalidName,
validSshKey,
invalidTagList,
invalidCrnList,
invalidSubnetTierName,
invalidNewResourceName,
Expand Down Expand Up @@ -62,7 +61,6 @@ module.exports = {
disableSave,
invalidNameText,
validSshKey,
invalidTagList,
invalidSubnetTierName,
invalidSubnetTierText,
formatConfig,
Expand Down
19 changes: 0 additions & 19 deletions client/src/lib/forms/invalid-callbacks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const {
splat,
getObjectFromArray,
isNullOrEmptyString,
contains,
containsKeys,
Expand Down Expand Up @@ -32,22 +30,6 @@ function invalidNewResourceName(str) {
return str ? str.match(newResourceNameExp) === null : true;
}

/**
* invalid tags
* @param {Array<string>} tags list of tags
* @returns {boolean} true if any tags in list are invalid
*/
function invalidTagList(tags) {
if (!tags || tags.length === 0) return false;
let invalid = false;
tags.forEach((tag) => {
if (tag.match(newResourceNameExp) === null || tag.length > 128) {
invalid = true;
}
});
return invalid;
}

/**
* create invalid bool for resource
* @param {string} field json field name
Expand Down Expand Up @@ -492,7 +474,6 @@ function invalidCrns(stateData) {
module.exports = {
invalidName,
invalidNewResourceName,
invalidTagList,
invalidCrnList,
validSshKey,
invalidSubnetTierName,
Expand Down
2 changes: 0 additions & 2 deletions client/src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {
disableSave,
invalidNameText,
validSshKey,
invalidTagList,
invalidSubnetTierName,
invalidSubnetTierText,
formatConfig,
Expand Down Expand Up @@ -194,7 +193,6 @@ module.exports = {
disableSave,
invalidNameText,
validSshKey,
invalidTagList,
invalidSubnetTierName,
invalidSubnetTierText,
formatConfig,
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/json-to-iac/secrets-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function ibmResourceInstanceSecretsManager(secretsManager, config) {
: {
name: kebabName([secretsManager.name]),
location: varDotRegion,
plan: "standard",
plan: secretsManager.plan ? secretsManager.plan : "standard",
service: "secrets-manager",
resource_group_id: rgIdRef(secretsManager.resource_group, config),
parameters: {
Expand Down
3 changes: 2 additions & 1 deletion client/src/lib/state/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ const {
encryptionKeyGroups,
onArrayInputChange,
fieldIsNotWholeNumber,
invalidTagList,
} = require("./utils");
const { invalidName, invalidNameText, invalidTagList } = require("../forms");
const { invalidName, invalidNameText } = require("../forms");
const { invalidDescription } = require("../forms/invalid-callbacks");

/**
Expand Down
2 changes: 0 additions & 2 deletions client/src/lib/state/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const state = require("./state");
const { storageChangeDisabledCallback } = require("./utils");

module.exports = {
state,
storageChangeDisabledCallback,
};
4 changes: 2 additions & 2 deletions client/src/lib/state/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const {
buildNumberDropdownList,
titleCase,
contains,
isNullOrEmptyString,
} = require("lazy-z");
const { subnetTierSave } = require("./vpc/vpc");
const { RegexButWithWords } = require("regex-but-with-words");
const { invalidNewResourceName, invalidTagList } = require("../forms");
const { invalidNewResourceName } = require("../forms");
const releaseNotes = require("../docs/release-notes.json");
const {
shouldDisableComponentSave,
Expand All @@ -18,6 +17,7 @@ const {
selectInvalidText,
kebabCaseInput,
onArrayInputChange,
invalidTagList,
} = require("./utils");

const powerVsZones = [
Expand Down
Loading

0 comments on commit 8a89c88

Please sign in to comment.