Skip to content

Commit

Permalink
Add ClientOrgID to PrometheusContext
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Nov 12, 2024
1 parent 6f15fb6 commit 5dcad1a
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 137 deletions.
9 changes: 5 additions & 4 deletions api/v1/appbinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ type TLSConfig struct {
}

type PrometheusContext struct {
HubUID string `json:"hubUID,omitempty"`
ClusterUID string `json:"clusterUID"`
ProjectId string `json:"projectId,omitempty"`
Default bool `json:"default"`
HubUID string `json:"hubUID,omitempty"`
ClusterUID string `json:"clusterUID"`
ProjectId string `json:"projectId,omitempty"`
Default bool `json:"default"`
ClientOrgID string `json:"clientOrgID,omitempty"`
}

type GrafanaContext struct {
Expand Down
6 changes: 6 additions & 0 deletions api/v1/openapi_generated.go

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

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
k8s.io/client-go v0.30.2
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20240620174524-b456828f718b
kmodules.xyz/client-go v0.30.28
kmodules.xyz/client-go v0.30.37
kmodules.xyz/custom-resources v0.30.0
sigs.k8s.io/controller-runtime v0.18.4
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCI
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/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.30.28 h1:YD5AZaUm3xakIbwLoKblLbE6mvayNZhIomgdXyuLo40=
kmodules.xyz/client-go v0.30.28/go.mod h1:CAu+JlA8RVGtj6LQHu0Q1w2mnFUajuti49c7T1AvGdM=
kmodules.xyz/client-go v0.30.37 h1:hj4BMsNDgRVc2aDPB6Y3x5iCylXTZDZeQPJp/oA6lxs=
kmodules.xyz/client-go v0.30.37/go.mod h1:CAu+JlA8RVGtj6LQHu0Q1w2mnFUajuti49c7T1AvGdM=
kmodules.xyz/custom-resources v0.30.0 h1:vR3CbseHMLwR4GvtcJJuRuwIV8voKqFqNii27rMcm1o=
kmodules.xyz/custom-resources v0.30.0/go.mod h1:ZsTuI2mLG2s3byre7bHmpxJ9w0HDqAkRTL1+izGFI24=
sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw=
Expand Down
2 changes: 1 addition & 1 deletion vendor/kmodules.xyz/client-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))

BASEIMAGE_PROD ?= gcr.io/distroless/static-debian12
BASEIMAGE_DBG ?= debian:bookworm
BASEIMAGE_DBG ?= debian:12

GO_VERSION ?= 1.23
BUILD_IMAGE ?= ghcr.io/appscode/golang-dev:$(GO_VERSION)
Expand Down
45 changes: 36 additions & 9 deletions vendor/kmodules.xyz/client-go/api/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,39 @@ const (
ClusterNameKey string = "cluster.appscode.com/name"
ClusterDisplayNameKey string = "cluster.appscode.com/display-name"
ClusterProviderNameKey string = "cluster.appscode.com/provider"

AceOrgIDKey string = "ace.appscode.com/org-id"
ClientOrgKey string = "ace.appscode.com/client-org"
ClientKeyPrefix string = "client.ace.appscode.com/"

ClusterClaimKeyID string = "id.k8s.io"
ClusterClaimKeyInfo string = "cluster.ace.info"
ClusterClaimKeyFeatures string = "features.ace.info"
)

type ClusterMetadata struct {
UID string `json:"uid" protobuf:"bytes,1,opt,name=uid"`
Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
DisplayName string `json:"displayName,omitempty" protobuf:"bytes,3,opt,name=displayName"`
Provider HostingProvider `json:"provider,omitempty" protobuf:"bytes,4,opt,name=provider,casttype=HostingProvider"`
OwnerID string `json:"ownerID,omitempty" protobuf:"bytes,5,opt,name=ownerID"`
OwnerType string `json:"ownerType,omitempty" protobuf:"bytes,6,opt,name=ownerType"`
APIEndpoint string `json:"apiEndpoint,omitempty" protobuf:"bytes,7,opt,name=apiEndpoint"`
CABundle string `json:"caBundle,omitempty" protobuf:"bytes,8,opt,name=caBundle"`
UID string `json:"uid" protobuf:"bytes,1,opt,name=uid"`
Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
DisplayName string `json:"displayName,omitempty" protobuf:"bytes,3,opt,name=displayName"`
Provider HostingProvider `json:"provider,omitempty" protobuf:"bytes,4,opt,name=provider,casttype=HostingProvider"`
OwnerID string `json:"ownerID,omitempty" protobuf:"bytes,5,opt,name=ownerID"`
OwnerType string `json:"ownerType,omitempty" protobuf:"bytes,6,opt,name=ownerType"`
APIEndpoint string `json:"apiEndpoint,omitempty" protobuf:"bytes,7,opt,name=apiEndpoint"`
CABundle string `json:"caBundle,omitempty" protobuf:"bytes,8,opt,name=caBundle"`
ManagerID string `json:"managerID,omitempty" protobuf:"bytes,9,opt,name=managerID"`
HubClusterID string `json:"hubClusterID,omitempty" protobuf:"bytes,10,opt,name=hubClusterID"`
}

func (md ClusterMetadata) Manager() string {
if md.ManagerID != "" && md.ManagerID != "0" {
return md.ManagerID
}
return md.OwnerID
}

func (md ClusterMetadata) State() string {
hasher := hmac.New(sha256.New, []byte(md.UID))
state := fmt.Sprintf("%s,%s", md.APIEndpoint, md.OwnerID)
state := fmt.Sprintf("%s,%s", md.APIEndpoint, md.Manager())
hasher.Write([]byte(state))
return base64.URLEncoding.EncodeToString(hasher.Sum(nil))
}
Expand Down Expand Up @@ -174,3 +191,13 @@ const (
CAPIProviderCAPZ CAPIProvider = "capz"
CAPIProviderCAPH CAPIProvider = "caph"
)

type ClusterClaimInfo struct {
ClusterMetadata ClusterInfo `json:"clusterMetadata"`
}

type ClusterClaimFeatures struct {
EnabledFeatures []string `json:"enabledFeatures,omitempty"`
ExternallyManagedFeatures []string `json:"externallyManagedFeatures,omitempty"`
DisabledFeatures []string `json:"disabledFeatures,omitempty"`
}
Loading

0 comments on commit 5dcad1a

Please sign in to comment.