更新软件
要更新专用目录中的软件,可以添加新版本或更新并重新发布现有版本。
准备工作
要完成此任务,需要为您分配对目录管理服务的编辑者角色。 有关更多信息,请参阅 分配用户访问权。
要使用 Terraform 更新软件,请确保已完成以下操作:
- 安装 Terraform CLI 并为 Terraform 配置 IBM Cloud 提供程序插件。 有关更多信息,请参阅 Terraform on IBM Cloud®入门 教程。 该插件对用于完成此任务的 IBM Cloud API 进行抽象。
- 创建一个名为
main.tf
的Terraform配置文件。 在此文件中,您使用 HashiCorp 配置语言来定义资源。 有关更多信息,请参阅 Terraform 文档。
使用控制台更新现有版本
以下步骤介绍了对产品自述文件进行更新的示例,以显示更新现有软件版本的完整过程。
- 在 IBM Cloud® 控制台中,转至 管理 > 目录 > 专用目录,然后从列表中选择目录。
- 单击软件产品的名称。
- 选择 专用产品 以浏览至专用目录中的产品列表。
- 单击 操作 图标
,然后选择 编辑。
- 点击“编辑自述”选项卡。
- 单击 编辑 图标
,向“简介”部分添加新的文本行,然后单击 更新。
- 单击 操作 图标
,然后选择 合并更改 以将更新后的版本发布到您的帐户。
使用 CLI 更新现有版本
完成以下步骤以创建草稿版本,对其进行更新,并将更改合并到软件的当前版本。
您需要软件的版本定位器。 要查找它,请运行 ibmcloud catalog offering list --catalog "your-private-catalog"
命令并搜索现有版本号。
- 创建软件的草稿版本。
ibmcloud catalog offering create-draft --version-locator <VERSION_LOCATOR>
- 请设置另一个类别。
ibmcloud catalog offering add-category --catalog "your-private-catalog" --offering "your-software" --category "category-type"
- 将草稿更新合并到软件。 此操作会将更新合并到帐户中发布的软件版本。
ibmcloud catalog offering merge-draft --version-locator **<VERSION_LOCATOR_OF_DRAFT_VERSION>**
- 在 IBM Cloud 目录中搜索软件。
ibmcloud catalog get --public | grep your-software
使用 API 更新现有版本
您可以通过调用目录管理API来更新版本,如下面的请求示例所示。 有关 API 的详细信息,请参阅 目录管理 API。
String catalogID = "{catalogID}";
String offeringID = "{offeringID}";
String label = "{label}";
String shortDesc = "{shortDesc}";
ReplaceOfferingOptions replaceOptions = new ReplaceOfferingOptions.Builder().catalogIdentifier(catalogID).id(offeringID).offeringId(offeringID).label(label).shortDescription(shortDesc).rev(revision.rev()).build();
Response<Catalog> response = service.replaceOffering(replaceOptions).execute();
System.out.println(response.getResult());
vcatalogID = "{catalogID}";
offeringID = "{offeringID}";
revision = "{revision}";
label = "{label}";
shortDesc = "{shortDesc}";
response = await service.replaceOffering({'catalogIdentifier': catalogID, 'offeringId': offeringID, 'id': offeringID, 'rev': revision, 'label': label, 'shortDescription': shortDesc});
console.log(response);
catalogID = "{catalogID}"
offeringID = "{offeringID}"
revision = "{revision}"
shortDesc = "{shortDesc}"
response = self.service.replace_offering(catalog_identifier=catalogID, offering_id=offeringID, id=offeringID, rev=revision, label=label, short_description=shortDesc)
print(response)
catalogID := "{catalogID}"
offeringID := "{offeringID}"
label := "{label}"
shortDesc := "{shortDesc}"
revision := "{revision}"
updateOptions := service.NewReplaceOfferingOptions(catalogID, offeringID)
updateOptions.SetID(offeringID)
updateOptions.SetLabel(label)
updateOptions.SetShortDescription(shortDesc)
updateOptions.SetRev(revision)
_, response, _ := service.ReplaceOffering(updateOptions)
fmt.Println(response)
使用 Terraform 更新现有版本
使用以下步骤通过 Terraform 更新软件的现有版本。
-
在
main.tf
文件中创建自变量。 以下示例使用cm_version
资源访问软件版本,其中offering_id
标识软件。resource "cm_version" "cm_version" { catalog_identifier = "catalog_identifier" offering_id = "offering_id" zipurl = "zipurl" }
有关更多信息,请参阅“Terraform 目录管理”页面上的参数参考详细信息。
-
完成构建配置文件后,初始化 Terraform CLI。 有关更多信息,请参阅 初始化工作目录。
terraform init
-
从
main.tf
文件供应资源。 有关更多信息,请参阅 使用 Terraform 供应基础架构。-
运行
terraform plan
以生成 Terraform 执行计划来预览建议的操作。terraform plan
-
运行
terraform apply
以创建计划中定义的资源。terraform apply
-