Skip to content

Commit

Permalink
iamuserpolicyattachment: new referenceer pattern
Browse files Browse the repository at this point in the history
Signed-off-by: sahil-lakhwani <sahilakhwani@gmail.com>
  • Loading branch information
sahil-lakhwani committed Apr 24, 2020
1 parent 1d29c1a commit 0f42052
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 393 deletions.
71 changes: 0 additions & 71 deletions apis/identity/v1alpha1/iamuser_references.go

This file was deleted.

197 changes: 0 additions & 197 deletions apis/identity/v1alpha1/iamuser_references_test.go

This file was deleted.

34 changes: 7 additions & 27 deletions apis/identity/v1alpha1/iamuserpolicyattachment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,9 @@ limitations under the License.
package v1alpha1

import (
"github.com/pkg/errors"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

runtimev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
"github.com/crossplane/crossplane-runtime/pkg/resource"
)

// IAMUserNameReferencerForUserPolicyAttachment is an attribute referencer that retrieves Name from a referenced IAMUser
type IAMUserNameReferencerForUserPolicyAttachment struct {
IAMUserNameReferencer `json:",inline"`
}

// Assign assigns the retrieved name to the managed resource
func (v *IAMUserNameReferencerForUserPolicyAttachment) Assign(res resource.CanReference, value string) error {
p, ok := res.(*IAMUserPolicyAttachment)
if !ok {
return errors.New(errResourceIsNotUserPolicyAttachment)
}

p.Spec.ForProvider.UserName = value
return nil
}

// Error strings
const (
errResourceIsNotUserPolicyAttachment = "the managed resource is not an UserPolicyAttachment"
)

// IAMUserPolicyAttachmentParameters define the desired state of an AWS IAMUserPolicyAttachment.
Expand All @@ -56,11 +32,15 @@ type IAMUserPolicyAttachmentParameters struct {

// UserName presents the name of the IAMUser.
// +optional
UserName string `json:"userName,omitempty"`
UserName *string `json:"userName,omitempty"`

// UserNameRef references to an IAMUser to retrieve its userName
// +optional
UserNameRef *runtimev1alpha1.Reference `json:"userNameRef,omitempty"`

// UserNameRef references to an IAMUser to retrieve its Name
// UserNameSelector selects a reference to an IAMUser to retrieve its userName
// +optional
UserNameRef *IAMUserNameReferencerForUserPolicyAttachment `json:"userNameRef,omitempty"`
UserNameSelector *runtimev1alpha1.Selector `json:"userNameSelector,omitempty"`
}

// An IAMUserPolicyAttachmentSpec defines the desired state of an
Expand Down
56 changes: 0 additions & 56 deletions apis/identity/v1alpha1/iamuserpolicyattachment_types_test.go

This file was deleted.

Loading

0 comments on commit 0f42052

Please sign in to comment.