Skip to content

Commit ae177db

Browse files
feat: PAAL-123 fix linter issues
1 parent 0e5c8c6 commit ae177db

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

internal/controller/agent_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141
agentContainerName = "agent"
4242
agentCardEndpoint = "/.well-known/agent-card.json"
4343
a2aAgentCardEndpoint = "/a2a/.well-known/agent-card.json"
44+
a2AProtocol = "A2A"
4445
)
4546

4647
// AgentReconciler reconciles a Agent object
@@ -361,7 +362,8 @@ func (r *AgentReconciler) mergeEnvironmentVariables(templateEnvVars, userEnvVars
361362
// hasA2AProtocol checks if the agent has A2A protocol configured
362363
func (r *AgentReconciler) hasA2AProtocol(agent *runtimev1alpha1.Agent) bool {
363364
for _, protocol := range agent.Spec.Protocols {
364-
if protocol.Type == "A2A" {
365+
366+
if protocol.Type == a2AProtocol {
365367
return true
366368
}
367369
}
@@ -381,7 +383,7 @@ func (r *AgentReconciler) hasOpenAIProtocol(agent *runtimev1alpha1.Agent) bool {
381383
// getA2AProtocol returns the first A2A protocol configuration found
382384
func (r *AgentReconciler) getA2AProtocol(agent *runtimev1alpha1.Agent) *runtimev1alpha1.AgentProtocol {
383385
for _, protocol := range agent.Spec.Protocols {
384-
if protocol.Type == "A2A" {
386+
if protocol.Type == a2AProtocol {
385387
return &protocol
386388
}
387389
}
@@ -847,7 +849,7 @@ func (r *AgentReconciler) sanitizeAgentName(name string) string {
847849
func (r *AgentReconciler) buildA2AAgentCardUrl(agent *runtimev1alpha1.Agent) string {
848850
// Find the A2A protocol
849851
for _, protocol := range agent.Spec.Protocols {
850-
if protocol.Type == "A2A" {
852+
if protocol.Type == a2AProtocol {
851853
return fmt.Sprintf("http://%s.%s.svc.cluster.local:%d%s",
852854
agent.Name, agent.Namespace, protocol.Port, protocol.Path)
853855
}

internal/controller/agent_controller_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"fmt"
2222

2323
webhookv1alpha1 "github.com/agentic-layer/agent-runtime-operator/internal/webhook/v1alpha1"
24-
. "github.com/onsi/ginkgo/v2"
25-
. "github.com/onsi/gomega"
2624
appsv1 "k8s.io/api/apps/v1"
2725
corev1 "k8s.io/api/core/v1"
2826
"k8s.io/apimachinery/pkg/api/errors"
@@ -144,7 +142,7 @@ var _ = Describe("Agent Controller", func() {
144142
probe := reconciler.generateReadinessProbe(agent)
145143
Expect(probe).NotTo(BeNil())
146144
Expect(probe.HTTPGet).NotTo(BeNil())
147-
Expect(probe.HTTPGet.Path).To(Equal(fmt.Sprintf(a2aAgentCardEndpoint)))
145+
Expect(probe.HTTPGet.Path).To(Equal(a2aAgentCardEndpoint))
148146
Expect(probe.HTTPGet.Port.IntValue()).To(Equal(8000))
149147
Expect(probe.InitialDelaySeconds).To(Equal(int32(10)))
150148
})
@@ -178,7 +176,7 @@ var _ = Describe("Agent Controller", func() {
178176
probe := reconciler.generateReadinessProbe(agent)
179177
Expect(probe).NotTo(BeNil())
180178
Expect(probe.HTTPGet).NotTo(BeNil())
181-
Expect(probe.HTTPGet.Path).To(Equal(fmt.Sprintf(a2aAgentCardEndpoint)))
179+
Expect(probe.HTTPGet.Path).To(Equal(a2aAgentCardEndpoint))
182180
})
183181

184182
It("should return nil probe for agents with no recognized protocols", func() {
@@ -242,7 +240,7 @@ var _ = Describe("Agent Controller", func() {
242240
Expect(probe).NotTo(BeNil())
243241
Expect(probe.HTTPGet).NotTo(BeNil())
244242
Expect(probe.HTTPGet.Port.IntValue()).To(Equal(3000))
245-
Expect(probe.HTTPGet.Path).To(Equal(fmt.Sprintf(a2aAgentCardEndpoint)))
243+
Expect(probe.HTTPGet.Path).To(Equal(a2aAgentCardEndpoint))
246244
})
247245

248246
It("should use custom port from OpenAI protocol", func() {
@@ -304,7 +302,7 @@ var _ = Describe("Agent Controller", func() {
304302
probe := reconciler.generateReadinessProbe(agent)
305303
Expect(probe).NotTo(BeNil())
306304
Expect(probe.HTTPGet).NotTo(BeNil())
307-
Expect(probe.HTTPGet.Path).To(Equal(fmt.Sprintf(a2aAgentCardEndpoint)))
305+
Expect(probe.HTTPGet.Path).To(Equal(a2aAgentCardEndpoint))
308306
Expect(probe.HTTPGet.Port.IntValue()).To(Equal(8000))
309307
})
310308

@@ -426,11 +424,11 @@ var _ = Describe("Agent Controller", func() {
426424
// Test with unspecified path field (should use default /a2a)
427425
protocolNoPath := &runtimev1alpha1.AgentProtocol{Type: "A2A"}
428426
pathDefault := reconciler.getA2AHealthPath(protocolNoPath)
429-
Expect(pathDefault).To(Equal(fmt.Sprintf(a2aAgentCardEndpoint)))
427+
Expect(pathDefault).To(Equal(a2aAgentCardEndpoint))
430428

431429
// Test with nil protocol (should use default)
432430
pathNil := reconciler.getA2AHealthPath(nil)
433-
Expect(pathNil).To(Equal(fmt.Sprintf(a2aAgentCardEndpoint)))
431+
Expect(pathNil).To(Equal(a2aAgentCardEndpoint))
434432
})
435433
})
436434

@@ -659,7 +657,7 @@ var _ = Describe("Agent Controller", func() {
659657
desiredContainer := reconciler.findAgentContainer(desiredDeployment.Spec.Template.Spec.Containers)
660658

661659
Expect(existingContainer.ReadinessProbe.HTTPGet.Path).To(Equal("/health"))
662-
Expect(desiredContainer.ReadinessProbe.HTTPGet.Path).To(Equal(fmt.Sprintf(a2aAgentCardEndpoint)))
660+
Expect(desiredContainer.ReadinessProbe.HTTPGet.Path).To(Equal(a2aAgentCardEndpoint))
663661
})
664662

665663
It("should not trigger update when probes are identical", func() {

0 commit comments

Comments
 (0)