Skip to content

Commit

Permalink
feat: Root module updates:<br>- name input has changed to `namespa…
Browse files Browse the repository at this point in the history
…ce_name`<br>- supported added to configure an existing namespace using new input `existing_namespace_name`<br>- A new `quotas` submodule has been added for configuring namespace quotas<br>- A new Deployable Architecutre has been created for IBM Cloud catalog (#208)
  • Loading branch information
Soaib024 authored Nov 29, 2024
1 parent 7ec0453 commit bf49fb9
Show file tree
Hide file tree
Showing 41 changed files with 1,081 additions and 49 deletions.
14 changes: 14 additions & 0 deletions .catalog-onboard-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
offerings:
- name: deploy-arch-ibm-container-registry
kind: solution
catalog_id: 7df1e4ca-d54c-4fd0-82ce-3d13247308cd
offering_id: 5947efd7-d52a-4905-8052-45f1142f78a0
variations:
- name: standard
mark_ready: true
install_type: fullstack
scc:
instance_id: 1c7d5f78-9262-44c3-b779-b28fe4d88c37
region: us-south
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Primary owner should be listed first in list of global owners, follwed by any secondary owners

* @shemau @daniel-butler-irl
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ repository:

# Uncomment this topics property
# and add a comma-separated list of topics to set on the repo.
topics: core-team, terraform, ibm-cloud, terraform-module, supported, graduated
topics: core-team, terraform, ibm-cloud, terraform-module, supported, graduated, deployable-architecture
3 changes: 3 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
}],
["@semantic-release/exec", {
"successCmd": "echo \"SEMVER_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
}],
["@semantic-release/exec",{
"publishCmd": "./ci/trigger-catalog-onboarding-pipeline.sh --version=v${nextRelease.version}"
}]
]
}
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ You can use this module to provision and configure an [IBM Container Registry](h
* [terraform-ibm-container-registry](#terraform-ibm-container-registry)
* [Submodules](./modules)
* [plan](./modules/plan)
* [quotas](./modules/quotas)
* [Examples](./examples)
* [IBM Container Registry namespace example](./examples/namespace)
* [IBM Container Registry namespace example](./examples/complete)
* [Contributing](#contributing)
<!-- END OVERVIEW HOOK -->

Expand All @@ -27,11 +28,25 @@ You can use this module to provision and configure an [IBM Container Registry](h
```hcl
module "namespace" {
source = "terraform-ibm-modules/container-registry/ibm"
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
name = "my-namespace"
version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release
namespace_name = "my-namespace"
namespace_region = "us-south"
resource_group_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX"
images_per_repo = 2
}
module "upgrade-plan" {
source = "terraform-ibm-modules/container-registry/ibm//modules/plan"
version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release
}
module "set_quota" {
source = "terraform-ibm-modules/container-registry/ibm//modules/quotas"
version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release
update_storage_quota = true
storage_megabytes = 5 * 1024 # 5GiB
update_traffic_quota = true
traffic_megabytes = 500 # 500 MB
}
```

### Required IAM access policies
Expand Down Expand Up @@ -61,13 +76,15 @@ No modules.
|------|------|
| [ibm_cr_namespace.cr_namespace](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cr_namespace) | resource |
| [ibm_cr_retention_policy.cr_retention_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cr_retention_policy) | resource |
| [ibm_cr_namespaces.existing_cr_namespaces](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/cr_namespaces) | data source |

### Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_existing_namespace_name"></a> [existing\_namespace\_name](#input\_existing\_namespace\_name) | The name of an existing namespace. Required if 'namespace\_name' is not provided. | `string` | `null` | no |
| <a name="input_images_per_repo"></a> [images\_per\_repo](#input\_images\_per\_repo) | (Optional, Integer) Determines how many images are retained in each repository when the retention policy is processed. The value -1 denotes Unlimited (all images are retained). The value 0 denotes no retention policy will be created (default) | `number` | `0` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of the container registry namespace | `string` | n/a | yes |
| <a name="input_namespace_name"></a> [namespace\_name](#input\_namespace\_name) | Name of the container registry namespace, if var.existing\_namespace\_name is not inputted, a new namespace will be created in a region set by provider. | `string` | n/a | yes |
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the IBM container namespace will be created. | `string` | n/a | yes |
| <a name="input_retain_untagged"></a> [retain\_untagged](#input\_retain\_untagged) | (Optional, Bool) Determines whether untagged images are retained when the retention policy is processed. Default value is false, means untagged images can be deleted when the policy runs. | `bool` | `false` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Optional list of tags to be added to the IBM container namespace. | `list(string)` | `[]` | no |
Expand All @@ -77,6 +94,8 @@ No modules.
| Name | Description |
|------|-------------|
| <a name="output_namespace_crn"></a> [namespace\_crn](#output\_namespace\_crn) | CRN representing the namespace |
| <a name="output_namespace_name"></a> [namespace\_name](#output\_namespace\_name) | Name of ICR namespace |
| <a name="output_retention_policy_id"></a> [retention\_policy\_id](#output\_retention\_policy\_id) | ID of retentation policy |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

<!-- Leave this section as is so that your module has a link to local development environment set up steps for contributors to follow -->
Expand Down
8 changes: 4 additions & 4 deletions cra-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: "v1"
CRA_TARGETS:
- CRA_TARGET: "examples/namespace"
- CRA_TARGET: "solutions/standard"
CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json"
PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
# CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
# TF_VAR_sample: "sample value"
# TF_VAR_other: "another value"
CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
TF_VAR_provider_visibility: "public"
TF_VAR_namespace_region: "us-south"
# SCC_INSTANCE_ID: "" # The SCC instance ID to use to download profile for CRA scan. If not provided, a default global value will be used.
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
# PROFILE_ID: "" # The Profile ID input for CRA SCC scan. Ensure to use a US-specific ID. If not provided, a default global value will be used.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IBM Container Registry namespace example

This example creates the following infrastructure:

- A new resource group, if one is not passed in.
- A new IBM Container Registry namespace.
- Optionally, a new retention policy for the namespace.
34 changes: 34 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
########################################################################################################################
# Resource group
########################################################################################################################

module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.1.6"
# if an existing resource group is not set (null) create a new one using prefix
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
existing_resource_group_name = var.resource_group
}

module "namespace" {
providers = {
ibm = ibm.namespace
}
source = "../.."
namespace_name = var.prefix == null ? "namespace" : "${var.prefix}-namespace"
existing_namespace_name = var.existing_namespace_name
resource_group_id = module.resource_group.resource_group_id
tags = var.resource_tags
images_per_repo = var.images_per_repo
retain_untagged = var.retain_untagged
}

module "upgrade_plan" {
source = "../..//modules/plan"
}

module "set_quota" {
source = "../../modules/quotas"
storage_megabytes = 5 * 1024 - 1
traffic_megabytes = 499
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
}

provider "ibm" {
alias = "namespace"
ibmcloud_api_key = var.ibmcloud_api_key
region = var.namespace_region
}

# Data source to retrieve token details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ variable "prefix" {
default = "test-icr"
}

variable "region" {
variable "namespace_region" {
type = string
description = "Prefix to append to all resources created by this example"
description = "The IBM Cloud region where the container registry namespace and retention policy will be created or where the existing namespace is located."
default = "us-south"
}

variable "existing_namespace_name" {
type = bool
description = "The name of an existing namespace. Required if `namespace_name` is not provided."
default = null
}

variable "resource_group" {
type = string
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ terraform {
}
restapi = {
source = "Mastercard/restapi"
version = ">= 1.18.2"
version = ">= 1.20.0"
}
}
}
Loading

0 comments on commit bf49fb9

Please sign in to comment.