Skip to content
Open
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
25 changes: 23 additions & 2 deletions packages/api-v4/src/linodes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import type {
CreateLinodeInterfaceSchema,
ModifyLinodeInterfaceSchema,
RebuildLinodeSchema,
UpdateLinodeInterfaceSettingsSchema,
UpgradeToLinodeInterfaceSchema,
} from '@linode/validation';
Expand Down Expand Up @@ -653,6 +652,11 @@
* @default false
*/
backups_enabled?: boolean | null;
/**
* When deploying from an Image, this field is optional, otherwise it is ignored.
* This is used to set the boot size for the newly-created Linode.
*/
boot_size?: null | number;
/**
* If it is deployed from an Image or a Backup and you wish it to remain offline after deployment, set this to false.
*
Expand Down Expand Up @@ -694,6 +698,11 @@
* Must be empty if Linode is configured to use new Linode Interfaces.
*/
ipv4?: string[];
/**
* When deploying from an Image, this field is optional, otherwise it is ignored.
* This is used to set the kernel type for the newly-created Linode.
*/
kernel?: null | string;
/**
* The Linode's label is for display purposes only.
* If no label is provided for a Linode, a default will be assigned.
Expand Down Expand Up @@ -779,7 +788,19 @@
type?: null | string;
}

export type RebuildRequest = InferType<typeof RebuildLinodeSchema>;
export interface RebuildRequest {
authorized_keys?: string[];
authorized_users?: string[];
booted?: boolean;
disk_encryption?: 'disabled' | 'enabled';
image: string;
metadata?: {
user_data: null | string;
};
root_pass?: string;
stackscript_data?: null | {};

Check warning on line 801 in packages/api-v4/src/linodes/types.ts

View workflow job for this annotation

GitHub Actions / ESLint Review (api-v4)

[eslint] reported by reviewdog 🐢 The `{}` ("empty object") type allows any non-nullish value, including literals like `0` and `""`. - If that's what you want, disable this lint rule with an inline comment or configure the 'allowObjectTypes' rule option. - If you want a type meaning "any object", you probably want `object` instead. - If you want a type meaning "any value", you probably want `unknown` instead. Raw Output: {"ruleId":"@typescript-eslint/no-empty-object-type","severity":1,"message":"The `{}` (\"empty object\") type allows any non-nullish value, including literals like `0` and `\"\"`.
stackscript_id?: number;
}
Comment on lines +799 to +803
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

stackscript_data?: null | {} is a problematic type because {} in TypeScript means β€œany non-nullish value” rather than β€œan object with arbitrary keys”. This loses useful typing and can admit incorrect values. Consider using Record<string, unknown> / Record<string, any> (or reusing the same type used elsewhere for StackScript data) so consumers get accurate type-checking.

Copilot uses AI. Check for mistakes.

export interface LinodeDiskCreationData {
authorized_keys?: string[];
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/dev-tools/FeatureFlagTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const options: { flag: keyof Flags; label: string }[] = [
{ flag: 'objMultiCluster', label: 'OBJ Multi-Cluster' },
{ flag: 'objectStorageGen2', label: 'OBJ Gen2' },
{ flag: 'objectStorageGlobalQuotas', label: 'OBJ Global Quotas' },
{ flag: 'passwordlessLinodes', label: 'PasswordLess Linodes' },
{
flag: 'placementGroupPolicyUpdate',
label: 'Placement Group Policy Update',
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export interface Flags {
objectStorageGlobalQuotas: boolean;
objMultiCluster: boolean;
objSummaryPage: boolean;
passwordlessLinodes: boolean;
placementGroupPolicyUpdate: boolean;
privateImageSharing: boolean;
productInformationBanners: ProductInformationBannerFlag[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Notice, Typography } from '@linode/ui';
import React from 'react';
import { Controller, useFormContext } from 'react-hook-form';

import { Skeleton } from 'src/components/Skeleton';
import { usePermissions } from 'src/features/IAM/hooks/usePermissions';
import { useIsPasswordLessLinodesEnabled } from 'src/utilities/linodes';

import type { CreateLinodeRequest } from '@linode/api-v4';

const PasswordInput = React.lazy(() =>
import('src/components/PasswordInput/PasswordInput').then((module) => ({
default: module.PasswordInput,
}))
);

export const Password = () => {
const { control, formState } = useFormContext<CreateLinodeRequest>();
const { data: permissions } = usePermissions('account', ['create_linode']);
const { isPasswordLessLinodesEnabled } = useIsPasswordLessLinodesEnabled();

return (
<>
{isPasswordLessLinodesEnabled && (
<>
<Typography mb={2} variant="h2">
Authentication Method
</Typography>
{formState.errors.root_pass?.message && (
<Notice text={formState.errors.root_pass.message} variant="error" />
)}
</>
)}
<React.Suspense
fallback={
<Skeleton
sx={(theme) => ({ height: '89px', maxWidth: theme.inputMaxWidth })}
/>
}
>
<Controller
control={control}
name="root_pass"
render={({ field, fieldState }) => (
<PasswordInput
autoComplete="off"
disabled={!permissions.create_linode}
errorText={
!isPasswordLessLinodesEnabled
? fieldState.error?.message
: undefined
}
id="linode-password"
label="Root Password"
name="password"
noMarginTop
onBlur={field.onBlur}
onChange={field.onChange}
placeholder="Enter a password."
value={field.value ?? ''}
/>
)}
/>
</React.Suspense>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { Controller, useFormContext } from 'react-hook-form';

import { UserSSHKeyPanel } from 'src/components/AccessPanel/UserSSHKeyPanel';
import { usePermissions } from 'src/features/IAM/hooks/usePermissions';

import type { CreateLinodeRequest } from '@linode/api-v4';

export const SSHKeys = () => {
const { control } = useFormContext<CreateLinodeRequest>();
const { data: permissions } = usePermissions('account', ['create_linode']);

return (
<Controller
control={control}
name="authorized_users"
render={({ field }) => (
<UserSSHKeyPanel
authorizedUsers={field.value ?? []}
disabled={!permissions.create_linode}
setAuthorizedUsers={field.onChange}
/>
)}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {

import { Security } from './Security';

import type { LinodeCreateFormValues } from './utilities';
import type { LinodeCreateFormValues } from '../utilities';

const queryMocks = vi.hoisted(() => ({
useNavigate: vi.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Divider, Paper, Typography } from '@linode/ui';
import React from 'react';
import { Controller, useFormContext, useWatch } from 'react-hook-form';

import { UserSSHKeyPanel } from 'src/components/AccessPanel/UserSSHKeyPanel';
import {
DISK_ENCRYPTION_DEFAULT_DISTRIBUTED_INSTANCES,
DISK_ENCRYPTION_DISTRIBUTED_DESCRIPTION,
Expand All @@ -13,16 +12,12 @@ import {
import { Encryption } from 'src/components/Encryption/Encryption';
import { useIsDiskEncryptionFeatureEnabled } from 'src/components/Encryption/utils';
import { getIsDistributedRegion } from 'src/components/RegionSelect/RegionSelect.utils';
import { Skeleton } from 'src/components/Skeleton';
import { usePermissions } from 'src/features/IAM/hooks/usePermissions';
import { useIsPasswordLessLinodesEnabled } from 'src/utilities/linodes';

import type { CreateLinodeRequest } from '@linode/api-v4';
import { Password } from './Password';
import { SSHKeys } from './SSHKeys';

const PasswordInput = React.lazy(() =>
import('src/components/PasswordInput/PasswordInput').then((module) => ({
default: module.PasswordInput,
}))
);
import type { CreateLinodeRequest } from '@linode/api-v4';

export const Security = () => {
const { control } = useFormContext<CreateLinodeRequest>();
Expand All @@ -45,52 +40,26 @@ export const Security = () => {
selectedRegion?.id ?? ''
);

const { data: permissions } = usePermissions('account', ['create_linode']);
const { isPasswordLessLinodesEnabled } = useIsPasswordLessLinodesEnabled();

return (
<Paper>
<Typography sx={{ mb: 2 }} variant="h2">
Security
</Typography>
<React.Suspense
fallback={
<Skeleton
sx={(theme) => ({ height: '89px', maxWidth: theme.inputMaxWidth })}
/>
}
>
<Controller
control={control}
name="root_pass"
render={({ field, fieldState }) => (
<PasswordInput
autoComplete="off"
disabled={!permissions.create_linode}
errorText={fieldState.error?.message}
id="linode-password"
label="Root Password"
name="password"
noMarginTop
onBlur={field.onBlur}
onChange={field.onChange}
placeholder="Enter a password."
value={field.value ?? ''}
/>
)}
/>
</React.Suspense>
<Divider spacingBottom={20} spacingTop={24} />
<Controller
control={control}
name="authorized_users"
render={({ field }) => (
<UserSSHKeyPanel
authorizedUsers={field.value ?? []}
disabled={!permissions.create_linode}
setAuthorizedUsers={field.onChange}
/>
)}
/>
{!isPasswordLessLinodesEnabled ? (
<>
<Password />
<Divider spacingBottom={20} spacingTop={24} />
<SSHKeys />
</>
) : (
<>
<SSHKeys />
<Divider spacingBottom={20} spacingTop={24} />
<Password />
</>
)}
{isDiskEncryptionFeatureEnabled && (
<>
<Divider spacingBottom={20} spacingTop={24} />
Expand Down
11 changes: 9 additions & 2 deletions packages/manager/src/features/Linodes/LinodeCreate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
import {
useIsLinodeCloneFirewallEnabled,
useIsLinodeInterfacesEnabled,
useIsPasswordLessLinodesEnabled,
} from 'src/utilities/linodes';
import { sanitizeHTML } from 'src/utilities/sanitizeHTML';

Expand All @@ -60,7 +61,7 @@ import { Networking } from './Networking/Networking';
import { transformLegacyInterfaceErrorsToLinodeInterfaceErrors } from './Networking/utilities';
import { Plan } from './Plan';
import { getLinodeCreateResolver } from './resolvers';
import { Security } from './Security';
import { Security } from './Security/Security';
import { SMTP } from './SMTP';
import { Summary } from './Summary/Summary';
import { UserData } from './UserData/UserData';
Expand All @@ -86,6 +87,7 @@ export const LinodeCreate = () => {
});
const { secureVMNoticesEnabled } = useSecureVMNoticesEnabled();
const { isLinodeInterfacesEnabled } = useIsLinodeInterfacesEnabled();
const { isPasswordLessLinodesEnabled } = useIsPasswordLessLinodesEnabled();
const { data: profile } = useProfile();
const { isLinodeCloneFirewallEnabled } = useIsLinodeCloneFirewallEnabled();
const { isVMHostMaintenanceEnabled } = useVMHostMaintenanceEnabled();
Expand All @@ -103,7 +105,12 @@ export const LinodeCreate = () => {
const { isDualStackEnabled } = useVPCDualStack();

const form = useForm<LinodeCreateFormValues, LinodeCreateFormContext>({
context: { isLinodeInterfacesEnabled, profile, secureVMNoticesEnabled },
context: {
isPasswordLessLinodesEnabled,
isLinodeInterfacesEnabled,
profile,
secureVMNoticesEnabled,
},
defaultValues: () =>
defaultValues(linodeCreateType, search, queryClient, {
isLinodeInterfacesEnabled,
Expand Down
40 changes: 31 additions & 9 deletions packages/manager/src/features/Linodes/LinodeCreate/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
CreateLinodeFromMarketplaceAppSchema,
CreateLinodeFromStackScriptSchema,
CreateLinodeSchema,
withRootPassOptional,
withRootPassRequired,
} from './schemas';
import {
getDoesEmployeeNeedToAssignFirewall,
Expand All @@ -27,12 +29,15 @@ export const getLinodeCreateResolver = (
tab: LinodeCreateType | undefined,
queryClient: QueryClient
): Resolver<LinodeCreateFormValues, LinodeCreateFormContext> => {
const schema = linodeCreateResolvers[tab ?? 'OS'];
return async (rawValues, context, options) => {
const linodeCreateSchemas = linodeCreateResolvers(
context?.isPasswordLessLinodesEnabled ?? false
);
const schema = linodeCreateSchemas[tab ?? 'OS'];
const values = structuredClone(rawValues);

// Because `interfaces` are so complex, we need to perform some transformations before
// we even try to valiate them with our vaidation schema.
// we even try to validate them with our vaidation schema.
if (context?.isLinodeInterfacesEnabled) {
values.interfaces = [];
values.linodeInterfaces = values.linodeInterfaces.map(
Expand Down Expand Up @@ -136,11 +141,28 @@ export const getLinodeCreateResolver = (
};
};

export const linodeCreateResolvers = {
Backups: CreateLinodeFromBackupSchema,
'Clone Linode': CreateLinodeSchema,
Images: CreateLinodeSchema,
OS: CreateLinodeSchema,
'One-Click': CreateLinodeFromMarketplaceAppSchema,
StackScripts: CreateLinodeFromStackScriptSchema,
// This function returns the appropriate validation schema based on whether or not passwordLess Linodes are enabled. If passwordLess Linodes are enabled, then the root_pass field is optional. If passwordLess Linodes are not enabled, then the root_pass field is required.
// Creating Linodes from Backups and Cloning Linodes do not require a root password, so they are unaffected by the passwordLess Linodes feature and their schemas remain the same regardless of whether or not passwordLess Linodes are enabled.
export const linodeCreateResolvers = (
isPasswordLessLinodesEnabled: boolean
) => {
if (!isPasswordLessLinodesEnabled) {
return {
Backups: CreateLinodeFromBackupSchema,
'Clone Linode': CreateLinodeSchema,
Images: withRootPassRequired(CreateLinodeSchema),
OS: withRootPassRequired(CreateLinodeSchema),
'One-Click': withRootPassRequired(CreateLinodeFromMarketplaceAppSchema),
StackScripts: withRootPassRequired(CreateLinodeFromStackScriptSchema),
};
}

return {
Backups: CreateLinodeFromBackupSchema,
'Clone Linode': CreateLinodeSchema,
Images: withRootPassOptional(CreateLinodeSchema),
OS: withRootPassOptional(CreateLinodeSchema),
'One-Click': withRootPassOptional(CreateLinodeFromMarketplaceAppSchema),
StackScripts: withRootPassOptional(CreateLinodeFromStackScriptSchema),
};
};
Loading
Loading