Skip to content

Commit 5df92de

Browse files
committed
chore: Modify orchestration environment variable style
1 parent 2546809 commit 5df92de

File tree

17 files changed

+32
-145
lines changed

17 files changed

+32
-145
lines changed

agent/app/dto/container.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ type ComposeInfo struct {
261261
Workdir string `json:"workdir"`
262262
Path string `json:"path"`
263263
Containers []ComposeContainer `json:"containers"`
264-
Env []string `json:"env"`
264+
Env string `json:"env"`
265265
}
266266
type ComposeContainer struct {
267267
ContainerID string `json:"containerID"`
@@ -271,13 +271,13 @@ type ComposeContainer struct {
271271
Ports []string `json:"ports"`
272272
}
273273
type ComposeCreate struct {
274-
TaskID string `json:"taskID"`
275-
Name string `json:"name"`
276-
From string `json:"from" validate:"required,oneof=edit path template"`
277-
File string `json:"file"`
278-
Path string `json:"path"`
279-
Template uint `json:"template"`
280-
Env []string `json:"env"`
274+
TaskID string `json:"taskID"`
275+
Name string `json:"name"`
276+
From string `json:"from" validate:"required,oneof=edit path template"`
277+
File string `json:"file"`
278+
Path string `json:"path"`
279+
Template uint `json:"template"`
280+
Env string `json:"env"`
281281
}
282282
type ComposeOperation struct {
283283
Name string `json:"name" validate:"required"`
@@ -287,10 +287,10 @@ type ComposeOperation struct {
287287
Force bool `josn:"force"`
288288
}
289289
type ComposeUpdate struct {
290-
Name string `json:"name" validate:"required"`
291-
Path string `json:"path" validate:"required"`
292-
Content string `json:"content" validate:"required"`
293-
Env []string `json:"env"`
290+
Name string `json:"name" validate:"required"`
291+
Path string `json:"path" validate:"required"`
292+
Content string `json:"content" validate:"required"`
293+
Env string `json:"env"`
294294
}
295295
type ComposeLogClean struct {
296296
Name string `json:"name" validate:"required"`

agent/app/service/container_compose.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -410,34 +410,22 @@ func loadEnv(list []dto.ComposeInfo) []dto.ComposeInfo {
410410
if err != nil {
411411
continue
412412
}
413-
lines := strings.Split(string(file), "\n")
414-
for _, line := range lines {
415-
lineItem := strings.TrimSpace(line)
416-
if len(lineItem) != 0 && !strings.HasPrefix(lineItem, "#") {
417-
list[i].Env = append(list[i].Env, lineItem)
418-
}
419-
}
413+
list[i].Env = string(file)
420414
}
421415
return list
422416
}
423417

424-
func newComposeEnv(pathItem string, env []string) error {
425-
if len(env) == 0 {
426-
return nil
427-
}
418+
func newComposeEnv(pathItem string, env string) error {
428419
envFilePath := path.Join(path.Dir(pathItem), ".env")
429420
file, err := os.OpenFile(envFilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, constant.FilePerm)
430421
if err != nil {
431422
global.LOG.Errorf("failed to create env file: %v", err)
432423
return err
433424
}
434425
defer file.Close()
435-
for _, env := range env {
436-
envItem := strings.TrimSpace(env)
437-
if _, err := file.WriteString(fmt.Sprintf("%s\n", envItem)); err != nil {
438-
global.LOG.Errorf("failed to write env to file: %v", err)
439-
return err
440-
}
426+
if _, err := file.WriteString(env); err != nil {
427+
global.LOG.Errorf("failed to write env to file: %v", err)
428+
return err
441429
}
442430
return nil
443431
}

frontend/src/api/interface/container.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ export namespace Container {
310310
path: string;
311311
containers: Array<ComposeContainer>;
312312
expand: boolean;
313-
envStr: string;
314-
env: Array<string>;
313+
env: string;
315314
}
316315
export interface ComposeContainer {
317316
name: string;
@@ -338,7 +337,7 @@ export namespace Container {
338337
name: string;
339338
path: string;
340339
content: string;
341-
env: Array<string>;
340+
env: string;
342341
createdBy: string;
343342
}
344343

frontend/src/components/label/index.vue

Lines changed: 0 additions & 85 deletions
This file was deleted.

frontend/src/lang/modules/en.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,6 @@ const message = {
10401040
composeOperatorHelper: '{1} operation will be performed on {0}. Do you want to continue?',
10411041
composeDownHelper:
10421042
'This will stop and remove all containers and networks under the {0} compose. Do you want to continue?',
1043-
composeEnvHelper1: 'Double-click to edit existing environment variables.',
10441043
composeEnvHelper2:
10451044
'This orchestration was created by the 1Panel App Store. Please modify environment variables in the installed applications.',
10461045

frontend/src/lang/modules/es-es.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,6 @@ const message = {
10461046
composeOperatorHelper: 'La operación {1} se realizará en {0}. ¿Desea continuar?',
10471047
composeDownHelper:
10481048
'Esto detendrá y eliminará todos los contenedores y redes bajo la composición {0}. ¿Desea continuar?',
1049-
composeEnvHelper1: 'Haga doble clic para editar las variables de entorno existentes.',
10501049
composeEnvHelper2:
10511050
'Esta orquestación fue creada por la Tienda de Aplicaciones 1Panel. Modifique las variables de entorno en las aplicaciones instaladas.',
10521051

frontend/src/lang/modules/ja.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ const message = {
10171017
composeOperatorHelper: '{1}操作は{0}で実行されます。続けたいですか?',
10181018
composeDownHelper:
10191019
'これにより、{0}構成の下のすべてのコンテナとネットワークが停止して削除されます。続けたいですか?',
1020-
composeEnvHelper1: '既存の環境変数を編集するにはダブルクリックしてください。',
10211020
composeEnvHelper2:
10221021
'このオーケストレーションは1Panelアプリストアで作成されました。インストール済みアプリケーションで環境変数を変更してください。',
10231022

frontend/src/lang/modules/ko.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,6 @@ const message = {
10051005
composeOperatorHelper: '{1} 작업이 {0}에서 수행됩니다. 계속 하시겠습니까?',
10061006
composeDownHelper:
10071007
'이 작업은 {0} 컴포즈 아래의 모든 컨테이너와 네트워크를 중지하고 제거합니다. 계속 하시겠습니까?',
1008-
composeEnvHelper1: '기존 환경 변수를 편집하려면 더블 클릭하세요.',
10091008
composeEnvHelper2:
10101009
'이 오케스트레이션은 1Panel 앱 스토어에서 생성되었습니다. 설치된 애플리케이션에서 환경 변수를 수정하세요.',
10111010

frontend/src/lang/modules/ms.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,6 @@ const message = {
10351035
composeOperatorHelper: 'Operasi {1} akan dilakukan pada {0}. Adakah anda mahu meneruskan?',
10361036
composeDownHelper:
10371037
'Ini akan menghentikan dan menghapuskan semua kontena dan rangkaian di bawah komposisi {0}. Adakah anda mahu meneruskan?',
1038-
composeEnvHelper1: 'Klik dua kali untuk mengedit pembolehubah persekitaran sedia ada.',
10391038
composeEnvHelper2:
10401039
'Penyelarasan ini dibuat oleh Kedai Apl 1Panel. Sila ubah pembolehubah persekitaran dalam aplikasi yang dipasang.',
10411040

frontend/src/lang/modules/pt-br.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,6 @@ const message = {
10321032
composeOperatorHelper: 'A operação {1} será realizada no {0}. Deseja continuar?',
10331033
composeDownHelper:
10341034
'Isso irá parar e remover todos os containers e redes sob a composição {0}. Deseja continuar?',
1035-
composeEnvHelper1: 'Clique duas vezes para editar variáveis de ambiente existentes.',
10361035
composeEnvHelper2:
10371036
'Esta orquestração foi criada pela Loja de Aplicativos 1Panel. Modifique as variáveis de ambiente nos aplicativos instalados.',
10381037

0 commit comments

Comments
 (0)