Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: move pkg/ansible to internal/ansible #3560

Merged
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ images/scorecard-test/scorecard-test
images/scorecard-test-kuttl/scorecard-test-kuttl

# Test artifacts
pkg/ansible/runner/testdata/valid.yaml
internal/ansible/runner/testdata/valid.yaml
/bin
internal/scorecard/examples/custom-scorecard-tests/go.sum

Expand Down
11 changes: 11 additions & 0 deletions changelog/fragments/mv-ansible-internal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
entries:
- description: >
The ansible operator implementation in `pkg/ansible` was moved to
`internal/ansible`.

kind: change
breaking: true
migration:
header: Hybrid Go/Ansible operator use cases are not supported in 1.0.0
body: >
There is no migration path that enables continued use of the Ansible-based operator Go libraries
12 changes: 6 additions & 6 deletions cmd/ansible-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/operator-framework/operator-sdk/internal/ansible/controller"
"github.com/operator-framework/operator-sdk/internal/ansible/flags"
"github.com/operator-framework/operator-sdk/internal/ansible/proxy"
"github.com/operator-framework/operator-sdk/internal/ansible/proxy/controllermap"
"github.com/operator-framework/operator-sdk/internal/ansible/runner"
"github.com/operator-framework/operator-sdk/internal/ansible/watches"
"github.com/operator-framework/operator-sdk/internal/log/zap"
"github.com/operator-framework/operator-sdk/internal/util/k8sutil"
"github.com/operator-framework/operator-sdk/pkg/ansible/controller"
"github.com/operator-framework/operator-sdk/pkg/ansible/flags"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/controllermap"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner"
"github.com/operator-framework/operator-sdk/pkg/ansible/watches"
sdkVersion "github.com/operator-framework/operator-sdk/version"
)

Expand Down
2 changes: 1 addition & 1 deletion hack/tests/e2e-ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source hack/lib/image_lib.sh
source ./hack/lib/common.sh

# ansible proxy test require a running cluster; run during e2e instead
go test -count=1 ./pkg/ansible/proxy/...
go test -count=1 ./internal/ansible/proxy/...

DEST_IMAGE="quay.io/example/memcached-operator:v0.0.2"
ROOTDIR="$(pwd)"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (
ctrlpredicate "sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/operator-framework/operator-sdk/pkg/ansible/events"
"github.com/operator-framework/operator-sdk/pkg/ansible/predicate"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner"
"github.com/operator-framework/operator-sdk/internal/ansible/events"
"github.com/operator-framework/operator-sdk/internal/ansible/predicate"
"github.com/operator-framework/operator-sdk/internal/ansible/runner"
)

var log = logf.Log.WithName("ansible-controller")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ import (
"strings"
"time"

ansiblestatus "github.com/operator-framework/operator-sdk/pkg/ansible/controller/status"
"github.com/operator-framework/operator-sdk/pkg/ansible/events"
"github.com/operator-framework/operator-sdk/pkg/ansible/metrics"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/kubeconfig"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"

v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -41,6 +34,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ansiblestatus "github.com/operator-framework/operator-sdk/internal/ansible/controller/status"
"github.com/operator-framework/operator-sdk/internal/ansible/events"
"github.com/operator-framework/operator-sdk/internal/ansible/metrics"
"github.com/operator-framework/operator-sdk/internal/ansible/proxy/kubeconfig"
"github.com/operator-framework/operator-sdk/internal/ansible/runner"
"github.com/operator-framework/operator-sdk/internal/ansible/runner/eventapi"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ import (
"testing"
"time"

"github.com/operator-framework/operator-sdk/pkg/ansible/controller"
ansiblestatus "github.com/operator-framework/operator-sdk/pkg/ansible/controller/status"
"github.com/operator-framework/operator-sdk/pkg/ansible/events"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/fake"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/operator-framework/operator-sdk/internal/ansible/controller"
ansiblestatus "github.com/operator-framework/operator-sdk/internal/ansible/controller/status"
"github.com/operator-framework/operator-sdk/internal/ansible/events"
"github.com/operator-framework/operator-sdk/internal/ansible/runner"
"github.com/operator-framework/operator-sdk/internal/ansible/runner/eventapi"
"github.com/operator-framework/operator-sdk/internal/ansible/runner/fake"
)

func TestReconcile(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"encoding/json"
"time"

"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/operator-framework/operator-sdk/internal/ansible/runner/eventapi"
)

var log = logf.Log.WithName("controller.status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"errors"
"fmt"

"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/operator-framework/operator-sdk/internal/ansible/runner/eventapi"
)

// LogLevel - Levelt for the logging to take place.
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,6 @@ import (
"strings"

libhandler "github.com/operator-framework/operator-lib/handler"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/controllermap"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/requestfactory"
k8sRequest "github.com/operator-framework/operator-sdk/pkg/ansible/proxy/requestfactory"

"k8s.io/apimachinery/pkg/api/meta"
metainternalscheme "k8s.io/apimachinery/pkg/apis/meta/internalversion/scheme"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -38,6 +34,9 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/operator-framework/operator-sdk/internal/ansible/proxy/controllermap"
k8sRequest "github.com/operator-framework/operator-sdk/internal/ansible/proxy/requestfactory"
)

type marshaler interface {
Expand Down Expand Up @@ -150,7 +149,7 @@ func (c *cacheResponseHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
}

// skipCacheLookup - determine if we should skip the cache lookup
func (c *cacheResponseHandler) skipCacheLookup(r *requestfactory.RequestInfo, gvk schema.GroupVersionKind,
func (c *cacheResponseHandler) skipCacheLookup(r *k8sRequest.RequestInfo, gvk schema.GroupVersionKind,
req *http.Request) bool {

skip := matchesRegexp(req.URL.String(), c.skipPathRegexp)
Expand Down Expand Up @@ -241,7 +240,7 @@ func (c *cacheResponseHandler) recoverDependentWatches(req *http.Request, un *un
}
}

func (c *cacheResponseHandler) getListFromCache(r *requestfactory.RequestInfo, req *http.Request,
func (c *cacheResponseHandler) getListFromCache(r *k8sRequest.RequestInfo, req *http.Request,
k schema.GroupVersionKind) (marshaler, error) {
k8sListOpts := &metav1.ListOptions{}
if err := metainternalscheme.ParameterCodec.DecodeParameters(req.URL.Query(), metav1.SchemeGroupVersion,
Expand Down Expand Up @@ -283,7 +282,7 @@ func (c *cacheResponseHandler) getListFromCache(r *requestfactory.RequestInfo, r
return &un, nil
}

func (c *cacheResponseHandler) getObjectFromCache(r *requestfactory.RequestInfo, req *http.Request,
func (c *cacheResponseHandler) getObjectFromCache(r *k8sRequest.RequestInfo, req *http.Request,
k schema.GroupVersionKind) (marshaler, error) {
un := &unstructured.Unstructured{}
un.SetGroupVersionKind(k)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import (
"net/http/httputil"

"github.com/operator-framework/operator-lib/handler"
"github.com/operator-framework/operator-sdk/internal/util/k8sutil"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/controllermap"
k8sRequest "github.com/operator-framework/operator-sdk/pkg/ansible/proxy/requestfactory"

"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"

"github.com/operator-framework/operator-sdk/internal/ansible/proxy/controllermap"
k8sRequest "github.com/operator-framework/operator-sdk/internal/ansible/proxy/requestfactory"
"github.com/operator-framework/operator-sdk/internal/util/k8sutil"
)

// injectOwnerReferenceHandler will handle proxied requests and inject the
Expand Down
File renamed without changes.
10 changes: 4 additions & 6 deletions pkg/ansible/proxy/proxy.go → internal/ansible/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

package proxy

// This file contains this project's custom code, as opposed to kubectl.go
// which contains code retrieved from the kubernetes project.

import (
"bytes"
"encoding/base64"
Expand All @@ -31,9 +28,6 @@ import (

libhandler "github.com/operator-framework/operator-lib/handler"
"github.com/operator-framework/operator-lib/predicate"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/controllermap"
"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/kubeconfig"
k8sRequest "github.com/operator-framework/operator-sdk/pkg/ansible/proxy/requestfactory"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand All @@ -43,6 +37,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/operator-framework/operator-sdk/internal/ansible/proxy/controllermap"
"github.com/operator-framework/operator-sdk/internal/ansible/proxy/kubeconfig"
k8sRequest "github.com/operator-framework/operator-sdk/internal/ansible/proxy/requestfactory"
)

// This is the default timeout to wait for the cache to respond
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
"os"
"testing"

"github.com/operator-framework/operator-sdk/pkg/ansible/proxy/controllermap"

kcorev1 "k8s.io/api/core/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"

"github.com/operator-framework/operator-sdk/internal/ansible/proxy/controllermap"
)

func TestHandler(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
"fmt"
"time"

"github.com/operator-framework/operator-sdk/pkg/ansible/runner"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"github.com/operator-framework/operator-sdk/internal/ansible/runner"
"github.com/operator-framework/operator-sdk/internal/ansible/runner/eventapi"
)

// Runner - implements the Runner interface for a GVK that's being watched.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"strconv"
"strings"

"github.com/operator-framework/operator-sdk/pkg/ansible/metrics"
"github.com/operator-framework/operator-sdk/pkg/ansible/paramconv"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/eventapi"
"github.com/operator-framework/operator-sdk/pkg/ansible/runner/internal/inputdir"
"github.com/operator-framework/operator-sdk/pkg/ansible/watches"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/operator-framework/operator-sdk/internal/ansible/metrics"
"github.com/operator-framework/operator-sdk/internal/ansible/paramconv"
"github.com/operator-framework/operator-sdk/internal/ansible/runner/eventapi"
"github.com/operator-framework/operator-sdk/internal/ansible/runner/internal/inputdir"
"github.com/operator-framework/operator-sdk/internal/ansible/watches"
)

var log = logf.Log.WithName("runner")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/operator-framework/operator-sdk/pkg/ansible/watches"
"github.com/operator-framework/operator-sdk/internal/ansible/watches"
)

func checkCmdFunc(t *testing.T, cmdFunc cmdFuncType, playbook, role string, verbosity int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
yaml "sigs.k8s.io/yaml"

"github.com/operator-framework/operator-sdk/pkg/ansible/flags"
"github.com/operator-framework/operator-sdk/internal/ansible/flags"
)

var log = logf.Log.WithName("watches")
Expand Down