Skip to content

Commit c2271f1

Browse files
committed
Update package names
1 parent cf7198e commit c2271f1

File tree

5 files changed

+55
-53
lines changed

5 files changed

+55
-53
lines changed

pkg/patterns/operator/operator.go renamed to pkg/patterns/application/application.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package operator
17+
package application
1818

1919
import (
2020
"fmt"
2121
"strings"
2222

23-
"github.com/kubernetes-sigs/controller-runtime/pkg/client"
24-
"github.com/kubernetes-sigs/controller-runtime/pkg/client/apiutil"
25-
"github.com/kubernetes-sigs/controller-runtime/pkg/client/config"
26-
"github.com/kubernetes-sigs/controller-runtime/pkg/controller"
27-
"github.com/kubernetes-sigs/controller-runtime/pkg/handler"
28-
internalcontroller "github.com/kubernetes-sigs/controller-runtime/pkg/internal/controller"
29-
"github.com/kubernetes-sigs/controller-runtime/pkg/manager"
30-
"github.com/kubernetes-sigs/controller-runtime/pkg/reconcile"
31-
"github.com/kubernetes-sigs/controller-runtime/pkg/runtime/signals"
32-
"github.com/kubernetes-sigs/controller-runtime/pkg/source"
3323
"k8s.io/apimachinery/pkg/runtime"
24+
"sigs.k8s.io/controller-runtime/pkg/client"
25+
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
26+
"sigs.k8s.io/controller-runtime/pkg/client/config"
27+
"sigs.k8s.io/controller-runtime/pkg/controller"
28+
"sigs.k8s.io/controller-runtime/pkg/handler"
29+
internalcontroller "sigs.k8s.io/controller-runtime/pkg/internal/controller"
30+
"sigs.k8s.io/controller-runtime/pkg/manager"
31+
"sigs.k8s.io/controller-runtime/pkg/reconcile"
32+
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
33+
"sigs.k8s.io/controller-runtime/pkg/source"
3434
)
3535

36-
// Operator is a very simple Controller that embeds a Manager.
37-
type Operator struct {
36+
// Application is a very simple Controller that embeds a Manager.
37+
type Application struct {
3838
mrg manager.Manager
3939
stopFn func() <-chan struct{}
4040
ctrl *internalcontroller.Controller
@@ -49,7 +49,7 @@ var newController = controller.New
4949
var newManager = manager.New
5050
var getGvk = apiutil.GVKForObject
5151

52-
// New returns a new Operator for a Kubernetes Resource type.
52+
// New returns a new Application for a Kubernetes Resource type.
5353
//
5454
// * Watch for changes (e.g. create,update,delete operations) to objects of the Resource type
5555
//
@@ -61,7 +61,7 @@ var getGvk = apiutil.GVKForObject
6161
//
6262
// ownedTypes: list of types of objects that may be created or managed by the reconcileObject. These
6363
// objects must have the OwnersReference set to the owning object in the ObjectMeta - e.g. &v1.Pod{}
64-
func New(reconcileObject runtime.Object, ownedTypes ...runtime.Object) (*Operator, error) {
64+
func New(reconcileObject runtime.Object, ownedTypes ...runtime.Object) (*Application, error) {
6565
c, err := getConfig()
6666
if err != nil {
6767
return nil, err
@@ -71,7 +71,7 @@ func New(reconcileObject runtime.Object, ownedTypes ...runtime.Object) (*Operato
7171
return nil, err
7272
}
7373

74-
o := &Operator{
74+
o := &Application{
7575
mrg: mrg,
7676
stopFn: signals.SetupSignalHandler,
7777
}
@@ -82,7 +82,7 @@ func New(reconcileObject runtime.Object, ownedTypes ...runtime.Object) (*Operato
8282
}
8383

8484
// Create the controller
85-
name := fmt.Sprintf("%s-operator", strings.ToLower(gvk.Kind))
85+
name := fmt.Sprintf("%s-application", strings.ToLower(gvk.Kind))
8686
ctrl, err := newController(name, mrg, controller.Options{Reconcile: noop})
8787
if err != nil {
8888
return nil, err
@@ -106,17 +106,17 @@ func New(reconcileObject runtime.Object, ownedTypes ...runtime.Object) (*Operato
106106
return o, nil
107107
}
108108

109-
// Start starts the Operator and blocks until the program is shutdown.
109+
// Start starts the Application and blocks until the program is shutdown.
110110
//
111111
// call: the Reconcile implementation. reconcile.Reconcile is a function that may be called at anytime with the
112112
// name / Namespace of an object. When called, it will ensure that the state of the system matches what is
113113
// specified in the object at the time reconcile is called.
114-
func (o *Operator) Start(call reconcile.Reconcile) error {
114+
func (o *Application) Start(call reconcile.Reconcile) error {
115115
o.ctrl.Do = call
116116
return o.mrg.Start(o.stopFn())
117117
}
118118

119119
// GetClient returns a client configured with the Config
120-
func (o *Operator) GetClient() client.Client {
120+
func (o *Application) GetClient() client.Client {
121121
return o.mrg.GetClient()
122122
}

pkg/patterns/operator/operator_suite_test.go renamed to pkg/patterns/application/application_suite_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package operator
1+
package application
22

33
import (
44
"testing"
@@ -10,14 +10,14 @@ import (
1010
import (
1111
"time"
1212

13-
logf "github.com/kubernetes-sigs/controller-runtime/pkg/runtime/log"
14-
"github.com/kubernetes-sigs/controller-runtime/pkg/test"
1513
"k8s.io/client-go/rest"
14+
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
15+
"sigs.k8s.io/controller-runtime/pkg/test"
1616
)
1717

1818
func TestSource(t *testing.T) {
1919
RegisterFailHandler(Fail)
20-
RunSpecsWithDefaultAndCustomReporters(t, "Operator Suite", []Reporter{test.NewlineReporter{}})
20+
RunSpecsWithDefaultAndCustomReporters(t, "Application Suite", []Reporter{test.NewlineReporter{}})
2121
}
2222

2323
var testenv *test.Environment

pkg/patterns/operator/operator_test.go renamed to pkg/patterns/application/application_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
package operator
1+
package application
22

33
import (
44
"fmt"
55

66
"context"
77

8-
"github.com/kubernetes-sigs/controller-runtime/pkg/client/apiutil"
9-
"github.com/kubernetes-sigs/controller-runtime/pkg/controller"
10-
"github.com/kubernetes-sigs/controller-runtime/pkg/manager"
11-
"github.com/kubernetes-sigs/controller-runtime/pkg/reconcile"
128
. "github.com/onsi/ginkgo"
139
. "github.com/onsi/gomega"
1410
appsv1 "k8s.io/api/apps/v1"
@@ -18,9 +14,13 @@ import (
1814
"k8s.io/apimachinery/pkg/runtime/schema"
1915
"k8s.io/apimachinery/pkg/types"
2016
"k8s.io/client-go/rest"
17+
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
18+
"sigs.k8s.io/controller-runtime/pkg/controller"
19+
"sigs.k8s.io/controller-runtime/pkg/manager"
20+
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2121
)
2222

23-
var _ = Describe("Operator", func() {
23+
var _ = Describe("Application", func() {
2424
var stop chan struct{}
2525

2626
BeforeEach(func() {
@@ -99,7 +99,7 @@ var _ = Describe("Operator", func() {
9999

100100
Describe("Start", func() {
101101
It("should Reconcile objects", func(done Done) {
102-
By("Creating the Operator")
102+
By("Creating the Application")
103103
instance, err := New(&appsv1.Deployment{}, &appsv1.ReplicaSet{})
104104
Expect(err).NotTo(HaveOccurred())
105105

@@ -116,11 +116,11 @@ var _ = Describe("Operator", func() {
116116
})
117117
Expect(err).NotTo(HaveOccurred())
118118

119-
By("Starting the Operator")
119+
By("Starting the Application")
120120
go func() {
121121
defer GinkgoRecover()
122122
Expect(instance.Start(fn)).NotTo(HaveOccurred())
123-
By("Stopping the Operator")
123+
By("Stopping the Application")
124124
}()
125125

126126
By("Creating a Deployment")

pkg/patterns/operator/doc.go renamed to pkg/patterns/application/doc.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,28 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package operator provides high-level porcelain wrapping the controller and manager libraries. It
17+
// Package application provides high-level porcelain wrapping the controller and manager libraries. It
1818
// has a minimalist approach to building simple application focused Controllers and hides most details
1919
// from the user.
2020
//
21-
// Projects built with an Operator can trivially be rebased on top of the underlying Controller and Manager
21+
// Note:
22+
//
23+
// Projects built with an Application can trivially be rebased on top of the underlying Controller and Manager
2224
// packages if the project requires more customized behavior in the future.
2325
//
24-
// Operator
26+
// Application
2527
//
26-
// An Operator is a Controller that implements the operational logic for an Application. It is often used
28+
// An Application is a Controller that implements the operational logic for an Application. It is often used
2729
// to take off-the-shelf OSS applications, and make them Kubernetes native.
2830
//
29-
// // First argument is the Reconciled Operator object type, additional arguments are types created
30-
// // by the Operator.
31-
// op, err := operator.New(&appsv1.ReplicaSet{}, &corev1.Pod{})
31+
// // First argument is the Reconciled Application object type, additional arguments are types created
32+
// // by the Application.
33+
// op, err := application.New(&appsv1.ReplicaSet{}, &corev1.Pod{})
3234
// if err != nil {
3335
// log.Fatal(err)
3436
// }
3537
//
36-
// // Implement the Operator logic for a single type - e.g. ReplicaSet
38+
// // Implement the Application logic for a single type - e.g. ReplicaSet
3739
// fn := reconcile.Func(func(req reconcile.Request) (reconcile.Result, error) {
3840
//
3941
// instance := &appsv1.ReplicaSet{}
@@ -49,4 +51,4 @@ limitations under the License.
4951
// })
5052
//
5153
// log.Fatal(op.Start(fn))
52-
package operator
54+
package application

pkg/patterns/operator/example_test.go renamed to pkg/patterns/application/example_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package operator_test
17+
package application_test
1818

1919
import (
2020
"context"
2121
"fmt"
2222
"log"
2323

24-
"github.com/kubernetes-sigs/controller-runtime/pkg/client"
25-
"github.com/kubernetes-sigs/controller-runtime/pkg/patterns/operator"
26-
"github.com/kubernetes-sigs/controller-runtime/pkg/reconcile"
2724
appsv1 "k8s.io/api/apps/v1"
2825
corev1 "k8s.io/api/core/v1"
2926
"k8s.io/apimachinery/pkg/labels"
27+
"sigs.k8s.io/controller-runtime/pkg/client"
28+
"sigs.k8s.io/controller-runtime/pkg/patterns/application"
29+
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3030
)
3131

32-
// This example creates a simple Operator that is configured for Deployments and ReplicaSets.
32+
// This example creates a simple Application that is configured for Deployments and ReplicaSets.
3333
//
34-
// * Create a new Operator for ReplicaSets. Watch Pods owned by ReplicaSets and Reconcile the ReplicaSet.
34+
// * Create a new Application for ReplicaSets. Watch Pods owned by ReplicaSets and Reconcile the ReplicaSet.
3535
//
36-
// * Start the Operator with the Reconcile function.
37-
func ExampleOperator() {
38-
// Create a new Operator for ReplicaSet
36+
// * Start the Application with the Reconcile function.
37+
func ExampleApplication() {
38+
// Create a new Application for ReplicaSet
3939

40-
op, err := operator.New(&appsv1.ReplicaSet{}, &corev1.Pod{})
40+
op, err := application.New(&appsv1.ReplicaSet{}, &corev1.Pod{})
4141
if err != nil {
4242
log.Fatal(err)
4343
}
@@ -79,6 +79,6 @@ func ExampleOperator() {
7979
return reconcile.Result{}, nil
8080
})
8181

82-
// Start the Operator
82+
// Start the Application
8383
log.Fatal(op.Start(rsRecFn))
8484
}

0 commit comments

Comments
 (0)