Skip to content

Conversation

@rawagner
Copy link
Contributor

No description provided.

@openshift-ci-robot openshift-ci-robot added component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dashboard Related to dashboard component/noobaa Related to noobaa-storage-plugin size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 18, 2019
@rawagner
Copy link
Contributor Author

/hold
for 4.4

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 18, 2019
@rawagner
Copy link
Contributor Author

rawagner commented Dec 2, 2019

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 2, 2019
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

I like this idea 👍

Copy link
Member

Choose a reason for hiding this comment

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

I'd expect this to always return a single resource and we'd have useListK8s for lists. I might call it useK8sGet to be consistent with k8sGet. We probably want K8sResourceCommon as the type here.

Suggested change
export const useGetK8s = <R extends K8sResourceKind | K8sResourceKind[] = K8sResourceKind>(
export const useK8sGet = <R extends K8sResourceCommon = K8sResourceKind>(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

K8sResourceCommon is probably better but its incompatible with K8sResourceKind.

K8sResourceCommon has all props required but K8sResourceKind has all props from K8sResourceCommon optional. It seems to me that K8sResourceKind should extend K8sResourceCommon (added to this PR) but I wonder if the apiVersion, kind and metadata should be optional or required ? So far I've marked them as optional.

Naming updated per your suggestion

Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense for K8sResourceKind to extend K8sResourceCommon.

Should the default be K8sResourceCommon? I'd like to start getting away from K8sResourceKind since it doesn't guard against property name typos due to [key: string]: any;

https://github.com/openshift/console/blob/master/frontend/public/module/k8s/index.ts#L123

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, changed the default to K8sResourceCommon

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice cleanup!

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/shared Related to console-shared and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 11, 2019
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm

export const getKind = <A extends K8sResourceCommon = K8sResourceCommon>(value: A) =>
_.get(value, 'kind') as K8sResourceCommon['kind'];
export const getOwnerReferences = <A extends K8sResourceCommon = K8sResourceCommon>(value: A) =>
_.get(value, 'metadata.ownerReferences') as K8sResourceCommon['metadata']['ownerReferences'];
Copy link
Member

Choose a reason for hiding this comment

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

When #3747 merges, we should be able to switch to optional chaining for better type safety.

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining

setLoaded(true);
}
};
fetch();
Copy link
Member

Choose a reason for hiding this comment

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

We might consider using AbortController to cancel the request if the component unmounts as in #1775. I'm not sure offhand if it would work with k8sGet

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 11, 2019
@spadgett spadgett added this to the v4.4 milestone Dec 11, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rawagner, spadgett

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

The pull request process is described here

Details 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

@openshift-merge-robot openshift-merge-robot merged commit 8629fb2 into openshift:master Dec 11, 2019
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. component/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dashboard Related to dashboard component/noobaa Related to noobaa-storage-plugin component/shared Related to console-shared 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.

5 participants