Skip to content

Commit d9480b6

Browse files
committed
Mark LLMCredentials and TLSCACertBundle optional
This commit marks the LLMCredentials and TLSCACertBundle as optional. Also it ensures that when patching the OLSConfig Optional values are checked for nil. If an optional value is not set it won't be added into the patched OLSConfig.
1 parent 27baa8d commit d9480b6

8 files changed

Lines changed: 24 additions & 34 deletions

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11681,11 +11681,9 @@ spec:
1168111681
tlsCACertBundle:
1168211682
type: string
1168311683
required:
11684-
- llmCredentials
1168511684
- llmEndpoint
1168611685
- llmEndpointType
1168711686
- modelName
11688-
- tlsCACertBundle
1168911687
type: object
1169011688
type: object
1169111689
ovn:

apis/bases/lightspeed.openstack.org_openstacklightspeeds.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ spec:
4747
tlsCACertBundle:
4848
type: string
4949
required:
50-
- llmCredentials
5150
- llmEndpoint
5251
- llmEndpointType
5352
- modelName
5453
- ragImage
55-
- tlsCACertBundle
5654
type: object
5755
status:
5856
properties:

apis/lightspeed/v1beta1/openstacklightspeed_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ type OpenStackLightspeedCore struct {
5151
LLMEndpointType *string `json:"llmEndpointType"`
5252

5353
// +kubebuilder:validation:Required
54+
// Name of the model to use at the API endpoint provided in LLMEndpoint
55+
ModelName *string `json:"modelName"`
56+
57+
// +kubebuilder:validation:Optional
5458
// Secret name containing API token for the LLMEndpoint. The key for the field
5559
// in the secret that holds the token should be "apitoken".
5660
LLMCredentials *string `json:"llmCredentials"`
5761

58-
// +kubebuilder:validation:Required
59-
// Name of the model to use at the API endpoint provided in LLMEndpoint
60-
ModelName *string `json:"modelName"`
61-
62-
// +kubebuilder:validation:Required
62+
// +kubebuilder:validation:Optional
6363
// Configmap name containing a CA Certificates bundle
6464
TLSCACertBundle *string `json:"tlsCACertBundle"`
6565
}

apis/lightspeed/v1beta1/zz_generated.deepcopy.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindata/crds/crds.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11845,11 +11845,9 @@ spec:
1184511845
tlsCACertBundle:
1184611846
type: string
1184711847
required:
11848-
- llmCredentials
1184911848
- llmEndpoint
1185011849
- llmEndpointType
1185111850
- modelName
11852-
- tlsCACertBundle
1185311851
type: object
1185411852
type: object
1185511853
ovn:
@@ -20244,12 +20242,10 @@ spec:
2024420242
tlsCACertBundle:
2024520243
type: string
2024620244
required:
20247-
- llmCredentials
2024820245
- llmEndpoint
2024920246
- llmEndpointType
2025020247
- modelName
2025120248
- ragImage
20252-
- tlsCACertBundle
2025320249
type: object
2025420250
status:
2025520251
properties:

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11681,11 +11681,9 @@ spec:
1168111681
tlsCACertBundle:
1168211682
type: string
1168311683
required:
11684-
- llmCredentials
1168511684
- llmEndpoint
1168611685
- llmEndpointType
1168711686
- modelName
11688-
- tlsCACertBundle
1168911687
type: object
1169011688
type: object
1169111689
ovn:

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ spec:
4747
tlsCACertBundle:
4848
type: string
4949
required:
50-
- llmCredentials
5150
- llmEndpoint
5251
- llmEndpointType
5352
- modelName
5453
- ragImage
55-
- tlsCACertBundle
5654
type: object
5755
status:
5856
properties:

pkg/lightspeed/funcs.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,25 @@ func PatchOLSConfig(
117117
indexID string,
118118
) error {
119119
// 1. Patch the Providers section
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-
},
120+
providersConfig := map[string]interface{}{
121+
"models": []interface{}{
122+
map[string]interface{}{
123+
"name": StringPtrValue(instance.Spec.ModelName),
124+
"parameters": map[string]interface{}{},
130125
},
131-
"name": OpenStackLightspeedDefaultProvider,
132-
"type": StringPtrValue(instance.Spec.LLMEndpointType),
133-
"url": StringPtrValue(instance.Spec.LLMEndpoint),
134126
},
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+
}
135136
}
136137

138+
providersPatch := []interface{}{providersConfig}
137139
if err := uns.SetNestedSlice(olsConfig.Object, providersPatch, "spec", "llm", "providers"); err != nil {
138140
return err
139141
}

0 commit comments

Comments
 (0)