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

Bug 1795407: tolerate invalid K8sResourceLink spec descriptor #4095

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,23 @@ const ResourceRequirements: React.SFC<SpecCapabilityProps> = ({ obj, descriptor
</dl>
);

const K8sResourceLink: React.SFC<SpecCapabilityProps> = (props) =>
_.isEmpty(props.value) ? (
<span className="text-muted">None</span>
) : (
<ResourceLink
kind={props.capability.split(SpecCapability.k8sResourcePrefix)[1]}
name={props.value}
namespace={props.namespace}
/>
);
const K8sResourceLink: React.SFC<SpecCapabilityProps> = (props) => {
if (!props.value) {
return <span className="text-muted">None</span>;
}

const kind = props.capability.split(SpecCapability.k8sResourcePrefix)[1];
if (!_.isString(props.value)) {
return (
<>
<YellowExclamationTriangleIcon /> Invalid spec descriptor: value at path &apos;
{props.descriptor.path}&apos; must be a {kind} resource name.
</>
);
}

return <ResourceLink kind={kind} name={props.value} namespace={props.namespace} />;
};

const BasicSelector: React.SFC<SpecCapabilityProps> = ({ value, capability }) => (
<Selector selector={value} kind={capability.split(SpecCapability.selector)[1]} />
Expand Down