mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix CRB's not being able to specify names, fixed SA not being bound to their namespace
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
755d1b383b
commit
c20850fbd4
@ -27,6 +27,7 @@ export interface ClusterRoleBindingSubject {
|
|||||||
kind: ClusterRoleBindingSubjectKind;
|
kind: ClusterRoleBindingSubjectKind;
|
||||||
name: string;
|
name: string;
|
||||||
apiGroup?: string;
|
apiGroup?: string;
|
||||||
|
namespace?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClusterRoleBinding {
|
export interface ClusterRoleBinding {
|
||||||
|
|||||||
@ -39,6 +39,7 @@ import { clusterRoleBindingsStore } from "./store";
|
|||||||
import { clusterRolesStore } from "../+cluster-roles/store";
|
import { clusterRolesStore } from "../+cluster-roles/store";
|
||||||
import { getRoleRefSelectOption, ServiceAccountOption } from "../select-options";
|
import { getRoleRefSelectOption, ServiceAccountOption } from "../select-options";
|
||||||
import { ObservableHashSet, nFircate } from "../../../utils";
|
import { ObservableHashSet, nFircate } from "../../../utils";
|
||||||
|
import { Input } from "../../input";
|
||||||
|
|
||||||
interface Props extends Partial<DialogProps> {
|
interface Props extends Partial<DialogProps> {
|
||||||
}
|
}
|
||||||
@ -94,6 +95,7 @@ export class ClusterRoleBindingDialog extends React.Component<Props> {
|
|||||||
const serviceAccounts = Array.from(this.selectedAccounts, sa => ({
|
const serviceAccounts = Array.from(this.selectedAccounts, sa => ({
|
||||||
name: sa.getName(),
|
name: sa.getName(),
|
||||||
kind: "ServiceAccount" as const,
|
kind: "ServiceAccount" as const,
|
||||||
|
namespace: sa.getNs(),
|
||||||
}));
|
}));
|
||||||
const users = Array.from(this.selectedUsers, user => ({
|
const users = Array.from(this.selectedUsers, user => ({
|
||||||
name: user,
|
name: user,
|
||||||
@ -143,7 +145,7 @@ export class ClusterRoleBindingDialog extends React.Component<Props> {
|
|||||||
this.selectedRoleRef = clusterRolesStore
|
this.selectedRoleRef = clusterRolesStore
|
||||||
.items
|
.items
|
||||||
.find(item => item.getName() === binding.roleRef.name);
|
.find(item => item.getName() === binding.roleRef.name);
|
||||||
this.bindingName = this.selectedRoleRef.getName();
|
this.bindingName = this.clusterRoleBinding.getName();
|
||||||
|
|
||||||
const [saSubjects, uSubjects, gSubjects] = nFircate(binding.getSubjects(), "kind", ["ServiceAccount", "User", "Group"]);
|
const [saSubjects, uSubjects, gSubjects] = nFircate(binding.getSubjects(), "kind", ["ServiceAccount", "User", "Group"]);
|
||||||
const accountNames = new Set(saSubjects.map(acc => acc.name));
|
const accountNames = new Set(saSubjects.map(acc => acc.name));
|
||||||
@ -152,7 +154,6 @@ export class ClusterRoleBindingDialog extends React.Component<Props> {
|
|||||||
serviceAccountsStore.items
|
serviceAccountsStore.items
|
||||||
.filter(sa => accountNames.has(sa.getName()))
|
.filter(sa => accountNames.has(sa.getName()))
|
||||||
);
|
);
|
||||||
console.log("onOpen", this.selectedAccounts.size, this.selectedAccounts.toJSON());
|
|
||||||
this.selectedUsers.replace(uSubjects.map(user => user.name));
|
this.selectedUsers.replace(uSubjects.map(user => user.name));
|
||||||
this.selectedGroups.replace(gSubjects.map(group => group.name));
|
this.selectedGroups.replace(gSubjects.map(group => group.name));
|
||||||
};
|
};
|
||||||
@ -197,7 +198,18 @@ export class ClusterRoleBindingDialog extends React.Component<Props> {
|
|||||||
isDisabled={this.isEditing}
|
isDisabled={this.isEditing}
|
||||||
options={this.clusterRoleRefoptions}
|
options={this.clusterRoleRefoptions}
|
||||||
value={this.selectedRoleRef}
|
value={this.selectedRoleRef}
|
||||||
onChange={({ value }) => this.selectedRoleRef = value}
|
onChange={({ value }) => {
|
||||||
|
this.selectedRoleRef = value;
|
||||||
|
this.bindingName = this.selectedRoleRef.getName();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<SubTitle title="Binding Name" />
|
||||||
|
<Input
|
||||||
|
placeholder="Name of ClusterRoleBinding ..."
|
||||||
|
disabled={this.isEditing}
|
||||||
|
value={this.bindingName}
|
||||||
|
onChange={val => this.bindingName = val}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SubTitle title="Binding targets" />
|
<SubTitle title="Binding targets" />
|
||||||
@ -241,13 +253,8 @@ export class ClusterRoleBindingDialog extends React.Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { ...dialogProps } = this.props;
|
const { ...dialogProps } = this.props;
|
||||||
const { isEditing, clusterRoleBinding, selectedRoleRef, selectedBindings } = this;
|
const [action, nextLabel] = this.isEditing ? ["Edit", "Update"] : ["Add", "Create"];
|
||||||
const clusterRoleBindingName = clusterRoleBinding?.getName();
|
const disableNext = !this.selectedRoleRef || !this.selectedBindings.length;
|
||||||
const header = clusterRoleBindingName
|
|
||||||
? <h5>Edit ClusterRoleBinding <span className="name">{clusterRoleBindingName}</span></h5>
|
|
||||||
: <h5>Add ClusterRoleBinding</h5>;
|
|
||||||
const disableNext = !selectedRoleRef || !selectedBindings.length;
|
|
||||||
const nextLabel = isEditing ? "Update" : "Create";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@ -259,7 +266,7 @@ export class ClusterRoleBindingDialog extends React.Component<Props> {
|
|||||||
onOpen={this.onOpen}
|
onOpen={this.onOpen}
|
||||||
>
|
>
|
||||||
<Wizard
|
<Wizard
|
||||||
header={header}
|
header={<h5>{action} ClusterRoleBinding</h5>}
|
||||||
done={ClusterRoleBindingDialog.close}
|
done={ClusterRoleBindingDialog.close}
|
||||||
>
|
>
|
||||||
<WizardStep
|
<WizardStep
|
||||||
|
|||||||
@ -222,18 +222,17 @@ export class RoleBindingDialog extends React.Component<Props> {
|
|||||||
if (this.selectedRoleRef.kind === "Role") {
|
if (this.selectedRoleRef.kind === "Role") {
|
||||||
this.bindingNamespace = this.selectedRoleRef.getNs();
|
this.bindingNamespace = this.selectedRoleRef.getNs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.bindingName = this.selectedRoleRef.getName();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{!this.isEditing && (
|
<SubTitle title="Role Binding Name" />
|
||||||
<>
|
<Input
|
||||||
<SubTitle title="Role Binding Name" />
|
disabled={this.isEditing}
|
||||||
<Input
|
value={this.bindingName}
|
||||||
value={this.bindingName}
|
onChange={value => this.bindingName = value}
|
||||||
onChange={value => this.bindingName = value}
|
/>
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<SubTitle title="Binding targets" />
|
<SubTitle title="Binding targets" />
|
||||||
|
|
||||||
@ -276,18 +275,8 @@ export class RoleBindingDialog extends React.Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { ...dialogProps } = this.props;
|
const { ...dialogProps } = this.props;
|
||||||
const { isEditing, roleBinding, selectedRoleRef, selectedBindings } = this;
|
const [action, nextLabel] = this.isEditing ? ["Edit", "Update"] : ["Add", "Create"];
|
||||||
const roleBindingName = roleBinding ? roleBinding.getName() : "";
|
const disableNext = !this.selectedRoleRef || !this.selectedBindings.length;
|
||||||
const header = (
|
|
||||||
<h5>
|
|
||||||
{roleBindingName
|
|
||||||
? <>Edit RoleBinding <span className="name">{roleBindingName}</span></>
|
|
||||||
: "Add RoleBinding"
|
|
||||||
}
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
const disableNext = !selectedRoleRef || !selectedBindings.length;
|
|
||||||
const nextLabel = isEditing ? "Update" : "Create";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@ -299,7 +288,7 @@ export class RoleBindingDialog extends React.Component<Props> {
|
|||||||
onOpen={this.onOpen}
|
onOpen={this.onOpen}
|
||||||
>
|
>
|
||||||
<Wizard
|
<Wizard
|
||||||
header={header}
|
header={<h5>{action} RoleBinding</h5>}
|
||||||
done={RoleBindingDialog.close}
|
done={RoleBindingDialog.close}
|
||||||
>
|
>
|
||||||
<WizardStep
|
<WizardStep
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user