8
8
"strings"
9
9
"time"
10
10
11
+ "errors"
12
+
11
13
"github.com/xeipuuv/gojsonschema"
12
14
)
13
15
@@ -50,6 +52,7 @@ type ProjectConfig struct {
50
52
Restart string `json:"restart,omitempty"`
51
53
HealthCheck * HealthCheck `json:"health_check,omitempty"`
52
54
Resources * Resources `json:"resources,omitempty"`
55
+ Gpus string `json:"gpus,omitempty"`
53
56
}
54
57
55
58
type HealthCheck struct {
@@ -145,9 +148,21 @@ func (cm *ConfigManager) Save(config *Config) error {
145
148
}
146
149
147
150
func (cm * ConfigManager ) LoadProjectConfig (projectPath string ) (* ProjectConfig , error ) {
148
- configPath := filepath .Join (projectPath , "devbox.json" )
149
-
150
- if _ , err := os .Stat (configPath ); os .IsNotExist (err ) {
151
+ // Support multiple filenames for project config to avoid clashes with other tools
152
+ candidates := []string {
153
+ filepath .Join (projectPath , "devbox.json" ), // default
154
+ filepath .Join (projectPath , "devbox.project.json" ), // alternative
155
+ filepath .Join (projectPath , ".devbox.json" ), // dotfile style
156
+ }
157
+
158
+ var configPath string
159
+ for _ , p := range candidates {
160
+ if _ , err := os .Stat (p ); err == nil {
161
+ configPath = p
162
+ break
163
+ }
164
+ }
165
+ if configPath == "" {
151
166
return nil , nil
152
167
}
153
168
@@ -165,7 +180,19 @@ func (cm *ConfigManager) LoadProjectConfig(projectPath string) (*ProjectConfig,
165
180
}
166
181
167
182
func (cm * ConfigManager ) SaveProjectConfig (projectPath string , config * ProjectConfig ) error {
168
- configPath := filepath .Join (projectPath , "devbox.json" )
183
+ // If an existing config file with a supported name exists, write back to it; otherwise use default
184
+ candidates := []string {
185
+ filepath .Join (projectPath , "devbox.json" ),
186
+ filepath .Join (projectPath , "devbox.project.json" ),
187
+ filepath .Join (projectPath , ".devbox.json" ),
188
+ }
189
+ configPath := candidates [0 ]
190
+ for _ , p := range candidates {
191
+ if _ , err := os .Stat (p ); err == nil {
192
+ configPath = p
193
+ break
194
+ }
195
+ }
169
196
170
197
data , err := json .MarshalIndent (config , "" , " " )
171
198
if err != nil {
@@ -199,7 +226,7 @@ func (cm *ConfigManager) ValidateProjectConfig(cfg *ProjectConfig) error {
199
226
b .WriteString (e .String ())
200
227
b .WriteString ("\n " )
201
228
}
202
- return fmt . Errorf (strings .TrimSpace (b .String ()))
229
+ return errors . New (strings .TrimSpace (b .String ()))
203
230
}
204
231
205
232
for _ , port := range cfg .Ports {
@@ -523,7 +550,8 @@ const ProjectConfigJSONSchema = `{
523
550
"memory": {"type": "string"}
524
551
},
525
552
"additionalProperties": false
526
- }
553
+ },
554
+ "gpus": {"type": "string"}
527
555
},
528
556
"additionalProperties": false
529
557
}`
0 commit comments