mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-12-22 17:14:22 +00:00
Fix docker_enabled inconsistency
This commit is contained in:
@@ -163,9 +163,9 @@ func (o *Options) isDockerEnabled(backend *config.BackendSettings, dockerEnabled
|
||||
return backend.Docker.Enabled
|
||||
}
|
||||
|
||||
func (o *Options) IsDockerEnabled(backendConfig *config.BackendConfig) bool {
|
||||
func (o *Options) IsDockerEnabled(backendConfig *config.BackendConfig, dockerEnabled *bool) bool {
|
||||
backendSettings := o.getBackendSettings(backendConfig)
|
||||
return o.isDockerEnabled(backendSettings, nil)
|
||||
return o.isDockerEnabled(backendSettings, dockerEnabled)
|
||||
}
|
||||
|
||||
// GetCommand builds the command to run the backend
|
||||
@@ -189,7 +189,7 @@ func (o *Options) GetCommand(backendConfig *config.BackendConfig, dockerEnabled
|
||||
}
|
||||
|
||||
// buildCommandArgs builds command line arguments for the backend
|
||||
func (o *Options) BuildCommandArgs(backendConfig *config.BackendConfig) []string {
|
||||
func (o *Options) BuildCommandArgs(backendConfig *config.BackendConfig, dockerEnabled *bool) []string {
|
||||
|
||||
var args []string
|
||||
|
||||
@@ -199,7 +199,7 @@ func (o *Options) BuildCommandArgs(backendConfig *config.BackendConfig) []string
|
||||
return args
|
||||
}
|
||||
|
||||
if o.isDockerEnabled(backendSettings, nil) {
|
||||
if o.isDockerEnabled(backendSettings, dockerEnabled) {
|
||||
// For Docker, start with Docker args
|
||||
args = append(args, backendSettings.Docker.Args...)
|
||||
args = append(args, backendSettings.Docker.Image)
|
||||
@@ -215,7 +215,7 @@ func (o *Options) BuildCommandArgs(backendConfig *config.BackendConfig) []string
|
||||
}
|
||||
|
||||
// BuildEnvironment builds the environment variables for the backend process
|
||||
func (o *Options) BuildEnvironment(backendConfig *config.BackendConfig, environment map[string]string) map[string]string {
|
||||
func (o *Options) BuildEnvironment(backendConfig *config.BackendConfig, dockerEnabled *bool, environment map[string]string) map[string]string {
|
||||
|
||||
backendSettings := o.getBackendSettings(backendConfig)
|
||||
env := map[string]string{}
|
||||
@@ -224,7 +224,7 @@ func (o *Options) BuildEnvironment(backendConfig *config.BackendConfig, environm
|
||||
maps.Copy(env, backendSettings.Environment)
|
||||
}
|
||||
|
||||
if o.isDockerEnabled(backendSettings, nil) {
|
||||
if o.isDockerEnabled(backendSettings, dockerEnabled) {
|
||||
if backendSettings.Docker.Environment != nil {
|
||||
maps.Copy(env, backendSettings.Docker.Environment)
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ func (i *Instance) buildCommandArgs() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
return opts.BackendOptions.BuildCommandArgs(i.globalBackendSettings)
|
||||
return opts.BackendOptions.BuildCommandArgs(i.globalBackendSettings, opts.DockerEnabled)
|
||||
}
|
||||
|
||||
func (i *Instance) buildEnvironment() map[string]string {
|
||||
@@ -273,29 +273,21 @@ func (i *Instance) buildEnvironment() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
return opts.BackendOptions.BuildEnvironment(i.globalBackendSettings, opts.Environment)
|
||||
return opts.BackendOptions.BuildEnvironment(i.globalBackendSettings, opts.DockerEnabled, opts.Environment)
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler for Instance
|
||||
func (i *Instance) MarshalJSON() ([]byte, error) {
|
||||
// Get options
|
||||
opts := i.GetOptions()
|
||||
|
||||
// Determine if docker is enabled for this instance's backend
|
||||
dockerEnabled := opts.BackendOptions.IsDockerEnabled(i.globalBackendSettings)
|
||||
|
||||
return json.Marshal(&struct {
|
||||
Name string `json:"name"`
|
||||
Status *status `json:"status"`
|
||||
Created int64 `json:"created,omitempty"`
|
||||
Options *options `json:"options,omitempty"`
|
||||
DockerEnabled bool `json:"docker_enabled,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Status *status `json:"status"`
|
||||
Created int64 `json:"created,omitempty"`
|
||||
Options *options `json:"options,omitempty"`
|
||||
}{
|
||||
Name: i.Name,
|
||||
Status: i.status,
|
||||
Created: i.Created,
|
||||
Options: i.options,
|
||||
DockerEnabled: dockerEnabled,
|
||||
Name: i.Name,
|
||||
Status: i.status,
|
||||
Created: i.Created,
|
||||
Options: i.options,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -59,12 +59,8 @@ function InstanceCard({
|
||||
// Fetch the most up-to-date instance data from the backend
|
||||
const instanceData = await instancesApi.get(instance.name);
|
||||
|
||||
// Remove docker_enabled as it's a computed field, not persisted to disk
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { docker_enabled, ...persistedData } = instanceData;
|
||||
|
||||
// Convert to JSON string with pretty formatting (matching backend format)
|
||||
const jsonString = JSON.stringify(persistedData, null, 2);
|
||||
const jsonString = JSON.stringify(instanceData, null, 2);
|
||||
|
||||
// Create a blob and download link
|
||||
const blob = new Blob([jsonString], { type: "application/json" });
|
||||
@@ -101,7 +97,7 @@ function InstanceCard({
|
||||
|
||||
{/* Badges row */}
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<BackendBadge backend={instance.options?.backend_type} docker={instance.docker_enabled} />
|
||||
<BackendBadge backend={instance.options?.backend_type} docker={instance.options?.docker_enabled} />
|
||||
{running && <HealthBadge health={health} />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,5 +27,4 @@ export interface Instance {
|
||||
name: string;
|
||||
status: InstanceStatus;
|
||||
options?: CreateInstanceOptions;
|
||||
docker_enabled?: boolean; // indicates backend is running via Docker
|
||||
}
|
||||
Reference in New Issue
Block a user