mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
Fix: add app samples for Terraform definition (#3119)
Added application samples for all Terraform typed ComponentDefinition,
and also localize the title for AWS and AZure
Signed-off-by: Zheng Xi Zhou <zzxwill@gmail.com>
(cherry picked from commit 670a327161)
Co-authored-by: Zheng Xi Zhou <zzxwill@gmail.com>
This commit is contained in:
co-authored by
Zheng Xi Zhou
parent
cd036b87ae
commit
11a1b2fa72
@@ -44,6 +44,14 @@ var Definitions = map[string]map[Language]string{
|
||||
Zh: "阿里云",
|
||||
En: "Alibaba Cloud",
|
||||
},
|
||||
"AWS": {
|
||||
Zh: "AWS",
|
||||
En: "AWS",
|
||||
},
|
||||
"Azure": {
|
||||
Zh: "Azure",
|
||||
En: "Azure",
|
||||
},
|
||||
"Name": {
|
||||
Zh: "名称",
|
||||
En: "Name",
|
||||
@@ -76,4 +84,52 @@ var Definitions = map[string]map[Language]string{
|
||||
Zh: "用于部署阿里云 ACK 集群的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud ACK cluster",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_Serverless_Kubernetes_(ASK)": {
|
||||
Zh: "用于部署阿里云 Serverless Kubernetes (ASK) 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud Serverless Kubernetes (ASK)",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_Elastic_IP": {
|
||||
Zh: "用于部署阿里云弹性 IP 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud Elastic IP",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_OSS_object": {
|
||||
Zh: "用于部署阿里云 OSS 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud OSS",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_RDS_object": {
|
||||
Zh: "用于部署阿里云 RDS 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud RDS",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_Redis": {
|
||||
Zh: "用于部署阿里云 Redis 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud Redis",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_SLS_Project": {
|
||||
Zh: "用于部署阿里云 SLS Project 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud SLS Project",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_SLS_Store": {
|
||||
Zh: "用于部署阿里云 SLS Store 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud SLS Store",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_VPC": {
|
||||
Zh: "用于部署阿里云 VPC 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud VPC",
|
||||
},
|
||||
"Terraform_configuration_for_Alibaba_Cloud_VSwitch": {
|
||||
Zh: "用于部署阿里云 VSwitch 的组件说明",
|
||||
En: "Terraform configuration for Alibaba Cloud VSwitch",
|
||||
},
|
||||
"Terraform_configuration_for_AWS_S3": {
|
||||
Zh: "用于部署 AWS S3 的组件说明",
|
||||
En: "Terraform configuration for AWS S3",
|
||||
},
|
||||
"Terraform_configuration_for_Azure_Database_Mariadb": {
|
||||
Zh: "用于部署 Azure mariadb 数据库的组件说明",
|
||||
En: "Terraform configuration for Azure Database Mariadb",
|
||||
},
|
||||
"Terraform_configuration_for_Azure_Blob_Storage_Account": {
|
||||
Zh: "用于部署 Azure Blob Storage 账号的的组件说明",
|
||||
En: "Terraform configuration for Azure Blob Storage Account",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -554,6 +554,20 @@ func TestMakeReadableTitle(t *testing.T) {
|
||||
},
|
||||
want: "阿里云 DEF-GHI",
|
||||
},
|
||||
{
|
||||
args: args{
|
||||
title: "aws-jk",
|
||||
ref: refZh,
|
||||
},
|
||||
want: "AWS JK",
|
||||
},
|
||||
{
|
||||
args: args{
|
||||
title: "azure-jk",
|
||||
ref: refZh,
|
||||
},
|
||||
want: "Azure JK",
|
||||
},
|
||||
}
|
||||
for _, tc := range testcases {
|
||||
t.Run("", func(t *testing.T) {
|
||||
|
||||
@@ -359,6 +359,156 @@ spec:
|
||||
writeConnectionSecretToRef:
|
||||
name: ack-conn
|
||||
namespace: vela-system
|
||||
`,
|
||||
"alibaba-eip": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: provision-cloud-resource-eip
|
||||
spec:
|
||||
components:
|
||||
- name: sample-eip
|
||||
type: alibaba-eip
|
||||
properties:
|
||||
writeConnectionSecretToRef:
|
||||
name: eip-conn
|
||||
`,
|
||||
|
||||
"alibaba-oss": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: oss-cloud-source
|
||||
spec:
|
||||
components:
|
||||
- name: sample-oss
|
||||
type: alibaba-oss
|
||||
properties:
|
||||
bucket: vela-website
|
||||
acl: private
|
||||
writeConnectionSecretToRef:
|
||||
name: oss-conn
|
||||
`,
|
||||
|
||||
"alibaba-redis": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: redis-cloud-source
|
||||
spec:
|
||||
components:
|
||||
- name: sample-redis
|
||||
type: alibaba-redis
|
||||
properties:
|
||||
instance_name: oam-redis
|
||||
account_name: oam
|
||||
password: Xyfff83jfewGGfaked
|
||||
writeConnectionSecretToRef:
|
||||
name: redis-conn
|
||||
`,
|
||||
|
||||
"aws-s3": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: s3-cloud-source
|
||||
spec:
|
||||
components:
|
||||
- name: sample-s3
|
||||
type: aws-s3
|
||||
properties:
|
||||
bucket: vela-website-20211019
|
||||
acl: private
|
||||
|
||||
writeConnectionSecretToRef:
|
||||
name: s3-conn
|
||||
`,
|
||||
|
||||
"azure-database-mariadb": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: mariadb-backend
|
||||
spec:
|
||||
components:
|
||||
- name: mariadb-backend
|
||||
type: azure-database-mariadb
|
||||
properties:
|
||||
resource_group: "kubevela-group"
|
||||
location: "West Europe"
|
||||
server_name: "kubevela"
|
||||
db_name: "backend"
|
||||
username: "acctestun"
|
||||
password: "H@Sh1CoR3!Faked"
|
||||
writeConnectionSecretToRef:
|
||||
name: azure-db-conn
|
||||
namespace: vela-system
|
||||
`,
|
||||
|
||||
"azure-storage-account": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: storage-account-dev
|
||||
spec:
|
||||
components:
|
||||
- name: storage-account-dev
|
||||
type: azure-storage-account
|
||||
properties:
|
||||
create_rsg: false
|
||||
resource_group_name: "weursgappdev01"
|
||||
location: "West Europe"
|
||||
name: "appdev01"
|
||||
tags: |
|
||||
{
|
||||
ApplicationName = "Application01"
|
||||
Terraform = "Yes"
|
||||
}
|
||||
static_website: |
|
||||
[{
|
||||
index_document = "index.html"
|
||||
error_404_document = "index.html"
|
||||
}]
|
||||
|
||||
writeConnectionSecretToRef:
|
||||
name: storage-account-dev
|
||||
namespace: vela-system
|
||||
`,
|
||||
|
||||
"alibaba-sls-project": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-sls-project-sample
|
||||
spec:
|
||||
components:
|
||||
- name: sample-sls-project
|
||||
type: alibaba-sls-project
|
||||
properties:
|
||||
name: kubevela-1112
|
||||
description: "Managed by KubeVela"
|
||||
|
||||
writeConnectionSecretToRef:
|
||||
name: sls-project-conn
|
||||
`,
|
||||
|
||||
"alibaba-sls-store": `
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-sls-store-sample
|
||||
spec:
|
||||
components:
|
||||
- name: sample-sls-store
|
||||
type: alibaba-sls-store
|
||||
properties:
|
||||
store_name: kubevela-1111
|
||||
store_retention_period: 30
|
||||
store_shard_count: 2
|
||||
store_max_split_shard_count: 2
|
||||
|
||||
writeConnectionSecretToRef:
|
||||
name: sls-store-conn
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -521,16 +671,26 @@ func (ref *MarkdownReference) CreateMarkdown(ctx context.Context, caps []types.C
|
||||
}
|
||||
|
||||
func (ref *MarkdownReference) makeReadableTitle(title string) string {
|
||||
const alibabaCloud = "alibaba-"
|
||||
if ref.I18N == "" {
|
||||
ref.I18N = En
|
||||
}
|
||||
var AlibabaCloudTitle = Definitions["AlibabaCloud"][ref.I18N]
|
||||
if strings.HasPrefix(title, alibabaCloud) {
|
||||
cloudResource := strings.Replace(title, alibabaCloud, "", 1)
|
||||
return fmt.Sprintf("%s %s", AlibabaCloudTitle, strings.ToUpper(cloudResource))
|
||||
if !strings.Contains(title, "-") {
|
||||
return strings.Title(title)
|
||||
}
|
||||
return strings.Title(title)
|
||||
var name string
|
||||
provider := strings.Split(title, "-")[0]
|
||||
switch provider {
|
||||
case "alibaba":
|
||||
name = "AlibabaCloud"
|
||||
case "aws":
|
||||
name = "AWS"
|
||||
case "azure":
|
||||
name = "Azure"
|
||||
default:
|
||||
return strings.Title(title)
|
||||
}
|
||||
cloudResource := strings.Replace(title, provider+"-", "", 1)
|
||||
return fmt.Sprintf("%s %s", Definitions[name][ref.I18N], strings.ToUpper(cloudResource))
|
||||
}
|
||||
|
||||
// prepareParameter prepares the table content for each property
|
||||
|
||||
Reference in New Issue
Block a user