Skip to content

Commit 0c5f422

Browse files
committed
Add Goose model field and update config paths
Add a dedicated Model field to GooseConfig so the Goose AI model can be set declaratively in the OpenStackAssistant CR spec rather than requiring it to be passed as a raw env var. When set, the controller injects the GOOSE_MODEL environment variable into the pod. Update the entrypoint script to use $HOME/.config/goose/ instead of ~/.goose/ for Goose configuration paths, aligning with the XDG base directory convention used by newer Goose versions.
1 parent 880dee3 commit 0c5f422

7 files changed

Lines changed: 53 additions & 10 deletions

File tree

api/assistant/v1beta1/openstackassistant_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ type LightspeedStackSpec struct {
5454

5555
// GooseConfig defines Goose-specific provider configuration
5656
type GooseConfig struct {
57+
// Model is the model identifier for the Goose AI agent
58+
// (e.g., "gemini/models/gemini-2.5-flash"). Sets the GOOSE_MODEL env var.
59+
// +kubebuilder:validation:Optional
60+
Model string `json:"model,omitempty"`
61+
5762
// Recipes is a ConfigMap name containing Goose recipe YAML files.
5863
// Each key in the ConfigMap becomes a recipe file registered as a
5964
// Goose slash command (e.g., /cluster-health).

api/bases/assistant.openstack.org_openstackassistants.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ spec:
188188
The ConfigMap must have a key "hints" with the content that
189189
will be written to ~/.goosehints in the pod.
190190
type: string
191+
model:
192+
description: |-
193+
Model is the model identifier for the Goose AI agent
194+
(e.g., "gemini/models/gemini-2.5-flash"). Sets the GOOSE_MODEL env var.
195+
type: string
191196
recipes:
192197
description: |-
193198
Recipes is a ConfigMap name containing Goose recipe YAML files.

bindata/crds/crds.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ spec:
187187
The ConfigMap must have a key "hints" with the content that
188188
will be written to ~/.goosehints in the pod.
189189
type: string
190+
model:
191+
description: |-
192+
Model is the model identifier for the Goose AI agent
193+
(e.g., "gemini/models/gemini-2.5-flash"). Sets the GOOSE_MODEL env var.
194+
type: string
190195
recipes:
191196
description: |-
192197
Recipes is a ConfigMap name containing Goose recipe YAML files.

config/crd/bases/assistant.openstack.org_openstackassistants.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ spec:
188188
The ConfigMap must have a key "hints" with the content that
189189
will be written to ~/.goosehints in the pod.
190190
type: string
191+
model:
192+
description: |-
193+
Model is the model identifier for the Goose AI agent
194+
(e.g., "gemini/models/gemini-2.5-flash"). Sets the GOOSE_MODEL env var.
195+
type: string
191196
recipes:
192197
description: |-
193198
Recipes is a ConfigMap name containing Goose recipe YAML files.

hack/clean_local_webhook.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ oc delete validatingwebhookconfiguration/vopenstackdataplaneservice.kb.io --igno
1313
oc delete mutatingwebhookconfiguration/mopenstackdataplanenodeset.kb.io --ignore-not-found
1414
oc delete mutatingwebhookconfiguration/mopenstackdataplaneservice.kb.io --ignore-not-found
1515
oc delete mutatingwebhookconfiguration/mopenstackdataplanedeployment.kb.io --ignore-not-found
16+
oc delete validatingwebhookconfiguration/vopenstackassistant-v1beta1.kb.io --ignore-not-found
17+
oc delete mutatingwebhookconfiguration/mopenstackassistant-v1beta1.kb.io --ignore-not-found

internal/openstackassistant/funcs.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ func EntrypointScript() string {
2727
set -eu
2828
2929
# Create goose config directory
30-
mkdir -p ~/.goose/config/profiles/default/custom_providers
30+
mkdir -p $HOME/.config/goose/custom_providers
3131
3232
# Write goose config.yaml
33-
cat > ~/.goose/config/profiles/default/config.yaml <<'GOOSE_CONFIG'
33+
cat > $HOME/.config/goose/config.yaml <<'GOOSE_CONFIG'
3434
extensions:
3535
developer:
3636
enabled: true
@@ -68,10 +68,10 @@ if [ -d /tmp/recipes ]; then
6868
basename=$(basename "$recipe")
6969
# Strip extension to get the command name
7070
cmdname="${basename%.*}"
71-
echo " ${cmdname}:" >> ~/.goose/config/profiles/default/config.yaml
72-
echo " type: recipe" >> ~/.goose/config/profiles/default/config.yaml
73-
echo " enabled: true" >> ~/.goose/config/profiles/default/config.yaml
74-
echo " recipe_source: ${recipe}" >> ~/.goose/config/profiles/default/config.yaml
71+
echo " ${cmdname}:" >> $HOME/.config/goose/config.yaml
72+
echo " type: recipe" >> $HOME/.config/goose/config.yaml
73+
echo " enabled: true" >> $HOME/.config/goose/config.yaml
74+
echo " recipe_source: ${recipe}" >> $HOME/.config/goose/config.yaml
7575
done
7676
fi
7777
@@ -82,7 +82,7 @@ fi
8282
8383
# Copy lightspeed provider config
8484
if [ -f /tmp/lightspeed-provider/lightspeed.json ]; then
85-
cp /tmp/lightspeed-provider/lightspeed.json ~/.goose/config/profiles/default/custom_providers/lightspeed.json
85+
cp /tmp/lightspeed-provider/lightspeed.json $HOME/.config/goose/custom_providers/lightspeed.json
8686
fi
8787
8888
exec sleep infinity
@@ -100,6 +100,10 @@ func AssistantPodSpec(
100100
envVars["GOOSE_TELEMETRY_ENABLED"] = env.SetValue("false")
101101
envVars["GOOSE_DISABLE_KEYRING"] = env.SetValue("1")
102102

103+
if instance.Spec.Goose != nil && instance.Spec.Goose.Model != "" {
104+
envVars["GOOSE_MODEL"] = env.SetValue(instance.Spec.Goose.Model)
105+
}
106+
103107
if instance.Spec.Env != nil {
104108
for idx := range instance.Spec.Env {
105109
e := instance.Spec.Env[idx]

internal/openstackassistant/funcs_test.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestEntrypointScript(t *testing.T) {
4646
script := EntrypointScript()
4747

4848
g.Expect(script).To(ContainSubstring("#!/bin/sh"))
49-
g.Expect(script).To(ContainSubstring("mkdir -p ~/.goose/config/profiles/default/custom_providers"))
49+
g.Expect(script).To(ContainSubstring("mkdir -p $HOME/.config/goose/custom_providers"))
5050
g.Expect(script).To(ContainSubstring("config.yaml"))
5151
g.Expect(script).To(ContainSubstring("developer:"))
5252
g.Expect(script).To(ContainSubstring("enabled: true"))
@@ -103,11 +103,29 @@ func TestAssistantPodSpec_DefaultEnvVars(t *testing.T) {
103103
g.Expect(envMap).To(HaveKeyWithValue("GOOSE_DISABLE_KEYRING", "1"))
104104
}
105105

106+
func TestAssistantPodSpec_GooseModel(t *testing.T) {
107+
g := NewWithT(t)
108+
instance := newTestInstance()
109+
instance.Spec.Goose = &assistantv1.GooseConfig{
110+
Model: "gemini/models/gemini-2.5-flash",
111+
}
112+
113+
spec := AssistantPodSpec(instance, "hash")
114+
envVars := spec.Containers[0].Env
115+
116+
envMap := make(map[string]string)
117+
for _, e := range envVars {
118+
envMap[e.Name] = e.Value
119+
}
120+
121+
g.Expect(envMap).To(HaveKeyWithValue("GOOSE_MODEL", "gemini/models/gemini-2.5-flash"))
122+
g.Expect(envMap).To(HaveKeyWithValue("GOOSE_PROVIDER", "lightspeed"))
123+
}
124+
106125
func TestAssistantPodSpec_CustomEnvVars(t *testing.T) {
107126
g := NewWithT(t)
108127
instance := newTestInstance()
109128
instance.Spec.Env = []corev1.EnvVar{
110-
{Name: "GOOSE_MODEL", Value: "gemini/models/gemini-2.5-flash"},
111129
{Name: "LIGHTSPEED_API_KEY", Value: "dummy"},
112130
}
113131

@@ -119,7 +137,6 @@ func TestAssistantPodSpec_CustomEnvVars(t *testing.T) {
119137
envMap[e.Name] = e.Value
120138
}
121139

122-
g.Expect(envMap).To(HaveKeyWithValue("GOOSE_MODEL", "gemini/models/gemini-2.5-flash"))
123140
g.Expect(envMap).To(HaveKeyWithValue("LIGHTSPEED_API_KEY", "dummy"))
124141
g.Expect(envMap).To(HaveKeyWithValue("GOOSE_PROVIDER", "lightspeed"))
125142
}

0 commit comments

Comments
 (0)