diff --git a/terraform-server/services/db/provider.go b/terraform-server/services/db/provider.go index efd621d..42096e9 100644 --- a/terraform-server/services/db/provider.go +++ b/terraform-server/services/db/provider.go @@ -49,7 +49,7 @@ func ProviderBatchCreate(user string, param []*models.ProviderTable) (rowData [] } terraformProviderCommonPath := terraformFilePath + "providers/" + data.Name + "/" + data.Version terraformProviderPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch - terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" + terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" data.Initialized = "Y" _, err = os.Stat(terraformProviderPath) @@ -108,7 +108,7 @@ func ProviderBatchUpdate(user string, param []*models.ProviderTable) (err error) } terraformProviderCommonPath := terraformFilePath + "providers/" + param[i].Name + "/" + param[i].Version terraformProviderPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch - terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" + terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" param[i].Initialized = "Y" _, err = os.Stat(terraformProviderPath) @@ -175,6 +175,7 @@ func ProviderPluginExport(providerNameList, pluginNameList []string) (result mod pluginIdFilterSql = fmt.Sprintf("('%s')", strings.Join(pluginIdList, "','")) x.SQL("select * from interface where plugin in " + pluginIdFilterSql).Find(&result.Interface) x.SQL("select * from `parameter` where interface in (select id from interface where plugin in " + pluginIdFilterSql + ")").Find(&result.Parameter) + x.SQL("select * from provider_template_value where provider in " + providerIdFilterSql).Find(&result.ProviderTemplateValue) templateSql := "select * from template where id in (select template_value from provider_template_value where provider in " + providerIdFilterSql + ")" templateSql += " union " templateSql += "select * from template where id in (select template from `parameter` where interface in (select id from interface where plugin in " + pluginIdFilterSql + "))" @@ -312,15 +313,15 @@ func ProviderDownload(providerId string, user string) (err error) { } terraformProviderCommonPath := terraformFilePath + "providers/" + providerData.Name + "/" + providerData.Version // terraformProviderPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch - terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" + terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" /* - err = GenDir(terraformProviderPath) - if err != nil { - err = fmt.Errorf("Gen terraformProviderPath : %s error: %s", terraformProviderPath, err.Error()) - log.Logger.Error("Gen terraformProviderPath error", log.String("terraformProviderPath", terraformProviderPath), log.Error(err)) - return - } + err = GenDir(terraformProviderPath) + if err != nil { + err = fmt.Errorf("Gen terraformProviderPath : %s error: %s", terraformProviderPath, err.Error()) + log.Logger.Error("Gen terraformProviderPath error", log.String("terraformProviderPath", terraformProviderPath), log.Error(err)) + return + } */ err = GenDir(terraformLockHclPath) @@ -402,7 +403,7 @@ func ProviderUpload(providerId string, r *http.Request, user string) (err error) terraformFilePath += "/" } terraformProviderCommonPath := terraformFilePath + "providers/" + providerData.Name + "/" + providerData.Version - terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" + terraformLockHclPath := terraformProviderCommonPath + "/" + models.Config.TerraformProviderOsArch + "_hcl" err = GenDir(terraformLockHclPath) if err != nil { @@ -530,4 +531,4 @@ func ProviderUpload(providerId string, r *http.Request, user string) (err error) log.Logger.Error("Update provider's initialized column error", log.Error(err)) } return -} \ No newline at end of file +} diff --git a/terraform-server/services/db/terraform.go b/terraform-server/services/db/terraform.go index e4b8d6e..2590c3a 100644 --- a/terraform-server/services/db/terraform.go +++ b/terraform-server/services/db/terraform.go @@ -625,21 +625,29 @@ func handleOutPutArgs(outPutArgs map[string]interface{}, if _, ok := reqParam[k]; ok { mapOutPutArgs[i][k] = reqParam[k] if k == "password" { - enCodeStr, encodeErr := cipher.AesEnPasswordByGuid(models.PGuid, models.Config.Auth.PasswordSeed, reqParam[k].(string), "") - if encodeErr != nil { - log.Logger.Error("Try to encode failed", log.Error(encodeErr)) + if _, tmpOk := reqParam["seed"]; !tmpOk { + log.Logger.Error("Try to get seed failed") } else { - mapOutPutArgs[i][k] = enCodeStr + enCodeStr, encodeErr := cipher.AesEnPasswordByGuid(reqParam["id"].(string), reqParam["seed"].(string), reqParam[k].(string), "") + if encodeErr != nil { + log.Logger.Error("Try to encode failed", log.Error(encodeErr)) + } else { + mapOutPutArgs[i][k] = enCodeStr + } } } } } else { if v.Sensitive == "Y" { - enCodeStr, encodeErr := cipher.AesEnPasswordByGuid(models.PGuid, models.Config.Auth.PasswordSeed, mapOutPutArgs[i][k].(string), "") - if encodeErr != nil { - log.Logger.Error("Try to encode failed", log.Error(encodeErr)) + if _, tmpOk := reqParam["seed"]; !tmpOk { + log.Logger.Error("Try to get seed failed") } else { - mapOutPutArgs[i][k] = enCodeStr + enCodeStr, encodeErr := cipher.AesEnPasswordByGuid(reqParam["id"].(string), reqParam["seed"].(string), mapOutPutArgs[i][k].(string), "") + if encodeErr != nil { + log.Logger.Error("Try to encode failed", log.Error(encodeErr)) + } else { + mapOutPutArgs[i][k] = enCodeStr + } } } } @@ -3381,6 +3389,23 @@ func convertDirect(defaultValue string, reqParam map[string]interface{}, tfArgum } } + if parameterData.Sensitive == "Y" { + if _, tmpOk := reqParam["seed"]; !tmpOk { + err = fmt.Errorf("Parameter data: seed can not be found ") + return + } else if reqParam["seed"].(string) == "" { + err = fmt.Errorf("Parameter data: seed can not be empty ") + return + } + + if _, ok := arg.(string); ok { + if strings.HasPrefix(arg.(string),"{cipher_a}") { + arg, err = cipher.AesDePasswordByGuid(reqParam["id"].(string), reqParam["seed"].(string), arg.(string)) + return + } + } + } + if tfArgument.DefaultValue == models.RandomFlag && (arg == nil || arg == "") { randomVal := guid.CreateGuid() arg = randomVal[:16] diff --git a/ui/src/locale/i18n/en-US.json b/ui/src/locale/i18n/en-US.json index 7c61a96..cc61f0d 100755 --- a/ui/src/locale/i18n/en-US.json +++ b/ui/src/locale/i18n/en-US.json @@ -38,6 +38,7 @@ "t_region_attr_name": "Region Attr Name", "t_secretKey_attr_name": "Secret Key Attr Name", "t_secretId_attr_name": "Secret ID Attr Name", + "t_initialized": "Provider Initialized", "t_source": "Source", "t_resource_asset_id_Attribute": "Resource Asset Id Attribute", "t_import_export": "Import & Export", @@ -66,5 +67,10 @@ "t_remark": "Remark", "t_namespace": "Namespace", "t_format_parameter": "Format Parameter", - "t_instance_data": "Instance Data" + "t_instance_data": "Instance Data", + "t_download": "Download", + "t_online_download": "Download", + "t_local_upload": "Upload", + "t_online_download_tip": "In online scenarios, download the official provider file", + "t_local_upload_tip": "In offline scenarios, upload the locally made provider file" } diff --git a/ui/src/locale/i18n/zh-CN.json b/ui/src/locale/i18n/zh-CN.json index 68f982f..c3474be 100755 --- a/ui/src/locale/i18n/zh-CN.json +++ b/ui/src/locale/i18n/zh-CN.json @@ -38,6 +38,7 @@ "t_region_attr_name": "地域属性名称", "t_secretKey_attr_name": "秘钥Key属性名称", "t_secretId_attr_name": "秘钥Id属性名称", + "t_initialized": "是否初始化", "t_source": "资源", "t_resource_asset_id_Attribute": "资产ID属性", "t_import_export": "导入&导出", @@ -66,5 +67,10 @@ "t_remark": "备注", "t_namespace": "命名空间", "t_format_parameter": "格式化参数", - "t_instance_data": "实例数据" + "t_instance_data": "实例数据", + "t_download": "下载", + "t_online_download": "下载", + "t_local_upload": "上传", + "t_online_download_tip": "连网场景,下载官方提供的provider文件", + "t_local_upload_tip": "离线场景,上传本地制做的provider文件" } diff --git a/ui/src/pages/instance-data.vue b/ui/src/pages/instance-data.vue index 7218427..398ef33 100644 --- a/ui/src/pages/instance-data.vue +++ b/ui/src/pages/instance-data.vue @@ -16,7 +16,7 @@