Skip to content
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

Code cleanup #659

Merged
merged 1 commit into from
Sep 12, 2024
Merged

Code cleanup #659

merged 1 commit into from
Sep 12, 2024

Conversation

kishen-v
Copy link
Contributor

@kishen-v kishen-v commented Sep 11, 2024

Includes definitions to reuse code, removes unused definitions and redundant declarations.

@ppc64le-cloud-bot ppc64le-cloud-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 11, 2024
return nil, errors.ToError(err)
}
return resp.Payload, nil
return c.client.GetAll()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A definition for GetAll() exists in power-go-client. The same has been re-used as the functionality is indifferent from the current implementation.

	params := p_cloud_volumes.NewPcloudCloudinstancesVolumesGetallParams().
		WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).
		WithCloudInstanceID(f.cloudInstanceID)
	resp, err := f.session.Power.PCloudVolumes.PcloudCloudinstancesVolumesGetall(params, f.session.AuthInfo(f.cloudInstanceID))
	if err != nil {
		return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get all Volumes for Cloud Instance %s: %w", f.cloudInstanceID, err))
	}
	if resp == nil || resp.Payload == nil {
		return nil, fmt.Errorf("failed to Get all Volumes for Cloud Instance %s", f.cloudInstanceID)
	}
	return resp.Payload, nil

@@ -27,13 +27,6 @@ type ResourceControllerV2 struct {
ResourceControllerV2 *rcv2.ResourceControllerV2
}

func NewResourceControllerV2(r *rcv2.ResourceControllerV2Options) (*ResourceControllerV2, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused definiton.

@@ -52,22 +47,14 @@ func (c *Client) GetAllPublic() (*models.Networks, error) {
}

func (c *Client) GetAll() (*models.Networks, error) {
params := p_cloud_networks.NewPcloudNetworksGetallParamsWithTimeout(pkg.TIMEOUT).WithCloudInstanceID(c.instanceID)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An existing definition exists in power-go-client. The definition is indifferent from the one in the imported package.

func (f *IBMPINetworkClient) GetAll() (*models.Networks, error) {
	params := p_cloud_networks.NewPcloudNetworksGetallParams().
		WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).
		WithCloudInstanceID(f.cloudInstanceID)
	resp, err := f.session.Power.PCloudNetworks.PcloudNetworksGetall(params, f.session.AuthInfo(f.cloudInstanceID))
	if err != nil {
		return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Get Network for cloud instance %s with error %w", f.cloudInstanceID, err))
	}
	if resp == nil || resp.Payload == nil {
		return nil, fmt.Errorf("failed to Get Network for cloud instance %s", f.cloudInstanceID)
	}
	return resp.Payload, nil
}

Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let us split into two PRs..

@kishen-v
Copy link
Contributor Author

/hold for #660

@ppc64le-cloud-bot ppc64le-cloud-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 12, 2024
@kishen-v kishen-v changed the title Fix image purge when provided with workspace name and cleanup code. Code cleanup Sep 12, 2024
@kishen-v kishen-v force-pushed the cleanup-3 branch 2 times, most recently from 335bab8 to a6d940c Compare September 12, 2024 08:03
@kishen-v
Copy link
Contributor Author

/unhold

@ppc64le-cloud-bot ppc64le-cloud-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 12, 2024
Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@ppc64le-cloud-bot ppc64le-cloud-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2024
@ppc64le-cloud-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kishen-v, mkumatag

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ppc64le-cloud-bot ppc64le-cloud-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 12, 2024
@ppc64le-cloud-bot ppc64le-cloud-bot merged commit a1e721f into ppc64le-cloud:main Sep 12, 2024
4 of 5 checks passed
@kishen-v kishen-v deleted the cleanup-3 branch September 13, 2024 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants