1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(nomad): remove nomad from UI EE-6060 (#10509)

This commit is contained in:
matias-portainer 2023-10-31 15:27:20 -03:00 committed by GitHub
parent 1140804fe9
commit 8bb5129be0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
110 changed files with 39 additions and 1813 deletions

View file

@ -13,7 +13,6 @@ const edgePropertiesFormInitialValues: ScriptFormValues = {
envVars: '',
os: 'linux' as OS,
platform: 'k8s' as Platform,
nomadToken: '',
authEnabled: true,
tlsEnabled: false,
edgeGroupsIds: [],
@ -25,7 +24,6 @@ const edgePropertiesFormInitialValues: ScriptFormValues = {
interface Props {
edgeInfo: EdgeInfo;
commands: CommandTab[] | Partial<Record<OS, CommandTab[]>>;
isNomadTokenVisible?: boolean;
asyncMode?: boolean;
showMetaFields?: boolean;
}
@ -33,7 +31,6 @@ interface Props {
export function EdgeScriptForm({
edgeInfo,
commands,
isNomadTokenVisible,
asyncMode,
showMetaFields,
children,
@ -44,7 +41,7 @@ export function EdgeScriptForm({
<div className="form-horizontal">
<Formik
initialValues={edgePropertiesFormInitialValues}
validationSchema={() => validationSchema(isNomadTokenVisible)}
validationSchema={() => validationSchema()}
onSubmit={() => {}}
validateOnMount
>
@ -53,9 +50,6 @@ export function EdgeScriptForm({
{children}
<EdgeScriptSettingsFieldset
isNomadTokenVisible={
isNomadTokenVisible && values.platform === 'nomad'
}
hideIdGetter={edgeInfo.id !== undefined}
showMetaFields={showMetaFields}
/>

View file

@ -1,8 +1,6 @@
import { object, boolean, string } from 'yup';
import { validation as nomadTokenValidation } from './NomadTokenField';
export function validationSchema(isNomadTokenVisible?: boolean) {
export function validationSchema() {
return object().shape({
allowSelfSignedCertificates: boolean(),
envVars: string(),
@ -13,17 +11,5 @@ export function validationSchema(isNomadTokenVisible?: boolean) {
'edge id generator cannot be empty',
(value) => !!(value && value.length)
),
...nomadValidation(isNomadTokenVisible),
});
}
function nomadValidation(isNomadTokenVisible?: boolean) {
if (!isNomadTokenVisible) {
return {};
}
return {
tlsEnabled: boolean().default(false),
...nomadTokenValidation(),
};
}

View file

@ -10,17 +10,14 @@ import { TagSelector } from '@@/TagSelector';
import { EdgeGroupsSelector } from '../../edge-stacks/components/EdgeGroupsSelector';
import { NomadTokenField } from './NomadTokenField';
import { ScriptFormValues } from './types';
interface Props {
isNomadTokenVisible?: boolean;
hideIdGetter?: boolean;
showMetaFields?: boolean;
}
export function EdgeScriptSettingsFieldset({
isNomadTokenVisible,
hideIdGetter,
showMetaFields,
}: Props) {
@ -75,23 +72,6 @@ export function EdgeScriptSettingsFieldset({
</>
)}
{isNomadTokenVisible && (
<>
<NomadTokenField />
<div className="form-group">
<div className="col-sm-12">
<SwitchField
label="TLS"
labelClass="col-sm-3 col-lg-2"
checked={values.tlsEnabled}
onChange={(checked) => setFieldValue('tlsEnabled', checked)}
/>
</div>
</div>
</>
)}
<FormControl
label="Environment variables"
tooltip="Comma separated list of environment variables that will be sourced from the host where the agent is deployed."

View file

@ -1,53 +0,0 @@
import { Field, useFormikContext } from 'formik';
import { string, boolean } from 'yup';
import { FormControl } from '@@/form-components/FormControl';
import { SwitchField } from '@@/form-components/SwitchField';
import { Input } from '@@/form-components/Input';
import { ScriptFormValues } from './types';
export function NomadTokenField() {
const { values, setFieldValue, errors } =
useFormikContext<ScriptFormValues>();
return (
<>
<div className="form-group">
<div className="col-sm-12">
<SwitchField
checked={values.authEnabled}
onChange={(value) => {
if (!value) {
setFieldValue('nomadToken', '');
}
setFieldValue('authEnabled', value);
}}
label="Nomad Authentication Enabled"
tooltip="Nomad authentication is only required if you have ACL enabled"
/>
</div>
</div>
{values.authEnabled && (
<FormControl
label="Nomad Token"
inputId="nomad-token-input"
errors={errors.nomadToken}
>
<Field name="nomadToken" as={Input} id="nomad-token-input" />
</FormControl>
)}
</>
);
}
export function validation() {
return {
nomadToken: string().when('authEnabled', {
is: true,
then: string().required('Token is required'),
}),
authEnabled: boolean(),
};
}

View file

@ -35,11 +35,6 @@ export const commandsTabs: Record<string, CommandTab> = {
label: 'Docker Standalone',
command: buildLinuxStandaloneCommand,
},
nomadLinux: {
id: 'nomad',
label: 'Nomad',
command: buildLinuxNomadCommand,
},
swarmWindows: {
id: 'swarm',
label: 'Docker Swarm',
@ -237,38 +232,6 @@ export function buildLinuxKubernetesCommand(
return `${idEnvVar}curl https://downloads.portainer.io/ee${agentShortVersion}/portainer-edge-agent-setup.sh | bash -s -- "${edgeIdVar}" "${edgeKey}" "${selfSigned}" "${agentSecret}" "${allEnvVars}"`;
}
export function buildLinuxNomadCommand(
agentVersion: string,
edgeKey: string,
properties: ScriptFormValues,
useAsyncMode: boolean,
edgeId?: string,
agentSecret?: string
) {
const {
allowSelfSignedCertificates,
edgeIdGenerator,
envVars,
nomadToken = '',
tlsEnabled,
} = properties;
const agentShortVersion = getAgentShortVersion(agentVersion);
const allEnvVars = buildEnvVars(
envVars,
_.compact([useAsyncMode && 'EDGE_ASYNC=1', ...metaEnvVars(properties)])
);
const selfSigned = allowSelfSignedCertificates ? '1' : '0';
const idEnvVar = edgeIdGenerator
? `PORTAINER_EDGE_ID=$(${edgeIdGenerator}) \n\n`
: '';
const edgeIdVar = !edgeIdGenerator && edgeId ? edgeId : '$PORTAINER_EDGE_ID';
return `${idEnvVar}curl https://downloads.portainer.io/ee${agentShortVersion}/portainer-edge-agent-nomad-setup.sh | bash -s -- "${nomadToken}" "${edgeIdVar}" "${edgeKey}" "${selfSigned}" "${allEnvVars}" "${agentSecret}" "${tlsEnabled}"`;
}
function buildDockerEnvVars(envVars: string, moreVars: string[]) {
const vars = moreVars.concat(envVars.split(',').filter((s) => s.length > 0));

View file

@ -3,11 +3,10 @@ import { EnvironmentGroupId } from '@/react/portainer/environments/environment-g
import { EdgeGroup } from '../../edge-groups/types';
export type Platform = 'standalone' | 'swarm' | 'k8s' | 'nomad';
export type Platform = 'standalone' | 'swarm' | 'k8s';
export type OS = 'win' | 'linux';
export interface ScriptFormValues {
nomadToken: string;
authEnabled: boolean;
tlsEnabled: boolean;