fix: replace hardcoded paths for firstboot

This commit is contained in:
Anna Vítová 2025-06-18 12:45:28 +02:00 committed by Klara Simickova
parent 9189a20e57
commit 47d526cf5c
3 changed files with 14 additions and 10 deletions

View file

@ -12,6 +12,10 @@ import {
RHEL_9_BETA,
RHEL_10,
RHEL_10_BETA,
FIRSTBOOT_PATH,
FIRSTBOOT_SERVICE_PATH,
SATELLITE_SERVICE_PATH,
SATELLITE_PATH,
} from '../../../constants';
import { RootState } from '../../../store';
import {
@ -448,9 +452,7 @@ export const mapExportRequestToState = (
};
const getFirstBootScript = (files?: File[]): string => {
const firstBootFile = files?.find(
(file) => file.path === '/usr/local/sbin/custom-first-boot'
);
const firstBootFile = files?.find((file) => file.path === FIRSTBOOT_PATH);
return firstBootFile?.data ? atob(firstBootFile.data) : '';
};
@ -564,13 +566,13 @@ const getCustomizations = (state: RootState, orgID: string): Customizations => {
const files: File[] = [];
if (selectFirstBootScript(state)) {
files.push({
path: '/etc/systemd/system/custom-first-boot.service',
path: FIRSTBOOT_SERVICE_PATH,
data: FIRST_BOOT_SERVICE_DATA,
data_encoding: 'base64',
ensure_parents: true,
});
files.push({
path: '/usr/local/sbin/custom-first-boot',
path: FIRSTBOOT_PATH,
data: btoa(selectFirstBootScript(state)),
data_encoding: 'base64',
mode: '0774',
@ -580,13 +582,13 @@ const getCustomizations = (state: RootState, orgID: string): Customizations => {
const satCmd = selectSatelliteRegistrationCommand(state);
if (satCmd && selectRegistrationType(state) === 'register-satellite') {
files.push({
path: '/etc/systemd/system/register-satellite.service',
path: SATELLITE_SERVICE_PATH,
data: SATELLITE_SERVICE_DATA,
data_encoding: 'base64',
ensure_parents: true,
});
files.push({
path: '/usr/local/sbin/register-satellite',
path: SATELLITE_PATH,
data: btoa(satCmd),
mode: '0774',
data_encoding: 'base64',

View file

@ -1,6 +1,7 @@
import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { FIRSTBOOT_PATH } from '../../../constants';
import { renderCustomRoutesWithReduxRouter } from '../../testUtils';
import { clickNext } from '../CreateImageWizard/wizardTestUtils';
@ -169,7 +170,7 @@ data = "IyEvYmluL2Jhc2gKZmlyc3Rib290IHNjcmlwdCB0byB0ZXN0IGltcG9ydA=="
data_encoding = "base64"
ensure_parents = true
mode = "0774"
path = "/usr/local/sbin/custom-first-boot"
path = "${FIRSTBOOT_PATH}"
[[customizations.filesystem]]
mountpoint = "/var"
@ -241,7 +242,7 @@ data = "IyEvYmluL2Jhc2gKZmlyc3Rib290IHNjcmlwdCB0byB0ZXN0IGltcG9ydA=="
data_encoding = "base64"
ensure_parents = true
mode = "0774"
path = "/usr/local/sbin/custom-first-boot"
path = "${FIRSTBOOT_PATH}"
[[customizations.filesystem]]
mountpoint = "/var"

View file

@ -11,6 +11,7 @@ import {
CENTOS_9,
FIRST_BOOT_SERVICE,
FIRST_BOOT_SERVICE_DATA,
FIRSTBOOT_PATH,
RHEL_8,
RHEL_9,
UNIT_GIB,
@ -130,7 +131,7 @@ export const firstBootData: File[] = [
ensure_parents: true,
},
{
path: '/usr/local/sbin/custom-first-boot',
path: FIRSTBOOT_PATH,
data: BASE64_SCRIPT,
data_encoding: 'base64',
mode: '0774',