-
Notifications
You must be signed in to change notification settings - Fork 363
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 DBSubnetGroup to v1beta1 #162
Move DBSubnetGroup to v1beta1 #162
Conversation
2c1ff5a
to
c67027e
Compare
if !ok { | ||
return errors.New(errUnexpectedObject) | ||
} | ||
|
||
cr.Status.SetConditions(runtimev1alpha1.Deleting()) | ||
|
||
req := e.client.DeleteDBSubnetGroupRequest(&awsrds.DeleteDBSubnetGroupInput{ | ||
DBSubnetGroupName: aws.String(cr.Spec.DBSubnetGroupName), | ||
DBSubnetGroupName: aws.String(cr.Spec.ForProvider.DBSubnetGroupName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DBSubnetGroupName: aws.String(cr.Spec.ForProvider.DBSubnetGroupName), | |
DBSubnetGroupName: meta.GetExternalName(cr), |
if !ok { | ||
return errors.New(errUnexpectedObject) | ||
} | ||
|
||
cr.Status.SetConditions(runtimev1alpha1.Deleting()) | ||
|
||
req := e.client.DeleteDBSubnetGroupRequest(&awsrds.DeleteDBSubnetGroupInput{ | ||
DBSubnetGroupName: aws.String(cr.Spec.DBSubnetGroupName), | ||
DBSubnetGroupName: aws.String(cr.Spec.ForProvider.DBSubnetGroupName), | ||
}) | ||
|
||
_, err := req.Send(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_, err := req.Send(ctx) | |
_, err := req.Send(ctx) | |
return errors.Wrap(resource.Ignore(rds.IsDBSubnetGroupNotFoundErr, err), errDelete) |
resource.Ignore
will skip that specific error by running the func you provide, which is rds.IsDBSubnetGroupNotFoundErr
in this case.
88b0b8f
to
885711a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good. I think we can merge it after the comments are addressed. I'd also suggest going over the commit list and consolidate some of them. For commit messages, I'm not sure whether we have a convention but I usually go with dbsubnetgroup: this commit does that
.
} | ||
|
||
// IsDBSubnetGroupUpToDate checks whether there is a change in any of the modifiable fields. | ||
func IsDBSubnetGroupUpToDate(p v1beta1.DBSubnetGroupParameters, sg rds.DBSubnetGroup) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are only 2 fields that might need update since Modify
call takes only those. So, it might be easier just to check DBSubnetGroupDescription
and SubnetIDs
fields and see whether they changed and return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment assumed that we were not able to update the tags but that's actually possible later I realized. So, you need to check tags as well.
SubnetIds: cr.Spec.SubnetIDs, | ||
DBSubnetGroupDescription: aws.String(cr.Spec.ForProvider.DBSubnetGroupDescription), | ||
DBSubnetGroupName: aws.String(cr.Spec.ForProvider.DBSubnetGroupName), | ||
SubnetIds: cr.Spec.ForProvider.SubnetIDs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly, in my comment, I was saying that DBSubnetGroupParameters
should have a Tags
field and it seems to be the case now.
SubnetGroupStatus string `json:"subnetGroupStatus,omitempty"` | ||
|
||
// DBSubnetGroupArn is the Amazon Resource Name (ARN) for this DB subnet group. | ||
DBSubnetGroupArn string `json:"dbSubnetGroupArn,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think state
and arn
would be sufficient for names as it's already implied with these fields being under DBSubnetGroup CRD. I see that they are indeed named as DBSubnetGroupArn
and SubnetGroupStatus
in cloud API but IMO we should go with state
and arn
as it's really unnecessary.
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.groupStatus" | ||
// +kubebuilder:printcolumn:name="GROUPNAME",type="string",JSONPath=".spec.forProvider.groupName" | ||
// +kubebuilder:printcolumn:name="DESCRIPTION",type="string",JSONPath=".spec.forProvider.description" | ||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.atProvider.groupStatus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.atProvider.groupStatus" | |
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.atProvider.subnetGroupStatus" |
// +kubebuilder:printcolumn:name="GROUPNAME",type="string",JSONPath=".spec.groupName" | ||
// +kubebuilder:printcolumn:name="DESCRIPTION",type="string",JSONPath=".spec.description" | ||
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.groupStatus" | ||
// +kubebuilder:printcolumn:name="GROUPNAME",type="string",JSONPath=".spec.forProvider.groupName" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// +kubebuilder:printcolumn:name="GROUPNAME",type="string",JSONPath=".spec.forProvider.groupName" |
|
||
// CreatePatch creates a *v1beta1.DBSubnetGroupParameters that has only the changed | ||
// values between the target *v1beta1.DBSubnetGroupParameters and the current *rds.DBSubnetGroup | ||
func CreatePatch(in *rds.DBSubnetGroup, target *v1beta1.DBSubnetGroupParameters) (*v1beta1.DBSubnetGroupParameters, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any usage of func CreatePatch
other than is-up-to-date check, so, it'd be better if you can remove it after making the is-up-to-date simpler.
1e84685
to
a0539fc
Compare
} | ||
|
||
// IsDBSubnetGroupUpToDate checks whether there is a change in any of the modifiable fields. | ||
func IsDBSubnetGroupUpToDate(p v1beta1.DBSubnetGroupParameters, sg rds.DBSubnetGroup) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment assumed that we were not able to update the tags but that's actually possible later I realized. So, you need to check tags as well.
Tags []Tag `json:"tags,omitempty"` | ||
} | ||
|
||
// A DBSubnetGroupSpec defines the desired state of a DBSubnetGroup. | ||
type DBSubnetGroupSpec struct { | ||
runtimev1alpha1.ResourceSpec `json:",inline"` | ||
DBSubnetGroupParameters `json:",inline"` | ||
ForProvider DBSubnetGroupParameters `json:"forProvider,omitempty"` | ||
} | ||
|
||
// DBSubnetGroupExternalStatus keeps the state for the external resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DBSubnetGroupExternalStatus
doesn't seem to be used anywhere, so you might as well remove it.
if id == value { | ||
return nil | ||
} | ||
} | ||
|
||
sg.Spec.SubnetIDs = append(sg.Spec.SubnetIDs, value) | ||
sg.Spec.ForProvider.SubnetIDs = append(sg.Spec.ForProvider.SubnetIDs, value) | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the line var _ resource.AttributeReferencer = (*SubnetIDReferencerForDBSubnetGroup)(nil)
as that struct already has its own test file to test this interface conformance.
Please make sure the functionality works as expected by testing manually. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few nitpicks unaddressed but the PR should be ready to go. @gauravgahlot thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nitpicks, but I think we can move forward and circle back around for any clean-up. Thanks for your great work @gauravgahlot! Could you post any manual testing you have done as a comment? (or point me to where you already have if I missed it scrolling through the comments)
@@ -167,7 +166,8 @@ func TestDBSubnetGroupNameReferencerBuild(t *testing.T) { | |||
input: input{ | |||
readerFn: func(ctx context.Context, key client.ObjectKey, obj runtime.Object) error { | |||
p := obj.(*DBSubnetGroup) | |||
p.Spec.DBSubnetGroupName = mockDBSubnetGroupName | |||
// p.Spec.ForProvider.DBSubnetGroupName = mockDBSubnetGroupName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed here
SubnetStatus: aws.StringValue(sn.SubnetStatus), | ||
} | ||
} | ||
// DBSubnetGroupObservation is the representation of the current state that is observed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: would you mind moving this up above DBSubnetGroupStatus
where DBSubnetGroupExternalStatus
is currently?
) | ||
|
||
// Client is the external client used for DBSubnetGroup Custom Resource | ||
type Client interface { // nolint:gocyclo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: is // nolint:gocyclo
needed here?
@@ -19,17 +19,20 @@ package fake | |||
import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: might make sense to move this file fake/dbsubnetgroup.go
from clients/rds
to clients/dbsubnetgroup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! You can consider squash some commits and/or clean up commit messages before the merge but that shouldn't block merging. cc @negz for merge.
Signed-off-by: Gaurav Gahlot <ggahlot@infracloud.io>
Signed-off-by: Gaurav Gahlot <gaurav.gahlot19@gmail.com>
Signed-off-by: Gaurav Gahlot <gaurav.gahlot19@gmail.com>
Signed-off-by: Gaurav Gahlot <ggahlot@infracloud.io>
Signed-off-by: Gaurav Gahlot <ggahlot@infracloud.io>
Signed-off-by: Gaurav Gahlot <ggahlot@infracloud.io>
Signed-off-by: Gaurav Gahlot <gaurav.gahlot19@gmail.com>
Signed-off-by: Gaurav Gahlot <gaurav.gahlot19@gmail.com>
64eb303
to
f17dd77
Compare
Move DBSubnetGroup to v1beta1 Signed-off-by: Gaurav Gahlot <ggahlot@infracloud.io> Signed-off-by: ajaykangare <ajaykangare1993@gmail.com>
Move DBSubnetGroup to v1beta1 Signed-off-by: Gaurav Gahlot <ggahlot@infracloud.io>
Move DBSubnetGroup to v1beta1
Description of your changes
v1alpha3
tov1beta1
.Tested with the following:
Checklist
I have:
make reviewable
to ensure this PR is ready for review.app.yaml
to include any new role permissions.