[REV] Fix parameters error in get json method.

This commit is contained in:
Zhang Jiajun 2018-05-10 18:32:14 +08:00
parent b857175b05
commit c3d107953c
2 changed files with 10 additions and 10 deletions

View File

@ -28,7 +28,7 @@ func CreateAppManager(mqClient pb.TaskQueueClient) *AppAction {
}
func (a *AppAction) Complete(tr *model.ExportAppStruct) error {
appName := gjson.Get(tr.Body.GroupMetadata, ".group_name").String()
appName := gjson.Get(tr.Body.GroupMetadata, "group_name").String()
if appName == "" {
err := errors.New("Failed to get group name form metadata.")
logrus.Error(err)
@ -79,7 +79,7 @@ func (a *AppAction) ExportApp(tr *model.ExportAppStruct) error {
// TODO 与ExportApp函数唯一不同的是导出目录以后有可能合并
func (a *AppAction) ExportRunnableApp(tr *model.ExportAppStruct) error {
appName := gjson.Get(tr.Body.GroupMetadata, ".group_name").String()
appName := gjson.Get(tr.Body.GroupMetadata, "group_name").String()
if appName == "" {
err := errors.New("Failed to get group name form metadata.")
logrus.Error(err)

View File

@ -186,14 +186,14 @@ func (i *ExportApp) replaceMetadata(old, new string) error {
}
func (i *ExportApp) exportImage(app gjson.Result) error {
serviceName := app.Get(".service_cname").String()
serviceName := app.Get("service_cname").String()
serviceName = unicode2zh(serviceName)
serviceDir := fmt.Sprintf("%s/%s", i.SourceDir, serviceName)
os.MkdirAll(serviceDir, 0755)
// 处理掉文件名中冒号等不合法字符
image := app.Get(".image").String()
image := app.Get("image").String()
tarFileName := buildToLinuxFileName(image)
// 如果是runner镜像则跳过
@ -234,14 +234,14 @@ func (i *ExportApp) saveApps() error {
i.Logger.Info("开始打包应用", map[string]string{"step": "export-app", "status": "success"})
for _, app := range apps {
serviceName := app.Get(".service_cname").String()
serviceName := app.Get("service_cname").String()
serviceName = unicode2zh(serviceName)
serviceDir := fmt.Sprintf("%s/%s", i.SourceDir, serviceName)
os.MkdirAll(serviceDir, 0755)
// 如果该slug文件存在于本地则直接复制然后修改json中的share_slug_path字段
shareSlugPath := app.Get(".share_slug_path").String()
shareSlugPath := app.Get("share_slug_path").String()
tarFileName := buildToLinuxFileName(shareSlugPath)
_, err := os.Stat(shareSlugPath)
if os.IsExist(err) {
@ -255,7 +255,7 @@ func (i *ExportApp) saveApps() error {
// 如果这个字段存在于该app中则认为该app是源码部署方式并从ftp下载相应slug文件
// 否则认为该app是镜像方式部署然后下载相应镜像即可
ftpHost := app.Get(".service_slug.ftp_host").String()
ftpHost := app.Get("service_slug.ftp_host").String()
if ftpHost == "" {
logrus.Infof("Not found fields ftp_host for service key %s", serviceName)
@ -271,9 +271,9 @@ func (i *ExportApp) saveApps() error {
map[string]string{"step": "parse-slug", "status": "failure"})
// 提取tfp服务器信息
ftpPort := app.Get(".service_slug.ftp_port").String()
ftpUsername := app.Get(".service_slug.ftp_username").String()
ftpPassword := app.Get(".service_slug.ftp_password").String()
ftpPort := app.Get("service_slug.ftp_port").String()
ftpUsername := app.Get("service_slug.ftp_username").String()
ftpPassword := app.Get("service_slug.ftp_password").String()
ftpClient, err := sources.NewSFTPClient(ftpUsername, ftpPassword, ftpPort, ftpHost)
if err != nil {