Skip to content

Commit

Permalink
Don't deploy billing prometheus rule for tests
Browse files Browse the repository at this point in the history
This will not deploy any billing data for instances where the claim
resides in the `vshn-test` namespace.
  • Loading branch information
Kidswiss committed Nov 26, 2024
1 parent b1ec9ef commit 3908409
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/comp-functions/functions/common/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"context"
_ "embed"
"fmt"
"text/template"

xfnproto "github.com/crossplane/function-sdk-go/proto/v1beta1"
v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
controllerruntime "sigs.k8s.io/controller-runtime"
"text/template"
)

var rawExpr = "vector({{.}})"
Expand All @@ -22,6 +23,11 @@ func CreateBillingRecord(ctx context.Context, svc *runtime.ServiceRuntime, comp
log := controllerruntime.LoggerFrom(ctx)
log.Info("Enabling billing for service", "service", comp.GetName())

if comp.GetClaimNamespace() == svc.Config.Data["ignoreNamespaceForBilling"] {
log.Info("Test instance, skipping billing")
return nil
}

expr, err := getExprFromTemplate(comp.GetInstances())
if err != nil {
runtime.NewWarningResult(fmt.Sprintf("cannot add billing to service %s", comp.GetName()))
Expand Down

0 comments on commit 3908409

Please sign in to comment.