Skip to content

Commit 98aa813

Browse files
committed
Mark llmCredentials as required
The llmCredentials parameter is required in OLSConfig and therefore should remain as required in our CRD as well. Also, do not pass the tlsCACertBundle value to OLSConfig when it is nil as it is an optional parameter.
1 parent d9480b6 commit 98aa813

7 files changed

Lines changed: 27 additions & 21 deletions

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11681,6 +11681,7 @@ spec:
1168111681
tlsCACertBundle:
1168211682
type: string
1168311683
required:
11684+
- llmCredentials
1168411685
- llmEndpoint
1168511686
- llmEndpointType
1168611687
- modelName

apis/bases/lightspeed.openstack.org_openstacklightspeeds.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ spec:
4747
tlsCACertBundle:
4848
type: string
4949
required:
50+
- llmCredentials
5051
- llmEndpoint
5152
- llmEndpointType
5253
- modelName

apis/lightspeed/v1beta1/openstacklightspeed_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type OpenStackLightspeedCore struct {
5454
// Name of the model to use at the API endpoint provided in LLMEndpoint
5555
ModelName *string `json:"modelName"`
5656

57+
// +kubebuilder:validation:Required
5758
// +kubebuilder:validation:Optional
5859
// Secret name containing API token for the LLMEndpoint. The key for the field
5960
// in the secret that holds the token should be "apitoken".

bindata/crds/crds.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11845,6 +11845,7 @@ spec:
1184511845
tlsCACertBundle:
1184611846
type: string
1184711847
required:
11848+
- llmCredentials
1184811849
- llmEndpoint
1184911850
- llmEndpointType
1185011851
- modelName
@@ -20242,6 +20243,7 @@ spec:
2024220243
tlsCACertBundle:
2024320244
type: string
2024420245
required:
20246+
- llmCredentials
2024520247
- llmEndpoint
2024620248
- llmEndpointType
2024720249
- modelName

config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11681,6 +11681,7 @@ spec:
1168111681
tlsCACertBundle:
1168211682
type: string
1168311683
required:
11684+
- llmCredentials
1168411685
- llmEndpoint
1168511686
- llmEndpointType
1168611687
- modelName

config/crd/bases/lightspeed.openstack.org_openstacklightspeeds.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ spec:
4747
tlsCACertBundle:
4848
type: string
4949
required:
50+
- llmCredentials
5051
- llmEndpoint
5152
- llmEndpointType
5253
- modelName

pkg/lightspeed/funcs.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,22 @@ func PatchOLSConfig(
117117
indexID string,
118118
) error {
119119
// 1. Patch the Providers section
120-
providersConfig := map[string]interface{}{
121-
"models": []interface{}{
122-
map[string]interface{}{
123-
"name": StringPtrValue(instance.Spec.ModelName),
124-
"parameters": map[string]interface{}{},
120+
providersPatch := []interface{}{
121+
map[string]interface{}{
122+
"credentialsSecretRef": map[string]interface{}{
123+
"name": StringPtrValue(instance.Spec.LLMCredentials),
124+
},
125+
"models": []interface{}{
126+
map[string]interface{}{
127+
"name": StringPtrValue(instance.Spec.ModelName),
128+
"parameters": map[string]interface{}{},
129+
},
125130
},
131+
"name": OpenStackLightspeedDefaultProvider,
132+
"type": StringPtrValue(instance.Spec.LLMEndpointType),
133+
"url": StringPtrValue(instance.Spec.LLMEndpoint),
126134
},
127-
"name": OpenStackLightspeedDefaultProvider,
128-
"type": StringPtrValue(instance.Spec.LLMEndpointType),
129-
"url": StringPtrValue(instance.Spec.LLMEndpoint),
130-
}
131-
132-
if instance.Spec.LLMCredentials != nil {
133-
providersConfig["credentialsSecretRef"] = map[string]interface{}{
134-
"name": StringPtrValue(instance.Spec.LLMCredentials),
135-
}
136135
}
137-
138-
providersPatch := []interface{}{providersConfig}
139136
if err := uns.SetNestedSlice(olsConfig.Object, providersPatch, "spec", "llm", "providers"); err != nil {
140137
return err
141138
}
@@ -153,14 +150,16 @@ func PatchOLSConfig(
153150
return err
154151
}
155152

156-
tlsCaCertBundle := StringPtrValue(instance.Spec.TLSCACertBundle)
157-
err := uns.SetNestedField(olsConfig.Object, tlsCaCertBundle, "spec", "ols", "additionalCAConfigMapRef", "name")
158-
if err != nil {
159-
return err
153+
if instance.Spec.TLSCACertBundle != nil {
154+
tlsCaCertBundle := StringPtrValue(instance.Spec.TLSCACertBundle)
155+
err := uns.SetNestedField(olsConfig.Object, tlsCaCertBundle, "spec", "ols", "additionalCAConfigMapRef", "name")
156+
if err != nil {
157+
return err
158+
}
160159
}
161160

162161
modelName := StringPtrValue(instance.Spec.ModelName)
163-
err = uns.SetNestedField(olsConfig.Object, modelName, "spec", "ols", "defaultModel")
162+
err := uns.SetNestedField(olsConfig.Object, modelName, "spec", "ols", "defaultModel")
164163
if err != nil {
165164
return err
166165
}

0 commit comments

Comments
 (0)