Skip to content

Commit

Permalink
refactor: move core packages from internal to pkg directory
Browse files Browse the repository at this point in the history
Move controller, graph, metadata, and runtime packages from `internal/`
to `pkg/` directory to make them available for external consumption.
  • Loading branch information
a-hilaly committed Dec 23, 2024
1 parent bfcd4bf commit 55a71cc
Show file tree
Hide file tree
Showing 73 changed files with 59 additions and 59 deletions.
4 changes: 2 additions & 2 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

xv1alpha1 "github.com/awslabs/kro/api/v1alpha1"
resourcegroupctrl "github.com/awslabs/kro/internal/controller/resourcegroup"
"github.com/awslabs/kro/internal/graph"
kroclient "github.com/awslabs/kro/pkg/client"
resourcegroupctrl "github.com/awslabs/kro/pkg/controller/resourcegroup"
"github.com/awslabs/kro/pkg/dynamiccontroller"
"github.com/awslabs/kro/pkg/graph"
//+kubebuilder:scaffold:imports
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
ctrl "sigs.k8s.io/controller-runtime"

"github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/graph"
"github.com/awslabs/kro/internal/metadata"
kroclient "github.com/awslabs/kro/pkg/client"
"github.com/awslabs/kro/pkg/graph"
"github.com/awslabs/kro/pkg/metadata"
)

// ReconcileConfig holds configuration parameters for the recnociliation process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/dynamic"

"github.com/awslabs/kro/internal/metadata"
"github.com/awslabs/kro/internal/runtime"
"github.com/awslabs/kro/pkg/metadata"
"github.com/awslabs/kro/pkg/requeue"
"github.com/awslabs/kro/pkg/runtime"
)

// instanceGraphReconciler is responsible for reconciling a single instance and
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/graph"
"github.com/awslabs/kro/internal/metadata"
kroclient "github.com/awslabs/kro/pkg/client"
"github.com/awslabs/kro/pkg/dynamiccontroller"
"github.com/awslabs/kro/pkg/graph"
"github.com/awslabs/kro/pkg/metadata"
)

//+kubebuilder:rbac:groups=kro.run,resources=resourcegroups,verbs=get;list;watch;create;update;patch;delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/metadata"
"github.com/awslabs/kro/pkg/metadata"
)

// cleanupResourceGroup handles the deletion of a ResourceGroup by shutting down its associated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/awslabs/kro/api/v1alpha1"
instancectrl "github.com/awslabs/kro/internal/controller/instance"
"github.com/awslabs/kro/internal/graph"
"github.com/awslabs/kro/internal/metadata"
instancectrl "github.com/awslabs/kro/pkg/controller/instance"
"github.com/awslabs/kro/pkg/dynamiccontroller"
"github.com/awslabs/kro/pkg/graph"
"github.com/awslabs/kro/pkg/metadata"
)

// reconcileResourceGroup orchestrates the reconciliation of a ResourceGroup by:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/metadata"
"github.com/awslabs/kro/pkg/metadata"
"github.com/go-logr/logr"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/dynamiccontroller/dynamic_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import (
"k8s.io/client-go/util/workqueue"
ctrl "sigs.k8s.io/controller-runtime"

"github.com/awslabs/kro/internal/metadata"
"github.com/awslabs/kro/pkg/metadata"
"github.com/awslabs/kro/pkg/requeue"
)

Expand Down
14 changes: 7 additions & 7 deletions internal/graph/builder.go → pkg/graph/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import (
"k8s.io/client-go/rest"

"github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/graph/crd"
"github.com/awslabs/kro/internal/graph/dag"
"github.com/awslabs/kro/internal/graph/emulator"
"github.com/awslabs/kro/internal/graph/parser"
"github.com/awslabs/kro/internal/graph/schema"
"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/internal/metadata"
krocel "github.com/awslabs/kro/pkg/cel"
"github.com/awslabs/kro/pkg/cel/ast"
"github.com/awslabs/kro/pkg/graph/crd"
"github.com/awslabs/kro/pkg/graph/dag"
"github.com/awslabs/kro/pkg/graph/emulator"
"github.com/awslabs/kro/pkg/graph/parser"
"github.com/awslabs/kro/pkg/graph/schema"
"github.com/awslabs/kro/pkg/graph/variable"
"github.com/awslabs/kro/pkg/metadata"
"github.com/awslabs/kro/pkg/simpleschema"
)

Expand Down
8 changes: 4 additions & 4 deletions internal/graph/builder_test.go → pkg/graph/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"github.com/stretchr/testify/require"
"k8s.io/client-go/rest"

"github.com/awslabs/kro/internal/graph/emulator"
"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/internal/testutil/k8s"
"github.com/awslabs/kro/pkg/graph/emulator"
"github.com/awslabs/kro/pkg/graph/variable"
"github.com/awslabs/kro/pkg/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/k8s"
)

func TestGraphBuilder_Validation(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions internal/graph/graph.go → pkg/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package graph
import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"github.com/awslabs/kro/internal/graph/dag"
"github.com/awslabs/kro/internal/runtime"
"github.com/awslabs/kro/pkg/graph/dag"
"github.com/awslabs/kro/pkg/runtime"
)

// Graph represents a processed resourcegroup. It contains the DAG representation
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"k8s.io/kube-openapi/pkg/validation/spec"

"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/pkg/graph/variable"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"k8s.io/kube-openapi/pkg/validation/spec"

"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/pkg/graph/variable"
)

func TestParseResource(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"fmt"
"strings"

"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/pkg/graph/variable"
)

// ParseSchemalessResource extracts CEL expressions without a schema, this is useful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"sort"
"testing"

"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/pkg/graph/variable"
)

func areEqualExpressionFields(a, b []variable.FieldDescriptor) bool {
Expand Down
4 changes: 2 additions & 2 deletions internal/graph/resource.go → pkg/graph/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kube-openapi/pkg/validation/spec"

rgschema "github.com/awslabs/kro/internal/graph/schema"
"github.com/awslabs/kro/internal/graph/variable"
rgschema "github.com/awslabs/kro/pkg/graph/schema"
"github.com/awslabs/kro/pkg/graph/variable"
)

// Resource represents a resource in a resource group, it hholds
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/google/cel-go/common/types/ref"
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"

"github.com/awslabs/kro/internal/graph/fieldpath"
"github.com/awslabs/kro/pkg/graph/fieldpath"
)

// fieldDescriptor represents a field in an OpenAPI schema. Typically this field
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/pkg/graph/variable"
)

// Interface defines the main runtime interface for managing and synchronizing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"fmt"
"strings"

"github.com/awslabs/kro/internal/graph/fieldpath"
"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/pkg/graph/fieldpath"
"github.com/awslabs/kro/pkg/graph/variable"
)

// ResolutionResult represents the result of resolving a single expression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/pkg/graph/variable"
)

func TestGetValueFromPath(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/runtime/runtime.go → pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"golang.org/x/exp/maps"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"github.com/awslabs/kro/internal/graph/variable"
"github.com/awslabs/kro/internal/runtime/resolver"
krocel "github.com/awslabs/kro/pkg/cel"
"github.com/awslabs/kro/pkg/graph/variable"
"github.com/awslabs/kro/pkg/runtime/resolver"
)

// Compile time proof to ensure that ResourceGroupRuntime implements the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/awslabs/kro/internal/graph/variable"
krocel "github.com/awslabs/kro/pkg/cel"
"github.com/awslabs/kro/pkg/graph/variable"
)

func Test_RuntimeWorkflow(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/runtime/state.go → pkg/runtime/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package runtime

import "github.com/awslabs/kro/internal/graph/variable"
import "github.com/awslabs/kro/pkg/graph/variable"

// ResourceState represents the current state of a resource in the runtime.
// It indicates the resource's readiness for processing or what it's waiting on.
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions test/integration/environment/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
ctrlinstance "github.com/awslabs/kro/internal/controller/instance"
ctrlresourcegroup "github.com/awslabs/kro/internal/controller/resourcegroup"
"github.com/awslabs/kro/internal/graph"
kroclient "github.com/awslabs/kro/pkg/client"
ctrlinstance "github.com/awslabs/kro/pkg/controller/instance"
ctrlresourcegroup "github.com/awslabs/kro/pkg/controller/resourcegroup"
"github.com/awslabs/kro/pkg/dynamiccontroller"
"github.com/awslabs/kro/pkg/graph"
)

type Environment struct {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/ackekscluster/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

func eksCluster(
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/ackekscluster/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/rand"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
ctrlinstance "github.com/awslabs/kro/internal/controller/instance"
ctrlinstance "github.com/awslabs/kro/pkg/controller/instance"
"github.com/awslabs/kro/test/integration/environment"
)

Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/conditional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

var _ = Describe("Conditions", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/rand"

"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

var _ = Describe("CRD", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/readiness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

var _ = Describe("Readiness", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/recover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/rand"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

var _ = Describe("Recovery", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"

ctrlinstance "github.com/awslabs/kro/internal/controller/instance"
ctrlinstance "github.com/awslabs/kro/pkg/controller/instance"
"github.com/awslabs/kro/test/integration/environment"
)

Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/util/rand"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

var _ = Describe("Status", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/util/rand"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

var _ = Describe("Topology", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/core/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/util/rand"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

var _ = Describe("Validation", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/deploymentservice/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

// deploymentService creates a ResourceGroup for testing deployment+service combinations
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/deploymentservice/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
ctrlinstance "github.com/awslabs/kro/internal/controller/instance"
ctrlinstance "github.com/awslabs/kro/pkg/controller/instance"
"github.com/awslabs/kro/test/integration/environment"
)

Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/networkingstack/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
"github.com/awslabs/kro/internal/testutil/generator"
"github.com/awslabs/kro/pkg/testutil/generator"
)

func networkingStack(
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suites/networkingstack/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/rand"

krov1alpha1 "github.com/awslabs/kro/api/v1alpha1"
ctrlinstance "github.com/awslabs/kro/internal/controller/instance"
ctrlinstance "github.com/awslabs/kro/pkg/controller/instance"
"github.com/awslabs/kro/test/integration/environment"
)

Expand Down

0 comments on commit 55a71cc

Please sign in to comment.