Skip to content

Commit

Permalink
extend AISettings with ScmConnection (#1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz authored Jan 10, 2025
1 parent 3529d9b commit bd06226
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,56 @@ spec:
- BEDROCK
- VERTEX
type: string
tools:
properties:
createPr:
properties:
scmConnectionRef:
description: ScmConnectionRef the SCM connection to use
for pr automations
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
type: object
type: object
vertex:
description: Vertex holds configuration for using GCP VertexAI
to generate LLM insights
Expand Down
28 changes: 28 additions & 0 deletions go/controller/api/v1alpha1/deploymentsettings_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ type AISettings struct {
// +kubebuilder:validation:Optional
Enabled *bool `json:"enabled,omitempty"`

// +kubebuilder:validation:Optional
Tools *Tools `json:"tools,omitempty"`

// Provider defines which of the supported LLM providers should be used.
//
// +kubebuilder:validation:Enum=OPENAI;ANTHROPIC;OLLAMA;AZURE;BEDROCK;VERTEX
Expand Down Expand Up @@ -317,6 +320,15 @@ type AISettings struct {
Vertex *VertexSettings `json:"vertex,omitempty"`
}

type Tools struct {
CreatePr *CreatePr `json:"createPr,omitempty"`
}

type CreatePr struct {
// ScmConnectionRef the SCM connection to use for pr automations
ScmConnectionRef *corev1.ObjectReference `json:"scmConnectionRef,omitempty"`
}

func (in *LoggingSettings) Attributes(ctx context.Context, c client.Client, namespace string) (*console.LoggingSettingsAttributes, error) {
attr := &console.LoggingSettingsAttributes{
Enabled: in.Enabled,
Expand Down Expand Up @@ -349,6 +361,22 @@ func (in *AISettings) Attributes(ctx context.Context, c client.Client, namespace
ToolProvider: in.ToolProvider,
}

if in.Tools != nil && in.Tools.CreatePr != nil {
if in.Tools.CreatePr.ScmConnectionRef != nil {
scm := in.Tools.CreatePr.ScmConnectionRef
connection := &ScmConnection{}
if err := c.Get(ctx, types.NamespacedName{Name: scm.Name, Namespace: scm.Namespace}, connection); err != nil {
return nil, err
}

attr.Tools = &console.ToolConfigAttributes{
CreatePr: &console.CreatePrConfigAttributes{
ConnectionID: connection.Status.ID,
},
}
}
}

switch *in.Provider {
case console.AiProviderOpenai:
if in.OpenAI == nil {
Expand Down
45 changes: 45 additions & 0 deletions go/controller/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,56 @@ spec:
- BEDROCK
- VERTEX
type: string
tools:
properties:
createPr:
properties:
scmConnectionRef:
description: ScmConnectionRef the SCM connection to use
for pr automations
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
type: object
type: object
vertex:
description: Vertex holds configuration for using GCP VertexAI
to generate LLM insights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,56 @@ spec:
- BEDROCK
- VERTEX
type: string
tools:
properties:
createPr:
properties:
scmConnectionRef:
description: ScmConnectionRef the SCM connection to use
for pr automations
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
type: object
type: object
vertex:
description: Vertex holds configuration for using GCP VertexAI
to generate LLM insights
Expand Down

0 comments on commit bd06226

Please sign in to comment.