Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/repositories/detail/variables/EnableDockerdAuthentication.tsx
2502 views
1
/**
2
* Copyright (c) 2025 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { SwitchInputField } from "@podkit/switch/Switch";
8
import { Heading3, Subheading } from "@podkit/typography/Headings";
9
import { FC, useCallback } from "react";
10
import { InputField } from "../../../components/forms/InputField";
11
import { useToast } from "../../../components/toasts/Toasts";
12
import { useId } from "../../../hooks/useId";
13
import { ConfigurationSettingsField } from "../ConfigurationSettingsField";
14
import { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb";
15
import { SquareArrowOutUpRight } from "lucide-react";
16
import { useConfiguration, useConfigurationMutation } from "../../../data/configurations/configuration-queries";
17
import Alert from "../../../components/Alert";
18
19
type Props = {
20
configuration: Configuration;
21
};
22
export const EnableDockerdAuthentication: FC<Props> = ({ configuration }) => {
23
const { data } = useConfiguration(configuration.id);
24
const configurationMutation = useConfigurationMutation();
25
const { toast } = useToast();
26
27
const updateEnableDockerdAuthentication = useCallback(
28
async (enable: boolean) => {
29
await configurationMutation.mutateAsync(
30
{
31
configurationId: configuration.id,
32
workspaceSettings: {
33
enableDockerdAuthentication: enable,
34
},
35
},
36
{
37
onError: (error) => {
38
toast(`Failed to update dockerd authentication: ${error.message}`);
39
},
40
},
41
);
42
},
43
[configurationMutation, configuration.id, toast],
44
);
45
46
const inputId = useId({ prefix: "enable-dockerd-authentication" });
47
const isEnabled = data?.workspaceSettings?.enableDockerdAuthentication;
48
49
return (
50
<ConfigurationSettingsField>
51
<Heading3 className="flex flex-row items-center gap-2">Docker registry authentication</Heading3>
52
<Subheading className="max-w-lg flex flex-col gap-2">
53
<span className="flex-1 text-left">
54
Enable authentication with Docker registries inside of workspaces based on the{" "}
55
<code>GITPOD_IMAGE_AUTH</code> environment variable.
56
</span>
57
58
<Alert type={"warning"} closable={false} showIcon={true} className="flex rounded p-2 mb-2 w-full">
59
By enabling this, credentials specified in <code>GITPOD_IMAGE_AUTH</code> will be visible inside all
60
workspaces on this project.
61
</Alert>
62
<a
63
className="gp-link flex flex-row items-center gap-1"
64
href="https://www.gitpod.io/docs/configure/repositories/environment-variables#docker-registry-authentication"
65
target="_blank"
66
rel="noreferrer"
67
>
68
Learn about using private Docker images with Gitpod
69
<SquareArrowOutUpRight size={12} />
70
</a>
71
</Subheading>
72
<InputField id={inputId}>
73
<SwitchInputField
74
id={inputId}
75
checked={isEnabled}
76
disabled={configurationMutation.isLoading}
77
onCheckedChange={updateEnableDockerdAuthentication}
78
label={isEnabled ? "Auto-login enabled" : "Auto-login disabled"}
79
/>
80
</InputField>
81
</ConfigurationSettingsField>
82
);
83
};
84
85