Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: show user-auth provisioners #14883

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

Merged
merged 9 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions enterprise/coderd/provisionerkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ func (api *API) provisionerKeyDaemons(rw http.ResponseWriter, r *http.Request) {

pkDaemons := []codersdk.ProvisionerKeyDaemons{}
for _, key := range sdkKeys {
// currently we exclude user-auth from this list
// The key.OrganizationID for the `user-auth` key is hardcoded to
// the default org in the database and we are overwriting it here
// to be the correct org we used to query the list.
// This will be changed when we update the `user-auth` keys to be
// directly tied to a user ID.
if key.ID.String() == codersdk.ProvisionerKeyIDUserAuth {
continue
key.OrganizationID = organization.ID
}
daemons := []codersdk.ProvisionerDaemon{}
for _, daemon := range recentDaemons {
Expand Down
37 changes: 32 additions & 5 deletions site/src/modules/provisioners/ProvisionerGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { createDayString } from "utils/createDayString";
import { docs } from "utils/docs";
import { ProvisionerTag } from "./ProvisionerTag";

type ProvisionerGroupType = "builtin" | "psk" | "key";
type ProvisionerGroupType = "builtin" | "userAuth" | "psk" | "key";

interface ProvisionerGroupProps {
readonly buildInfo: BuildInfoResponse;
Expand Down Expand Up @@ -103,7 +103,8 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({
: `${provisionersWithWarnings} provisioners`;

const hasMultipleTagVariants =
type === "psk" && provisioners.some((it) => !isSimpleTagSet(it.tags));
(type === "psk" || type === "userAuth") &&
provisioners.some((it) => !isSimpleTagSet(it.tags));

return (
<div
Expand Down Expand Up @@ -143,6 +144,8 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({
</>
)}

{type === "userAuth" && <UserAuthProvisionerTitle />}

{type === "psk" && <PskProvisionerTitle />}
{type === "key" && (
<h4 css={styles.groupTitle}>Key group &ndash; {keyName}</h4>
Expand Down Expand Up @@ -249,7 +252,7 @@ export const ProvisionerGroup: FC<ProvisionerGroupProps> = ({
</span>
</div>
{hasMultipleTagVariants && (
<PskProvisionerTags tags={provisioner.tags} />
<InlineProvisionerTags tags={provisioner.tags} />
)}
</Stack>
</div>
Expand Down Expand Up @@ -335,11 +338,11 @@ const ProvisionerVersionPopover: FC<ProvisionerVersionPopoverProps> = ({
);
};

interface PskProvisionerTagsProps {
interface InlineProvisionerTagsProps {
tags: Record<string, string>;
}

const PskProvisionerTags: FC<PskProvisionerTagsProps> = ({ tags }) => {
const InlineProvisionerTags: FC<InlineProvisionerTagsProps> = ({ tags }) => {
const daemonScope = tags.scope || "organization";
const iconScope =
daemonScope === "organization" ? <BusinessIcon /> : <PersonIcon />;
Expand Down Expand Up @@ -413,6 +416,30 @@ const BuiltinProvisionerTitle: FC = () => {
);
};

const UserAuthProvisionerTitle: FC = () => {
return (
<h4 css={styles.groupTitle}>
<Stack direction="row" alignItems="end" spacing={1}>
<span>User-authenticated provisioners</span>
<HelpTooltip>
<HelpTooltipTrigger />
<HelpTooltipContent>
<HelpTooltipTitle>User-authenticated provisioners</HelpTooltipTitle>
<HelpTooltipText>
These provisioners are connected by users using the{" "}
<code>coder</code> CLI, and are authorized by the users
credentials. They can be tagged to only run provisioner jobs for
that user. User-authenticated provisioners are only available for
the default organization.{" "}
<Link href={docs("/")}>Learn more&hellip;</Link>
</HelpTooltipText>
</HelpTooltipContent>
</HelpTooltip>
</Stack>
</h4>
);
};

const PskProvisionerTitle: FC = () => {
return (
<h4 css={styles.groupTitle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MockProvisionerBuiltinKey,
MockProvisionerKey,
MockProvisionerPskKey,
MockProvisionerUserAuthKey,
MockProvisionerWithTags,
MockUserProvisioner,
mockApiError,
Expand Down Expand Up @@ -79,6 +80,17 @@ export const Provisioners: Story = {
name: `ケイラ-${i}`,
})),
},
{
key: MockProvisionerUserAuthKey,
daemons: [
MockUserProvisioner,
{
...MockUserProvisioner,
id: "mock-user-provisioner-2",
name: "Test User Provisioner 2",
},
],
},
],
},
play: async ({ step }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,16 @@ const ViewContent: FC<ViewContentProps> = ({ buildInfo, provisioners }) => {
</div>
)}
<Stack spacing={4.5}>
{provisioners.map((group) => {
const type = getGroupType(group.key);

// We intentionally hide user-authenticated provisioners for now
// because there are 1. some grouping issues on the backend and 2. we
// should ideally group them by the user who authenticated them, and
// not just lump them all together.
if (type === "userAuth") {
return null;
}

return (
<ProvisionerGroup
key={group.key.id}
buildInfo={buildInfo}
keyName={group.key.name}
keyTags={group.key.tags}
type={type}
provisioners={group.daemons}
/>
);
})}
{provisioners.map((group) => (
<ProvisionerGroup
key={group.key.id}
buildInfo={buildInfo}
keyName={group.key.name}
keyTags={group.key.tags}
type={getGroupType(group.key)}
provisioners={group.daemons}
/>
))}
</Stack>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export const MockProvisioner2: TypesGen.ProvisionerDaemon = {
};

export const MockUserProvisioner: TypesGen.ProvisionerDaemon = {
...MockProvisioner,
...MockUserAuthProvisioner,
id: "test-user-provisioner",
name: "Test User Provisioner",
tags: { scope: "user", owner: "12345678-abcd-1234-abcd-1234567890abcd" },
Expand Down
Loading