Skip to content
Open
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
5 changes: 5 additions & 0 deletions apis/v1alpha1/providerconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ type ProviderConfigSpec struct {
// Address of the cortex server
Address string `json:"address"`

// RulerAPIPath for the Rules endpoint
// e.g. /prometheus/config/v1/rules
// +optional
RulerAPIPath *string `json:"rulerAPIPath,omitempty"`

// Credentials required to authenticate to this provider.
// Credentials ProviderCredentials `json:"credentials"`
}
Expand Down
7 changes: 6 additions & 1 deletion apis/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.20

require (
github.com/crossplane/crossplane-runtime v0.19.2
// github.com/crossplane/crossplane-tools v0.0.0-20230327091744-4236bf732aa5
github.com/crossplane/crossplane-tools v0.0.0-20220901191540-806c0b01097b
github.com/google/go-cmp v0.5.9
github.com/pkg/errors v0.9.1
Expand All @@ -17,7 +16,7 @@ require (
)

require (
github.com/cortexproject/cortex-tools v0.11.2-0.20230927171007-58aa76d01708
github.com/cortexproject/cortex-tools v0.11.2-0.20231101174637-76a414b4fe47
github.com/prometheus/common v0.42.0
github.com/prometheus/prometheus v1.8.2-0.20220411232225-ce6a643ee88f
gopkg.in/yaml.v3 v3.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ github.com/cortexproject/cortex v1.7.1-0.20210316085356-3fedc1108a49/go.mod h1:/
github.com/cortexproject/cortex v1.8.1-0.20210422151339-cf1c444e0905/go.mod h1:xxm4/CLvTmDxwE7yXwtClR4dIvkG4S09o5DygPOgc1U=
github.com/cortexproject/cortex v1.13.2 h1:Bz0SstQuvW8HrUVuV5NygORm1eL4p+v5mAMBoMt4Lpg=
github.com/cortexproject/cortex v1.13.2/go.mod h1:NL24i3LSvY5ChBGHwFFm+gc2ZWCH7E/37/F+1fgjf24=
github.com/cortexproject/cortex-tools v0.11.2-0.20230927171007-58aa76d01708 h1:0Bne+boFjYJn6/62upv1q1jY/2kYyE+0XddEHNX591E=
github.com/cortexproject/cortex-tools v0.11.2-0.20230927171007-58aa76d01708/go.mod h1:WULGudjEWbYqufjmjjO4SP276qAWaCKbVaPt/jFh5sE=
github.com/cortexproject/cortex-tools v0.11.2-0.20231101174637-76a414b4fe47 h1:bQZ1ikD6AI0oCUy/5PKhwSxEYpNEKhGGkfsfkvP72qo=
github.com/cortexproject/cortex-tools v0.11.2-0.20231101174637-76a414b4fe47/go.mod h1:WULGudjEWbYqufjmjjO4SP276qAWaCKbVaPt/jFh5sE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down
13 changes: 9 additions & 4 deletions internal/clients/cortex.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type Config struct {
// NewClient creates new Cortex Client with provided Cortex Configurations.
func NewClient(config Config) *cortexClient.CortexClient {
client, err := cortexClient.New(cortexClient.Config{
Address: config.Address,
ID: config.ID,
Address: config.Address,
ID: config.ID,
RulerAPIPath: config.RulerAPIPath,
})

if err != nil {
Expand Down Expand Up @@ -52,8 +53,12 @@ func UseProviderConfig(ctx context.Context, c client.Client, mg resource.Managed
return nil, errors.Wrap(err, "cannot track ProviderConfig usage")
}

// return &Config{}, nil
return &Config{cortexClient.Config{ID: pc.Spec.TenantID, Address: pc.Spec.Address}}, nil
rulerAPIPath := ""
if pc.Spec.RulerAPIPath != nil {
rulerAPIPath = *pc.Spec.RulerAPIPath
}

return &Config{cortexClient.Config{ID: pc.Spec.TenantID, Address: pc.Spec.Address, RulerAPIPath: rulerAPIPath}}, nil

// switch s := pc.Spec.Credentials.Source; s { //nolint:exhaustive
// case xpv1.CredentialsSourceSecret:
Expand Down
3 changes: 3 additions & 0 deletions package/crds/cortex.crossplane.io_providerconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
address:
description: Address of the cortex server
type: string
rulerAPIPath:
description: RulerAPIPath for the Rules endpoint e.g. /prometheus/config/v1/rules
type: string
tenantId:
description: ID of the cortex tenant
type: string
Expand Down
2 changes: 1 addition & 1 deletion package/crossplane.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: meta.pkg.crossplane.io/v1alpha1
apiVersion: meta.pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-cortex
Expand Down