Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions api/v1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ package v1
import (
"errors"
"fmt"
"strconv"

"kmodules.xyz/client-go/policy/secomp"
appcatalog "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1"

"gomodules.xyz/pointer"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
)

Expand Down Expand Up @@ -137,3 +139,39 @@ func (c *ConnectionSpec) ToAppBinding() (*appcatalog.AppBinding, error) {
}
return &app, nil
}

func (svc ServiceSpec) ObjectKey() types.NamespacedName {
return types.NamespacedName{
Name: svc.Name,
Namespace: svc.Namespace,
}
}

func (svc ServiceSpec) ToServiceReference() (*appcatalog.ServiceReference, error) {
ref := appcatalog.ServiceReference{
Scheme: svc.Scheme,
Namespace: svc.Namespace,
Name: svc.Name,
Port: -1,
Path: svc.Path,
Query: svc.Query,
}
if port, ok := IsValidPort(svc.Port); ok {
ref.Port = int32(port)
} else {
return nil, fmt.Errorf("invalid service port: %q", svc.Port)
}
return &ref, nil
}

// IsValidPort checks if a string is a valid port number (0-65535).
func IsValidPort(portStr string) (int, bool) {
port, err := strconv.Atoi(portStr)
if err != nil {
return -1, false
}
if port >= 0 && port <= 65535 {
return port, true
}
return -1, false
}
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module kmodules.xyz/monitoring-agent-api

go 1.24.0

toolchain go1.24.1

require (
github.com/evanphx/json-patch v5.9.11+incompatible
github.com/gobuffalo/flect v1.0.3
Expand All @@ -26,13 +24,13 @@ require (
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
kmodules.xyz/client-go v0.34.2
kmodules.xyz/custom-resources v0.32.3-0.20251226151909-e0c7e447f3de
kmodules.xyz/client-go v0.34.4
kmodules.xyz/custom-resources v0.34.0
sigs.k8s.io/controller-runtime v0.22.4
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
filippo.io/edwards25519 v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/PuerkitoBio/purell v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -85,7 +83,7 @@ require (
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.31.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/time v0.13.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw=
filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/PuerkitoBio/purell v1.2.1 h1:QsZ4TjvwiMpat6gBCBxEQI0rcS9ehtkKtSpiUnd9N28=
Expand Down Expand Up @@ -210,8 +210,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -277,10 +277,10 @@ k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzk
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/client-go v0.34.2 h1:2Cec+nyfj9kfbR+5KPK3AksxN6h4jSjhn/tw+Dhqggo=
kmodules.xyz/client-go v0.34.2/go.mod h1:kQRuGMxhb+B9rVdcfBzjK+PV7oBDo+SaDiQ66u1QG+4=
kmodules.xyz/custom-resources v0.32.3-0.20251226151909-e0c7e447f3de h1:4QiA9uZiJVp6YfrVeKukeMWVaHlS55rDBaHKWLqYGyU=
kmodules.xyz/custom-resources v0.32.3-0.20251226151909-e0c7e447f3de/go.mod h1:pcA/n/CnrycjKCRNtU9Z+l5svhzFncLY2Kn9pqeXDVs=
kmodules.xyz/client-go v0.34.4 h1:1WwI2iZYdGP8pD4j7dmNMDMsLha6JV4O08l/06LUtOU=
kmodules.xyz/client-go v0.34.4/go.mod h1:myCt7AfRao4PBdUtKXu01xxbqqmLZ5U8fW0LQDaifhQ=
kmodules.xyz/custom-resources v0.34.0 h1:ljkIYzIq0A3Awj87kkpuYqS9aifuyR3Hr9q2OVKoojM=
kmodules.xyz/custom-resources v0.34.0/go.mod h1:pcA/n/CnrycjKCRNtU9Z+l5svhzFncLY2Kn9pqeXDVs=
sigs.k8s.io/controller-runtime v0.22.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327UfMq9A=
sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
Expand Down
1 change: 1 addition & 0 deletions vendor/filippo.io/edwards25519/extra.go

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

2 changes: 1 addition & 1 deletion vendor/kmodules.xyz/client-go/api/v1/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func RemoveCertificate(certificates []CertificateSpec, alias string) []Certifica
type stringSetMerger struct{}

func (t stringSetMerger) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
if typ == reflect.TypeOf([]string{}) {
if typ == reflect.TypeFor[[]string]() {
return func(dst, src reflect.Value) error {
if dst.CanSet() {
if dst.Len() <= 1 && src.Len() == 0 {
Expand Down
43 changes: 40 additions & 3 deletions vendor/kmodules.xyz/client-go/api/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"encoding/json"
"fmt"
)

Expand Down Expand Up @@ -143,7 +144,43 @@ type ClusterClaimInfo struct {
}

type ClusterClaimFeatures struct {
EnabledFeatures []string `json:"enabledFeatures,omitempty" protobuf:"bytes,1,rep,name=enabledFeatures"`
ExternallyManagedFeatures []string `json:"externallyManagedFeatures,omitempty" protobuf:"bytes,2,rep,name=externallyManagedFeatures"`
DisabledFeatures []string `json:"disabledFeatures,omitempty" protobuf:"bytes,3,rep,name=disabledFeatures"`
EnabledFeatures map[string]string `json:"enabledFeatures,omitempty" protobuf:"bytes,1,opt,name=enabledFeatures"`
ExternallyManagedFeatures []string `json:"externallyManagedFeatures,omitempty" protobuf:"bytes,2,opt,name=externallyManagedFeatures"`
DisabledFeatures []string `json:"disabledFeatures,omitempty" protobuf:"bytes,3,opt,name=disabledFeatures"`
}

func (f *ClusterClaimFeatures) UnmarshalJSON(data []byte) error {
aux := &struct {
EnabledFeatures any `json:"enabledFeatures,omitempty"`
ExternallyManagedFeatures []string `json:"externallyManagedFeatures,omitempty"`
DisabledFeatures []string `json:"disabledFeatures,omitempty"`
}{}

if err := json.Unmarshal(data, aux); err != nil {
return err
}

f.EnabledFeatures = toStringMap(aux.EnabledFeatures)
f.ExternallyManagedFeatures = aux.ExternallyManagedFeatures
f.DisabledFeatures = aux.DisabledFeatures
return nil
}

func toStringMap(v any) map[string]string {
result := make(map[string]string)
switch val := v.(type) {
case []any:
for _, item := range val {
if str, ok := item.(string); ok {
result[str] = ""
}
}
case map[string]any:
for k, item := range val {
if str, ok := item.(string); ok {
result[k] = str
}
}
}
return result
}
Loading
Loading