Skip to content

Commit 2288211

Browse files
committed
adding new flag --core-flag to allow custom environment variables to Neo Core
1 parent 052cd23 commit 2288211

5 files changed

Lines changed: 19 additions & 3 deletions

File tree

cmd/neoctl/instance.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var (
3232
instAll bool
3333
instCoreVer string
3434
instUIVer string
35+
instCoreEnv []string
3536
instSMB bool
3637
instPortSMB int
3738

@@ -289,6 +290,12 @@ var instanceConfigureCmd = &cobra.Command{
289290
inst.UIVersion = instUIVer
290291
}
291292

293+
if cmd.Flags().Changed("core-env") {
294+
inst.CoreEnv = instCoreEnv
295+
} else if !ok {
296+
inst.CoreEnv = instCoreEnv
297+
}
298+
292299
if cmd.Flags().Changed("smb") {
293300
inst.SMB = instSMB
294301
} else if !ok {
@@ -732,6 +739,7 @@ func init() {
732739
instanceConfigureCmd.Flags().StringVar(&instMemory, "memory", "8G", "Memory limit")
733740
instanceConfigureCmd.Flags().StringVar(&instCoreVer, "core", "", "Neo Core version (e.g. v1.2.3)")
734741
instanceConfigureCmd.Flags().StringVar(&instUIVer, "ui", "", "Neo UI version (e.g. v1.2.3)")
742+
instanceConfigureCmd.Flags().StringSliceVar(&instCoreEnv, "core-env", nil, "Additional environment variables for Neo Core (e.g. VAR=value)")
735743
instanceConfigureCmd.Flags().BoolVar(&instSMB, "smb", false, "Enable a SMB server for test only")
736744
instanceConfigureCmd.Flags().IntVar(&instPortSMB, "port-smb", 445, "SMB server port")
737745

internal/config/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ type InstanceConfig struct {
8989
GPU string `json:"gpu"`
9090
CPU string `json:"cpu"`
9191
Memory string `json:"memory"`
92-
CoreVersion string `json:"neocore_version,omitempty"`
93-
UIVersion string `json:"neoui_version,omitempty"`
94-
SMB bool `json:"smb"`
92+
CoreVersion string `json:"neocore_version,omitempty"`
93+
UIVersion string `json:"neoui_version,omitempty"`
94+
CoreEnv []string `json:"core_env,omitempty"`
95+
SMB bool `json:"smb"`
9596
PortSMB int `json:"port_smb"`
9697
}
9798

internal/config/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func TestSaveAndLoadInstanceConfig(t *testing.T) {
8787
PortSQL: 5432,
8888
SMB: true,
8989
PortSMB: 445,
90+
CoreEnv: []string{"TEST_ENV=1"},
9091
}
9192

9293
if err := SaveInstanceConfig(instances); err != nil {

internal/runner/compose.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ const composeTemplate = `services:
9696
environment:
9797
- PORT=8080
9898
- PYTHONUNBUFFERED=1
99+
{{- range .Instance.CoreEnv }}
100+
- {{ . }}
101+
{{- end }}
99102
restart: unless-stopped
100103
101104
neoui:

internal/runner/compose_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func TestGenerateComposeFile(t *testing.T) {
106106
Name: "test-smb",
107107
SMB: true,
108108
PortSMB: 4450,
109+
CoreEnv: []string{"CUSTOM_VAR1=one", "CUSTOM_VAR2=two"},
109110
}
110111
bundle := config.Config{} // Empty bundle is fine for this test
111112

@@ -126,6 +127,8 @@ func TestGenerateComposeFile(t *testing.T) {
126127
"container_name: test-smb-neosmb",
127128
"4450:445", // Port mapping
128129
"test-smb-neosmb:/storage", // Volume
130+
"CUSTOM_VAR1=one",
131+
"CUSTOM_VAR2=two",
129132
}
130133

131134
for _, s := range expectedStrings {

0 commit comments

Comments
 (0)