Skip to content

Commit

Permalink
introduce sdk submodule composed from ./api ./pkg/model ./pkg/util ./…
Browse files Browse the repository at this point in the history
…pkg/plugins (kube-logging#217)

* introduce sdk submodule composed from ./api ./pkg/model ./pkg/util ./pkg/plugins
  • Loading branch information
pepov authored Nov 7, 2019
1 parent 40c6ccd commit b022505
Show file tree
Hide file tree
Showing 97 changed files with 305 additions and 161 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
build/
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
COPY pkg/sdk/go.mod pkg/sdk/go.mod
COPY pkg/sdk/go.sum pkg/sdk/go.sum

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VERSION := $(shell git describe --abbrev=0 --tags)
DOCKER_IMAGE = banzaicloud/logging-operator
DOCKER_TAG ?= ${VERSION}
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./client/*")
GOFILES_NOPLUGINS = $(shell find . -type f -name '*.go' -not -path "./pkg/model/filter/*" -not -path "./pkg/model/output/*" -not -path "./pkg/model/input/*")
GOFILES_NOPLUGINS = $(shell find . -type f -name '*.go' -not -path "./pkg/sdk/model/filter/*" -not -path "./pkg/sdk/model/output/*" -not -path "./pkg/sdk/model/input/*")
PKGS=$(shell go list ./... | grep -v /vendor)

GOLANGCI_VERSION = 1.19.1
Expand Down Expand Up @@ -63,7 +63,7 @@ test: generate fmt vet manifests bin/kubebuilder
@which kubebuilder
@which etcd
kubebuilder version
go test ./api/... ./controllers/... ./pkg/... -coverprofile cover.out
go test ./controllers/... ./pkg/... -coverprofile cover.out

# Build manager binary
manager: generate fmt vet
Expand Down Expand Up @@ -96,8 +96,8 @@ vet:

# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/model/...
cd pkg/sdk && $(CONTROLLER_GEN) object:headerFile=./../../hack/boilerplate.go.txt paths=./api/...
cd pkg/sdk && $(CONTROLLER_GEN) object:headerFile=./../../hack/boilerplate.go.txt paths=./model/...

# Build the docker image
docker-build: test
Expand Down
6 changes: 3 additions & 3 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ type PluginDir struct {
}

var pluginDirs = []PluginDir{
{"filters", "./pkg/model/filter/"},
{"outputs", "./pkg/model/output/"},
{"common", "./pkg/model/common/"},
{"filters", "./pkg/sdk/model/filter/"},
{"outputs", "./pkg/sdk/model/output/"},
{"common", "./pkg/sdk/model/common/"},
}

var docsPath = "docs/plugins"
Expand Down
6 changes: 3 additions & 3 deletions controllers/logging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
"regexp"

"emperror.dev/errors"
"github.com/banzaicloud/logging-operator/pkg/model/render"
"github.com/banzaicloud/logging-operator/pkg/model/secret"
"github.com/banzaicloud/logging-operator/pkg/resources"
"github.com/banzaicloud/logging-operator/pkg/resources/fluentbit"
"github.com/banzaicloud/logging-operator/pkg/resources/fluentd"
"github.com/banzaicloud/logging-operator/pkg/resources/model"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/render"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/secret"
"github.com/go-logr/logr"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -39,7 +39,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

loggingv1alpha2 "github.com/banzaicloud/logging-operator/api/v1beta1"
loggingv1alpha2 "github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
)

// LoggingReconciler reconciles a Logging object
Expand Down
6 changes: 3 additions & 3 deletions controllers/logging_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"time"

"emperror.dev/errors"
"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/controllers"
"github.com/banzaicloud/logging-operator/pkg/model/output"
"github.com/banzaicloud/logging-operator/pkg/model/secret"
"github.com/banzaicloud/logging-operator/pkg/resources/fluentd"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/output"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/secret"
"github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"sync"
"testing"

"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/pborman/uuid"
v12 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ go run main.go

To add a `plugin` to the logging operator you need to define the plugin struct.

> Note: Place your plugin in the corresponding directory `pkg/model/filter` or `pkg/model/output`
> Note: Place your plugin in the corresponding directory `pkg/sdk/model/filter` or `pkg/sdk/model/output`
```go
type MyExampleOutput struct {
Expand Down
11 changes: 2 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ go 1.12

require (
emperror.dev/errors v0.4.2
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883
github.com/banzaicloud/k8s-objectmatcher v1.0.1
github.com/banzaicloud/logging-operator/pkg/sdk v0.0.0
github.com/coreos/prometheus-operator v0.33.0
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v0.1.0
github.com/goph/emperror v0.17.2
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/pborman/uuid v1.2.0
github.com/prometheus/common v0.6.0
github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/cast v1.3.0
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
k8s.io/api v0.0.0-20190813020757-36bff7324fb7
k8s.io/apiextensions-apiserver v0.0.0-20190801143813-8b5f3a974f92
k8s.io/apimachinery v0.0.0-20190809020650-423f5d784010
Expand All @@ -29,6 +21,7 @@ require (
)

replace (
github.com/banzaicloud/logging-operator/pkg/sdk => ./pkg/sdk
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2-0.20190818123050-43acd0e2e93f
k8s.io/api => k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
// required for test deps only
Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,8 @@ github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"flag"
"os"

loggingv1alpha2 "github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/controllers"
"github.com/banzaicloud/logging-operator/pkg/util"
loggingv1alpha2 "github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
prometheusOperator "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentbit/configsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"text/template"

"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/model/types"
"github.com/banzaicloud/logging-operator/pkg/resources/fluentd"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/types"
"github.com/prometheus/common/log"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/fluentbit/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"crypto/sha256"
"fmt"

"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/fluentbit/fluentbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"emperror.dev/errors"
"k8s.io/apimachinery/pkg/runtime"

"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
"github.com/go-logr/logr"
"github.com/goph/emperror"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentbit/psp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package fluentbit
import (
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
policyv1beta1 "k8s.io/api/policy/v1beta1"
rbacv1 "k8s.io/api/rbac/v1"

Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentbit/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package fluentbit
import (
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
v1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
corev1 "k8s.io/api/core/v1"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentd/appconfigmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
)

type ConfigCheckResult struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentd/configsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/resources/fluentd/fluentd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"time"

"emperror.dev/errors"
"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/model/secret"
"github.com/banzaicloud/logging-operator/pkg/resources"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/secret"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
"github.com/go-logr/logr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentd/outputsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"

"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/model/secret"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/secret"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentd/psp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package fluentd
import (
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
policyv1beta1 "k8s.io/api/policy/v1beta1"
rbacv1 "k8s.io/api/rbac/v1"

Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package fluentd
import (
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
v1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
corev1 "k8s.io/api/core/v1"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/fluentd/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package fluentd

import (
"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/k8sutil"
"github.com/banzaicloud/logging-operator/pkg/resources/templates"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
"github.com/spf13/cast"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down
12 changes: 6 additions & 6 deletions pkg/resources/model/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ package model

import (
"emperror.dev/errors"
"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/model/common"
"github.com/banzaicloud/logging-operator/pkg/model/input"
"github.com/banzaicloud/logging-operator/pkg/model/secret"
"github.com/banzaicloud/logging-operator/pkg/model/types"
"github.com/banzaicloud/logging-operator/pkg/plugins"
"github.com/banzaicloud/logging-operator/pkg/resources/fluentd"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/common"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/input"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/secret"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/types"
"github.com/banzaicloud/logging-operator/pkg/sdk/plugins"
"github.com/go-logr/logr"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package templates

import (
"github.com/banzaicloud/logging-operator/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
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 @@ -15,7 +15,7 @@
package v1beta1

import (
"github.com/banzaicloud/logging-operator/pkg/model/filter"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/filter"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

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 @@ -17,7 +17,7 @@ package v1beta1
import (
"fmt"

"github.com/banzaicloud/logging-operator/pkg/util"
"github.com/banzaicloud/logging-operator/pkg/sdk/util"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package v1beta1

import (
"github.com/banzaicloud/logging-operator/pkg/model/output"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/output"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
File renamed without changes.
File renamed without changes.

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

21 changes: 21 additions & 0 deletions pkg/sdk/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module github.com/banzaicloud/logging-operator/pkg/sdk

go 1.13

require (
emperror.dev/errors v0.4.2
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883
github.com/ghodss/yaml v1.0.0
github.com/goph/emperror v0.17.2
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/sergi/go-diff v1.0.0 // indirect
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
sigs.k8s.io/controller-runtime v0.2.0
)
Loading

0 comments on commit b022505

Please sign in to comment.