Skip to content

Commit b4f943b

Browse files
authored
Add managed-by label for Authorino to API key secrets (#23)
API key Secrets created by the key-manager include the label `authorino.kuadrant.io/managed-by=authorino`. This makes new secrets immediately discoverable by Authorino without requiring a hot-reload. Signed-off-by: Brent Salisbury <bsalisbu@redhat.com>
1 parent 876f666 commit b4f943b

File tree

19 files changed

+93
-121
lines changed

19 files changed

+93
-121
lines changed

deployment/kuadrant-openshift/key-manager/04-token-rate-limit-policy.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ metadata:
88
name: gateway-default-unlimited
99
namespace: llm
1010
labels:
11-
maas/managed-by: "key-manager"
1211
maas/resource-type: "default-rate-limit"
1312
annotations:
1413
maas/description: "Default unlimited rate policy - teams can override with specific limits"

deployment/kuadrant-openshift/key-manager/internal/auth/middleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ func getEnvOrDefault(key, defaultValue string) string {
5656
return value
5757
}
5858
return defaultValue
59-
}
59+
}

deployment/kuadrant-openshift/key-manager/internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ func getEnvOrDefault(key, defaultValue string) string {
5050
return value
5151
}
5252
return defaultValue
53-
}
53+
}

deployment/kuadrant-openshift/key-manager/internal/handlers/health.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ func NewHealthHandler() *HealthHandler {
1717
// HealthCheck handles GET /health
1818
func (h *HealthHandler) HealthCheck(c *gin.Context) {
1919
c.JSON(http.StatusOK, gin.H{"status": "healthy"})
20-
}
20+
}

deployment/kuadrant-openshift/key-manager/internal/handlers/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ func (h *KeysHandler) ListUserKeys(c *gin.Context) {
131131
"keys": keys,
132132
"total_keys": len(keys),
133133
})
134-
}
134+
}

deployment/kuadrant-openshift/key-manager/internal/handlers/legacy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ func (h *LegacyHandler) DeleteKey(c *gin.Context) {
7979
"message": "API key deleted successfully",
8080
"secret_name": secretName,
8181
})
82-
}
82+
}

deployment/kuadrant-openshift/key-manager/internal/handlers/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ func (h *ModelsHandler) ListModels(c *gin.Context) {
3535
}
3636

3737
c.JSON(http.StatusOK, response)
38-
}
38+
}

deployment/kuadrant-openshift/key-manager/internal/handlers/teams.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ func (h *TeamsHandler) DeleteTeam(c *gin.Context) {
143143

144144
log.Printf("Team deleted successfully: %s", teamID)
145145
c.JSON(http.StatusOK, gin.H{"message": "Team deleted successfully", "team_id": teamID})
146-
}
146+
}

deployment/kuadrant-openshift/key-manager/internal/handlers/usage.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type UsageHandler struct {
2626
// NewUsageHandler creates a new usage handler
2727
func NewUsageHandler(clientset *kubernetes.Clientset, config *rest.Config, keyNamespace string) *UsageHandler {
2828
collector := usage.NewCollector(clientset, config, keyNamespace)
29-
29+
3030
return &UsageHandler{
3131
clientset: clientset,
3232
config: config,
@@ -108,11 +108,11 @@ func (h *UsageHandler) enrichUserUsage(userUsage *types.UserUsage) error {
108108
}
109109

110110
// Create policy -> team mapping
111-
policyToTeam := make(map[string]struct{
111+
policyToTeam := make(map[string]struct {
112112
teamID string
113113
teamName string
114114
})
115-
115+
116116
for _, secret := range secrets.Items {
117117
policy := secret.Annotations["maas/policy"]
118118
if policy != "" {
@@ -141,9 +141,9 @@ func (h *UsageHandler) enrichUserUsage(userUsage *types.UserUsage) error {
141141
func (h *UsageHandler) enrichTeamUsage(teamUsage *types.TeamUsage) error {
142142
for i, userUsage := range teamUsage.UserBreakdown {
143143
// Find user's API key secret to get email
144-
labelSelector := fmt.Sprintf("kuadrant.io/apikeys-by=rhcl-keys,maas/team-id=%s,maas/user-id=%s",
144+
labelSelector := fmt.Sprintf("kuadrant.io/apikeys-by=rhcl-keys,maas/team-id=%s,maas/user-id=%s",
145145
teamUsage.TeamID, userUsage.UserID)
146-
146+
147147
secrets, err := h.clientset.CoreV1().Secrets(h.keyNamespace).List(
148148
context.Background(), metav1.ListOptions{LabelSelector: labelSelector})
149149
if err != nil {
@@ -160,4 +160,4 @@ func (h *UsageHandler) enrichTeamUsage(teamUsage *types.TeamUsage) error {
160160
}
161161

162162
return nil
163-
}
163+
}

deployment/kuadrant-openshift/key-manager/internal/keys/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ func isValidUserID(userID string) bool {
3434
// ValidateUserID validates a user ID using Kubernetes naming rules
3535
func ValidateUserID(userID string) bool {
3636
return isValidUserID(userID)
37-
}
37+
}

0 commit comments

Comments
 (0)