mirror of https://github.com/portainer/portainer
refactor(edge): deprecate IsEdgeDevice [EE-5046] (#8534)
parent
814fc9dfc0
commit
308a78db21
|
@ -38,7 +38,6 @@ type endpointCreatePayload struct {
|
|||
AzureAuthenticationKey string
|
||||
TagIDs []portainer.TagID
|
||||
EdgeCheckinInterval int
|
||||
IsEdgeDevice bool
|
||||
}
|
||||
|
||||
type endpointCreationEnum int
|
||||
|
@ -381,7 +380,6 @@ func (handler *Handler) createEdgeAgentEndpoint(payload *endpointCreatePayload)
|
|||
EdgeKey: edgeKey,
|
||||
EdgeCheckinInterval: payload.EdgeCheckinInterval,
|
||||
Kubernetes: portainer.KubernetesDefault(),
|
||||
IsEdgeDevice: payload.IsEdgeDevice,
|
||||
UserTrusted: true,
|
||||
}
|
||||
|
||||
|
@ -435,7 +433,6 @@ func (handler *Handler) createUnsecuredEndpoint(payload *endpointCreatePayload)
|
|||
Status: portainer.EndpointStatusUp,
|
||||
Snapshots: []portainer.DockerSnapshot{},
|
||||
Kubernetes: portainer.KubernetesDefault(),
|
||||
IsEdgeDevice: payload.IsEdgeDevice,
|
||||
}
|
||||
|
||||
err := handler.snapshotAndPersistEndpoint(endpoint)
|
||||
|
@ -501,7 +498,6 @@ func (handler *Handler) createTLSSecuredEndpoint(payload *endpointCreatePayload,
|
|||
Status: portainer.EndpointStatusUp,
|
||||
Snapshots: []portainer.DockerSnapshot{},
|
||||
Kubernetes: portainer.KubernetesDefault(),
|
||||
IsEdgeDevice: payload.IsEdgeDevice,
|
||||
}
|
||||
|
||||
endpoint.Agent.Version = agentVersion
|
||||
|
|
|
@ -10,10 +10,9 @@ import (
|
|||
)
|
||||
|
||||
type systemInfoResponse struct {
|
||||
Platform plf.ContainerPlatform `json:"platform"`
|
||||
EdgeAgents int `json:"edgeAgents"`
|
||||
EdgeDevices int `json:"edgeDevices"`
|
||||
Agents int `json:"agents"`
|
||||
Platform plf.ContainerPlatform `json:"platform"`
|
||||
EdgeAgents int `json:"edgeAgents"`
|
||||
Agents int `json:"agents"`
|
||||
}
|
||||
|
||||
// @id systemInfo
|
||||
|
@ -34,7 +33,6 @@ func (handler *Handler) systemInfo(w http.ResponseWriter, r *http.Request) *http
|
|||
|
||||
agents := 0
|
||||
edgeAgents := 0
|
||||
edgeDevices := 0
|
||||
|
||||
for _, environment := range environments {
|
||||
if endpointutils.IsAgentEndpoint(&environment) {
|
||||
|
@ -45,9 +43,6 @@ func (handler *Handler) systemInfo(w http.ResponseWriter, r *http.Request) *http
|
|||
edgeAgents++
|
||||
}
|
||||
|
||||
if environment.IsEdgeDevice {
|
||||
edgeDevices++
|
||||
}
|
||||
}
|
||||
|
||||
platform, err := plf.DetermineContainerPlatform()
|
||||
|
@ -56,9 +51,8 @@ func (handler *Handler) systemInfo(w http.ResponseWriter, r *http.Request) *http
|
|||
}
|
||||
|
||||
return response.JSON(w, &systemInfoResponse{
|
||||
EdgeAgents: edgeAgents,
|
||||
EdgeDevices: edgeDevices,
|
||||
Agents: agents,
|
||||
Platform: platform,
|
||||
EdgeAgents: edgeAgents,
|
||||
Agents: agents,
|
||||
Platform: platform,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -388,8 +388,7 @@ type (
|
|||
LastCheckInDate int64
|
||||
// QueryDate of each query with the endpoints list
|
||||
QueryDate int64
|
||||
// IsEdgeDevice marks if the environment was created as an EdgeDevice
|
||||
IsEdgeDevice bool
|
||||
|
||||
// Whether the device has been trusted or not by the user
|
||||
UserTrusted bool
|
||||
|
||||
|
@ -417,6 +416,9 @@ type (
|
|||
|
||||
// Deprecated in DBVersion == 22
|
||||
Tags []string `json:"Tags"`
|
||||
|
||||
// Deprecated v2.18
|
||||
IsEdgeDevice bool
|
||||
}
|
||||
|
||||
EnvironmentEdgeSettings struct {
|
||||
|
|
|
@ -46,7 +46,7 @@ function config($stateRegistryProvider: StateRegistry) {
|
|||
|
||||
$stateRegistryProvider.register({
|
||||
name: 'portainer.wizard.endpoints',
|
||||
url: '/endpoints?edgeDevice',
|
||||
url: '/endpoints',
|
||||
views: {
|
||||
'content@': {
|
||||
component: 'wizardEnvironmentTypeSelectView',
|
||||
|
|
|
@ -90,8 +90,7 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
TLSCAFile,
|
||||
TLSCertFile,
|
||||
TLSKeyFile,
|
||||
checkinInterval,
|
||||
isEdgeDevice
|
||||
checkinInterval
|
||||
) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
|
@ -113,8 +112,7 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
TLSCAFile,
|
||||
TLSCertFile,
|
||||
TLSKeyFile,
|
||||
checkinInterval,
|
||||
isEdgeDevice
|
||||
checkinInterval
|
||||
)
|
||||
.then(function success(response) {
|
||||
deferred.resolve(response.data);
|
||||
|
|
|
@ -153,8 +153,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
TLSCAFile,
|
||||
TLSCertFile,
|
||||
TLSKeyFile,
|
||||
checkinInterval,
|
||||
isEdgeDevice
|
||||
checkinInterval
|
||||
) {
|
||||
return Upload.upload({
|
||||
url: 'api/endpoints',
|
||||
|
@ -172,7 +171,6 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
TLSCertFile: TLSCertFile,
|
||||
TLSKeyFile: TLSKeyFile,
|
||||
CheckinInterval: checkinInterval,
|
||||
IsEdgeDevice: isEdgeDevice,
|
||||
},
|
||||
ignoreLoadingBar: true,
|
||||
});
|
||||
|
|
|
@ -82,8 +82,7 @@ angular
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
null
|
||||
);
|
||||
} catch (err) {
|
||||
Notifications.error('Failure', err, 'Unable to create the environment');
|
||||
|
|
|
@ -32,11 +32,9 @@ export function EnvironmentTypeTag({
|
|||
|
||||
function getTypeLabel(environment: Environment) {
|
||||
if (isEdgeEnvironment(environment.Type)) {
|
||||
if (environment.Edge.AsyncMode) {
|
||||
return 'Edge Agent Async';
|
||||
}
|
||||
|
||||
return 'Edge Agent Standard';
|
||||
return environment.Edge.AsyncMode
|
||||
? 'Edge Agent Async'
|
||||
: 'Edge Agent Standard';
|
||||
}
|
||||
|
||||
if (isLocalEnvironment(environment)) {
|
||||
|
|
|
@ -108,7 +108,6 @@ export interface EnvironmentOptions {
|
|||
meta?: EnvironmentMetadata;
|
||||
azure?: AzureSettings;
|
||||
tls?: TLSSettings;
|
||||
isEdgeDevice?: boolean;
|
||||
pollFrequency?: number;
|
||||
edge?: EdgeSettings;
|
||||
tunnelServerAddr?: string;
|
||||
|
@ -167,7 +166,6 @@ interface CreateEdgeAgentEnvironment {
|
|||
tunnelServerAddr?: string;
|
||||
meta?: EnvironmentMetadata;
|
||||
pollFrequency: number;
|
||||
isEdgeDevice?: boolean;
|
||||
edge: EdgeSettings;
|
||||
}
|
||||
|
||||
|
@ -175,7 +173,6 @@ export function createEdgeAgentEnvironment({
|
|||
name,
|
||||
portainerUrl,
|
||||
meta = { tagIds: [] },
|
||||
isEdgeDevice,
|
||||
pollFrequency,
|
||||
edge,
|
||||
}: CreateEdgeAgentEnvironment) {
|
||||
|
@ -188,7 +185,6 @@ export function createEdgeAgentEnvironment({
|
|||
skipVerify: true,
|
||||
skipClientVerify: true,
|
||||
},
|
||||
isEdgeDevice,
|
||||
pollFrequency,
|
||||
edge,
|
||||
meta,
|
||||
|
@ -216,7 +212,6 @@ async function createEnvironment(
|
|||
GroupID: groupId,
|
||||
TagIds: arrayToJson(tagIds),
|
||||
CheckinInterval: options.pollFrequency,
|
||||
IsEdgeDevice: options.isEdgeDevice,
|
||||
};
|
||||
|
||||
const { tls, azure } = options;
|
||||
|
|
|
@ -152,7 +152,6 @@ export type Environment = {
|
|||
Kubernetes: KubernetesSettings;
|
||||
Nomad: NomadSettings;
|
||||
PublicURL?: string;
|
||||
IsEdgeDevice?: boolean;
|
||||
UserTrusted: boolean;
|
||||
AMTDeviceGUID?: string;
|
||||
Edge: EnvironmentEdge;
|
||||
|
|
|
@ -10,8 +10,6 @@ import { PageHeader } from '@@/PageHeader';
|
|||
import { Widget, WidgetBody, WidgetTitle } from '@@/Widget';
|
||||
import { FormSection } from '@@/form-components/FormSection';
|
||||
|
||||
import { useCreateEdgeDeviceParam } from '../hooks/useCreateEdgeDeviceParam';
|
||||
|
||||
import { EnvironmentSelector } from './EnvironmentSelector';
|
||||
import {
|
||||
EnvironmentOptionValue,
|
||||
|
@ -20,8 +18,6 @@ import {
|
|||
} from './environment-types';
|
||||
|
||||
export function EnvironmentTypeSelectView() {
|
||||
const createEdgeDevice = useCreateEdgeDeviceParam();
|
||||
|
||||
const [types, setTypes] = useState<EnvironmentOptionValue[]>([]);
|
||||
const { trackEvent } = useAnalytics();
|
||||
const router = useRouter();
|
||||
|
@ -50,14 +46,12 @@ export function EnvironmentTypeSelectView() {
|
|||
<EnvironmentSelector
|
||||
value={types}
|
||||
onChange={setTypes}
|
||||
createEdgeDevice={createEdgeDevice}
|
||||
options={existingEnvironmentTypes}
|
||||
/>
|
||||
<p className="control-label !mb-2">Set up new environments</p>
|
||||
<EnvironmentSelector
|
||||
value={types}
|
||||
onChange={setTypes}
|
||||
createEdgeDevice={createEdgeDevice}
|
||||
options={newEnvironmentTypes}
|
||||
hiddenSpacingCount={
|
||||
existingEnvironmentTypes.length -
|
||||
|
@ -102,7 +96,6 @@ export function EnvironmentTypeSelectView() {
|
|||
|
||||
router.stateService.go('portainer.wizard.endpoints.create', {
|
||||
envType: types,
|
||||
...(createEdgeDevice ? { edgeDevice: createEdgeDevice } : {}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,28 +6,18 @@ interface Props {
|
|||
value: EnvironmentOptionValue[];
|
||||
onChange(value: EnvironmentOptionValue[]): void;
|
||||
options: EnvironmentOption[];
|
||||
createEdgeDevice?: boolean;
|
||||
hiddenSpacingCount?: number;
|
||||
}
|
||||
|
||||
const hasEdge: EnvironmentOptionValue[] = [
|
||||
'dockerStandalone',
|
||||
'dockerSwarm',
|
||||
'kubernetes',
|
||||
];
|
||||
|
||||
export function EnvironmentSelector({
|
||||
value,
|
||||
onChange,
|
||||
createEdgeDevice,
|
||||
options,
|
||||
hiddenSpacingCount,
|
||||
}: Props) {
|
||||
const filteredOptions = filterEdgeDevicesIfNeed(options, createEdgeDevice);
|
||||
|
||||
return (
|
||||
<BoxSelector
|
||||
options={filteredOptions}
|
||||
options={options}
|
||||
isMulti
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
|
@ -36,14 +26,3 @@ export function EnvironmentSelector({
|
|||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function filterEdgeDevicesIfNeed(
|
||||
types: EnvironmentOption[],
|
||||
createEdgeDevice?: boolean
|
||||
) {
|
||||
if (!createEdgeDevice) {
|
||||
return [...types];
|
||||
}
|
||||
|
||||
return [...types.filter((eType) => hasEdge.includes(eType.id))];
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import { BadgeIcon } from '@@/BadgeIcon';
|
|||
|
||||
import { AnalyticsStateKey } from '../types';
|
||||
import { EdgeAgentTab } from '../shared/EdgeAgentTab';
|
||||
import { useFilterEdgeOptionsIfNeeded } from '../useOnlyEdgeOptions';
|
||||
|
||||
import { AgentTab } from './AgentTab';
|
||||
import { APITab } from './APITab';
|
||||
|
@ -24,7 +23,7 @@ interface Props {
|
|||
isDockerStandalone?: boolean;
|
||||
}
|
||||
|
||||
const defaultOptions: BoxSelectorOption<
|
||||
const options: BoxSelectorOption<
|
||||
'agent' | 'api' | 'socket' | 'edgeAgentStandard' | 'edgeAgentAsync'
|
||||
>[] = _.compact([
|
||||
{
|
||||
|
@ -65,11 +64,6 @@ const defaultOptions: BoxSelectorOption<
|
|||
]);
|
||||
|
||||
export function WizardDocker({ onCreate, isDockerStandalone }: Props) {
|
||||
const options = useFilterEdgeOptionsIfNeeded(
|
||||
defaultOptions,
|
||||
'edgeAgentStandard'
|
||||
);
|
||||
|
||||
const [creationType, setCreationType] = useState(options[0].value);
|
||||
|
||||
const tab = getTab(creationType);
|
||||
|
|
|
@ -15,7 +15,6 @@ import { BEFeatureIndicator } from '@@/BEFeatureIndicator';
|
|||
|
||||
import { AnalyticsStateKey } from '../types';
|
||||
import { EdgeAgentTab } from '../shared/EdgeAgentTab';
|
||||
import { useFilterEdgeOptionsIfNeeded } from '../useOnlyEdgeOptions';
|
||||
|
||||
import { AgentPanel } from './AgentPanel';
|
||||
import { KubeConfigTeaserForm } from './KubeConfigTeaserForm';
|
||||
|
@ -30,7 +29,7 @@ type CreationType =
|
|||
| 'edgeAgentAsync'
|
||||
| 'kubeconfig';
|
||||
|
||||
const defaultOptions: BoxSelectorOption<CreationType>[] = _.compact([
|
||||
const options: BoxSelectorOption<CreationType>[] = _.compact([
|
||||
{
|
||||
id: 'agent_endpoint',
|
||||
icon: Zap,
|
||||
|
@ -67,8 +66,6 @@ const defaultOptions: BoxSelectorOption<CreationType>[] = _.compact([
|
|||
]);
|
||||
|
||||
export function WizardKubernetes({ onCreate }: Props) {
|
||||
const options = useFilterEdgeOptionsIfNeeded(defaultOptions, 'agent');
|
||||
|
||||
const [creationType, setCreationType] = useState(options[0].value);
|
||||
|
||||
const tab = getTab(creationType);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import { EnvironmentCreationTypes } from '@/react/portainer/environments/types';
|
||||
|
||||
import { Value, BoxSelectorOption } from '@@/BoxSelector/types';
|
||||
|
||||
import { useCreateEdgeDeviceParam } from '../hooks/useCreateEdgeDeviceParam';
|
||||
|
||||
export function useFilterEdgeOptionsIfNeeded<
|
||||
T extends Value = EnvironmentCreationTypes
|
||||
>(options: BoxSelectorOption<T>[], edgeValue: T) {
|
||||
const createEdgeDevice = useCreateEdgeDeviceParam();
|
||||
|
||||
if (!createEdgeDevice) {
|
||||
return options;
|
||||
}
|
||||
|
||||
return options.filter((option) => option.value === edgeValue);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
import { useCurrentStateAndParams } from '@uirouter/react';
|
||||
|
||||
export function useCreateEdgeDeviceParam() {
|
||||
const {
|
||||
params: { edgeDevice: edgeDeviceParam },
|
||||
} = useCurrentStateAndParams();
|
||||
|
||||
const createEdgeDevice = edgeDeviceParam ? edgeDeviceParam === 'true' : false;
|
||||
|
||||
return createEdgeDevice;
|
||||
}
|
|
@ -19,7 +19,6 @@ export interface SystemInfoResponse {
|
|||
platform: ContainerPlatform;
|
||||
agents: number;
|
||||
edgeAgents: number;
|
||||
edgeDevices: number;
|
||||
}
|
||||
|
||||
async function getSystemInfo() {
|
||||
|
|
|
@ -54,7 +54,6 @@ function UpgradeBEBanner() {
|
|||
nodeCount: nodesCount,
|
||||
platform: systemInfo.platform,
|
||||
edgeAgents: systemInfo.edgeAgents,
|
||||
edgeDevices: systemInfo.edgeDevices,
|
||||
agents: systemInfo.agents,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue