Skip to content

Commit

Permalink
tests:feat:integ: adc for direct
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pana <[email protected]>
  • Loading branch information
acpana committed Dec 13, 2024
1 parent 4345acc commit 659e5d1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pkg/test/controller/reconciler/testreconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import (
"fmt"
"log"
"net/http"
"os"
"regexp"
"strconv"
"testing"
"time"

Expand All @@ -43,6 +45,7 @@ import (
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/kccfeatureflags"
"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/servicemapping/servicemappingloader"
testcontroller "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/controller"
testgcp "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/gcp"
testk8s "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/k8s"
testservicemappingloader "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/servicemappingloader"

Expand Down Expand Up @@ -112,9 +115,22 @@ func NewTestReconciler(t *testing.T, mgr manager.Manager, provider *tfschema.Pro
dclConverter := conversion.New(dclSchemaLoader, serviceMetaLoader)

// Initialize direct controllers
if err := registry.Init(context.TODO(), &config.ControllerConfig{
kccConfig := &config.ControllerConfig{
HTTPClient: httpClient,
}); err != nil {
}
p := testgcp.GetDefaultProject(t)
// technically this would be sufficient for TF and DCL controllers
// to set the BillingProject as the resource project that is being used.
kccConfig.UserProjectOverride = true

// but for our direct resources we look at the BillingProject so let's set it.
if os.Getenv("BILLING_ACCOUNT_ID") != "" {
kccConfig.BillingProject = os.Getenv("BILLING_ACCOUNT_ID")
} else {
kccConfig.BillingProject = strconv.FormatInt(p.ProjectNumber, 10)
}

if err := registry.Init(context.TODO(), kccConfig); err != nil {
t.Fatalf("error initializing direct registry: %v", err)
}

Expand Down

0 comments on commit 659e5d1

Please sign in to comment.