mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-12-23 01:24:24 +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
|
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)
|
backendSettings := o.getBackendSettings(backendConfig)
|
||||||
return o.isDockerEnabled(backendSettings, nil)
|
return o.isDockerEnabled(backendSettings, dockerEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCommand builds the command to run the backend
|
// 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
|
// 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
|
var args []string
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ func (o *Options) BuildCommandArgs(backendConfig *config.BackendConfig) []string
|
|||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.isDockerEnabled(backendSettings, nil) {
|
if o.isDockerEnabled(backendSettings, dockerEnabled) {
|
||||||
// For Docker, start with Docker args
|
// For Docker, start with Docker args
|
||||||
args = append(args, backendSettings.Docker.Args...)
|
args = append(args, backendSettings.Docker.Args...)
|
||||||
args = append(args, backendSettings.Docker.Image)
|
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
|
// 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)
|
backendSettings := o.getBackendSettings(backendConfig)
|
||||||
env := map[string]string{}
|
env := map[string]string{}
|
||||||
@@ -224,7 +224,7 @@ func (o *Options) BuildEnvironment(backendConfig *config.BackendConfig, environm
|
|||||||
maps.Copy(env, backendSettings.Environment)
|
maps.Copy(env, backendSettings.Environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.isDockerEnabled(backendSettings, nil) {
|
if o.isDockerEnabled(backendSettings, dockerEnabled) {
|
||||||
if backendSettings.Docker.Environment != nil {
|
if backendSettings.Docker.Environment != nil {
|
||||||
maps.Copy(env, backendSettings.Docker.Environment)
|
maps.Copy(env, backendSettings.Docker.Environment)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ func (i *Instance) buildCommandArgs() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return opts.BackendOptions.BuildCommandArgs(i.globalBackendSettings)
|
return opts.BackendOptions.BuildCommandArgs(i.globalBackendSettings, opts.DockerEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Instance) buildEnvironment() map[string]string {
|
func (i *Instance) buildEnvironment() map[string]string {
|
||||||
@@ -273,29 +273,21 @@ func (i *Instance) buildEnvironment() map[string]string {
|
|||||||
return nil
|
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
|
// MarshalJSON implements json.Marshaler for Instance
|
||||||
func (i *Instance) MarshalJSON() ([]byte, error) {
|
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 {
|
return json.Marshal(&struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status *status `json:"status"`
|
Status *status `json:"status"`
|
||||||
Created int64 `json:"created,omitempty"`
|
Created int64 `json:"created,omitempty"`
|
||||||
Options *options `json:"options,omitempty"`
|
Options *options `json:"options,omitempty"`
|
||||||
DockerEnabled bool `json:"docker_enabled,omitempty"`
|
|
||||||
}{
|
}{
|
||||||
Name: i.Name,
|
Name: i.Name,
|
||||||
Status: i.status,
|
Status: i.status,
|
||||||
Created: i.Created,
|
Created: i.Created,
|
||||||
Options: i.options,
|
Options: i.options,
|
||||||
DockerEnabled: dockerEnabled,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,12 +59,8 @@ function InstanceCard({
|
|||||||
// Fetch the most up-to-date instance data from the backend
|
// Fetch the most up-to-date instance data from the backend
|
||||||
const instanceData = await instancesApi.get(instance.name);
|
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)
|
// 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
|
// Create a blob and download link
|
||||||
const blob = new Blob([jsonString], { type: "application/json" });
|
const blob = new Blob([jsonString], { type: "application/json" });
|
||||||
@@ -101,7 +97,7 @@ function InstanceCard({
|
|||||||
|
|
||||||
{/* Badges row */}
|
{/* Badges row */}
|
||||||
<div className="flex items-center gap-2 flex-wrap">
|
<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} />}
|
{running && <HealthBadge health={health} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,5 +27,4 @@ export interface Instance {
|
|||||||
name: string;
|
name: string;
|
||||||
status: InstanceStatus;
|
status: InstanceStatus;
|
||||||
options?: CreateInstanceOptions;
|
options?: CreateInstanceOptions;
|
||||||
docker_enabled?: boolean; // indicates backend is running via Docker
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user