Skip to content

Commit

Permalink
Merge pull request #109 from negz/pacdoc
Browse files Browse the repository at this point in the history
Add package doc for packages that currently lack it.
  • Loading branch information
negz authored Jan 15, 2020
2 parents 4463f1f + 96f3434 commit e0d566e
Show file tree
Hide file tree
Showing 27 changed files with 319 additions and 170 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/claimbinding/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimbinding

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/claimbinding/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimbinding

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/claimbinding/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimbinding

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/claimbinding/configurator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimbinding

import (
"context"
Expand Down
18 changes: 18 additions & 0 deletions pkg/reconciler/claimbinding/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2020 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package claimbinding provides a resource claim binding reconciler.
package claimbinding
2 changes: 1 addition & 1 deletion pkg/reconciler/claimbinding/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimbinding

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/claimbinding/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimbinding

import (
"context"
Expand Down
19 changes: 19 additions & 0 deletions pkg/reconciler/claimdefaulting/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2020 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package claimdefaulting provides a reconciler that sets the default resource
// class for a resource claim.
package claimdefaulting
19 changes: 19 additions & 0 deletions pkg/reconciler/claimscheduling/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2020 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package claimscheduling provides a reconciler that selects a resource class
// for a resource claim.
package claimscheduling
2 changes: 1 addition & 1 deletion pkg/reconciler/claimscheduling/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimscheduling

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/claimscheduling/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package claimscheduling

import (
"strconv"
Expand Down
18 changes: 18 additions & 0 deletions pkg/reconciler/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2020 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package reconciler provides reconcilers for Crossplane resources.
package reconciler
28 changes: 14 additions & 14 deletions pkg/reconciler/managed/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package managed

import (
"context"
Expand All @@ -37,19 +37,19 @@ const (
errUpdateManagedStatus = "cannot update managed resource status"
)

// An APIManagedFinalizer adds and removes finalizers to and from a resource.
type APIManagedFinalizer struct {
// An APIFinalizer adds and removes finalizers to and from a resource.
type APIFinalizer struct {
client client.Client
finalizer string
}

// NewAPIManagedFinalizer returns a new APIManagedFinalizer.
func NewAPIManagedFinalizer(c client.Client, finalizer string) *APIManagedFinalizer {
return &APIManagedFinalizer{client: c, finalizer: finalizer}
// NewAPIFinalizer returns a new APIFinalizer.
func NewAPIFinalizer(c client.Client, finalizer string) *APIFinalizer {
return &APIFinalizer{client: c, finalizer: finalizer}
}

// AddFinalizer to the supplied Managed resource.
func (a *APIManagedFinalizer) AddFinalizer(ctx context.Context, mg resource.Managed) error {
func (a *APIFinalizer) AddFinalizer(ctx context.Context, mg resource.Managed) error {
if meta.FinalizerExists(mg, a.finalizer) {
return nil
}
Expand All @@ -58,23 +58,23 @@ func (a *APIManagedFinalizer) AddFinalizer(ctx context.Context, mg resource.Mana
}

// RemoveFinalizer from the supplied Managed resource.
func (a *APIManagedFinalizer) RemoveFinalizer(ctx context.Context, mg resource.Managed) error {
func (a *APIFinalizer) RemoveFinalizer(ctx context.Context, mg resource.Managed) error {
meta.RemoveFinalizer(mg, a.finalizer)
return errors.Wrap(resource.IgnoreNotFound(a.client.Update(ctx, mg)), errUpdateManaged)
}

// ManagedNameAsExternalName writes the name of the managed resource to
// NameAsExternalName writes the name of the managed resource to
// the external name annotation field in order to be used as name of
// the external resource in provider.
type ManagedNameAsExternalName struct{ client client.Client }
type NameAsExternalName struct{ client client.Client }

// NewManagedNameAsExternalName returns a new ManagedNameAsExternalName.
func NewManagedNameAsExternalName(c client.Client) *ManagedNameAsExternalName {
return &ManagedNameAsExternalName{client: c}
// NewNameAsExternalName returns a new NameAsExternalName.
func NewNameAsExternalName(c client.Client) *NameAsExternalName {
return &NameAsExternalName{client: c}
}

// Initialize the given managed resource.
func (a *ManagedNameAsExternalName) Initialize(ctx context.Context, mg resource.Managed) error {
func (a *NameAsExternalName) Initialize(ctx context.Context, mg resource.Managed) error {
if meta.GetExternalName(mg) != "" {
return nil
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/reconciler/managed/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package managed

import (
"context"
Expand All @@ -38,8 +38,8 @@ import (
)

var (
_ ManagedFinalizer = &APIManagedFinalizer{}
_ ManagedInitializer = &ManagedNameAsExternalName{}
_ Finalizer = &APIFinalizer{}
_ Initializer = &NameAsExternalName{}
)

func TestManagedRemoveFinalizer(t *testing.T) {
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestManagedRemoveFinalizer(t *testing.T) {

for name, tc := range cases {
t.Run(name, func(t *testing.T) {
api := NewAPIManagedFinalizer(tc.client, finalizer)
api := NewAPIFinalizer(tc.client, finalizer)
err := api.RemoveFinalizer(tc.args.ctx, tc.args.mg)
if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" {
t.Errorf("api.RemoveFinalizer(...): -want error, +got error:\n%s", diff)
Expand All @@ -100,7 +100,7 @@ func TestManagedRemoveFinalizer(t *testing.T) {
}
}

func TestAPIManagedFinalizerAdder(t *testing.T) {
func TestAPIFinalizerAdder(t *testing.T) {
finalizer := "veryfinal"

type args struct {
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestAPIManagedFinalizerAdder(t *testing.T) {

for name, tc := range cases {
t.Run(name, func(t *testing.T) {
api := NewAPIManagedFinalizer(tc.client, finalizer)
api := NewAPIFinalizer(tc.client, finalizer)
err := api.AddFinalizer(tc.args.ctx, tc.args.mg)
if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" {
t.Errorf("api.Initialize(...): -want error, +got error:\n%s", diff)
Expand All @@ -158,7 +158,7 @@ func TestAPIManagedFinalizerAdder(t *testing.T) {
}
}

func TestManagedNameAsExternalName(t *testing.T) {
func TestNameAsExternalName(t *testing.T) {
type args struct {
ctx context.Context
mg resource.Managed
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestManagedNameAsExternalName(t *testing.T) {

for name, tc := range cases {
t.Run(name, func(t *testing.T) {
api := NewManagedNameAsExternalName(tc.client)
api := NewNameAsExternalName(tc.client)
err := api.Initialize(tc.args.ctx, tc.args.mg)
if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" {
t.Errorf("api.Initialize(...): -want error, +got error:\n%s", diff)
Expand Down
19 changes: 19 additions & 0 deletions pkg/reconciler/managed/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2020 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package managed provides a reconciler that manages the lifecycle of a
// resource in an external system.
package managed
8 changes: 4 additions & 4 deletions pkg/reconciler/managed/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package managed

import (
"context"
Expand All @@ -23,9 +23,9 @@ import (
)

// A PublisherChain chains multiple ManagedPublishers.
type PublisherChain []ManagedConnectionPublisher
type PublisherChain []ConnectionPublisher

// PublishConnection calls each ManagedConnectionPublisher.PublishConnection serially. It returns the first error it
// PublishConnection calls each ConnectionPublisher.PublishConnection serially. It returns the first error it
// encounters, if any.
func (pc PublisherChain) PublishConnection(ctx context.Context, mg resource.Managed, c ConnectionDetails) error {
for _, p := range pc {
Expand All @@ -36,7 +36,7 @@ func (pc PublisherChain) PublishConnection(ctx context.Context, mg resource.Mana
return nil
}

// UnpublishConnection calls each ManagedConnectionPublisher.UnpublishConnection serially. It returns the first error it
// UnpublishConnection calls each ConnectionPublisher.UnpublishConnection serially. It returns the first error it
// encounters, if any.
func (pc PublisherChain) UnpublishConnection(ctx context.Context, mg resource.Managed, c ConnectionDetails) error {
for _, p := range pc {
Expand Down
12 changes: 6 additions & 6 deletions pkg/reconciler/managed/publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package resource
package managed

import (
"context"
Expand All @@ -29,8 +29,8 @@ import (
)

var (
_ ManagedConnectionPublisher = &APISecretPublisher{}
_ ManagedConnectionPublisher = PublisherChain{}
_ ConnectionPublisher = &APISecretPublisher{}
_ ConnectionPublisher = PublisherChain{}
)

func TestPublisherChain(t *testing.T) {
Expand All @@ -43,7 +43,7 @@ func TestPublisherChain(t *testing.T) {
errBoom := errors.New("boom")

cases := map[string]struct {
p ManagedConnectionPublisher
p ConnectionPublisher
args args
want error
}{
Expand All @@ -58,7 +58,7 @@ func TestPublisherChain(t *testing.T) {
},
"SuccessfulPublisher": {
p: PublisherChain{
ManagedConnectionPublisherFns{
ConnectionPublisherFns{
PublishConnectionFn: func(_ context.Context, mg resource.Managed, c ConnectionDetails) error {
return nil
},
Expand All @@ -76,7 +76,7 @@ func TestPublisherChain(t *testing.T) {
},
"PublisherReturnsError": {
p: PublisherChain{
ManagedConnectionPublisherFns{
ConnectionPublisherFns{
PublishConnectionFn: func(_ context.Context, mg resource.Managed, c ConnectionDetails) error {
return errBoom
},
Expand Down
Loading

0 comments on commit e0d566e

Please sign in to comment.