|
| 1 | +/********************************************************************** |
| 2 | + * Copyright (C) 2024 Red Hat, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: Apache-2.0 |
| 17 | + ***********************************************************************/ |
| 18 | + |
| 19 | +export const NO_CURRENT_CONTEXT_ERROR = 'no current context'; |
| 20 | + |
| 21 | +// CheckingState indicates the state of the check for a context |
| 22 | +export interface CheckingState { |
| 23 | + state: 'waiting' | 'checking' | 'gaveup'; |
| 24 | +} |
| 25 | + |
| 26 | +// A selection of resources, to indicate the 'general' status of a context |
| 27 | +type selectedResources = ['pods', 'deployments']; |
| 28 | + |
| 29 | +// resources managed by podman desktop, excepted the primary ones |
| 30 | +// This is where to add new resources when adding new informers |
| 31 | +export const secondaryResources = [ |
| 32 | + 'services', |
| 33 | + 'ingresses', |
| 34 | + 'routes', |
| 35 | + 'configmaps', |
| 36 | + 'secrets', |
| 37 | + 'nodes', |
| 38 | + 'persistentvolumeclaims', |
| 39 | + 'events', |
| 40 | + 'cronjobs', |
| 41 | + 'jobs', |
| 42 | +] as const; |
| 43 | + |
| 44 | +export type SecondaryResourceName = (typeof secondaryResources)[number]; |
| 45 | +export type ResourceName = SelectedResourceName | SecondaryResourceName; |
| 46 | + |
| 47 | +export type SelectedResourceName = selectedResources[number]; |
| 48 | + |
| 49 | +export type SelectedResourcesCount = { |
| 50 | + [resourceName in SelectedResourceName]: number; |
| 51 | +}; |
| 52 | + |
| 53 | +// information sent: status and count of selected resources |
| 54 | +export interface ContextGeneralState { |
| 55 | + checking?: CheckingState; |
| 56 | + error?: string; |
| 57 | + reachable: boolean; |
| 58 | + resources: SelectedResourcesCount; |
| 59 | +} |
0 commit comments