@soft-stech/fleet
Version:
287 lines (286 loc) • 11.4 kB
JavaScript
import { z } from "zod";
import { iObjectMetaSchema } from "@soft-stech/apimachinery/apis/meta/v1/ObjectMeta.schema";
/**
* ClusterGroup is a re-usable selector to target a group of clusters.
*/
export const IClusterGroupSchema = z.object({
/**
* APIVersion defines the versioned schema of this representation of an object.
* Servers should convert recognized schemas to the latest internal value, and
* may reject unrecognized values.
* More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
*/
apiVersion: z.literal("fleet.cattle.io/v1alpha1"),
/**
* Kind is a string value representing the REST resource this object represents.
* Servers may infer this from the endpoint the client submits requests to.
* Cannot be updated.
* In CamelCase.
* More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
*/
kind: z.literal("ClusterGroup"),
metadata: iObjectMetaSchema.optional(),
spec: z
.object({
/**
* Selector is a label selector, used to select clusters for this group.
*/
selector: z
.object({
/**
* matchExpressions is a list of label selector requirements. The requirements are ANDed.
*/
matchExpressions: z
.array(z.object({
/**
* key is the label key that the selector applies to.
*/
key: z.string(),
/**
* operator represents a key's relationship to a set of values.
* Valid operators are In, NotIn, Exists and DoesNotExist.
*/
operator: z.string(),
/**
* values is an array of string values. If the operator is In or NotIn,
* the values array must be non-empty. If the operator is Exists or DoesNotExist,
* the values array must be empty. This array is replaced during a strategic
* merge patch.
*/
values: z.array(z.string()).optional()
}))
.optional(),
/**
* matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
* map is equivalent to an element of matchExpressions, whose key field is "key", the
* operator is "In", and the values array contains only "value". The requirements are ANDed.
*/
matchLabels: z.record(z.string(), z.string()).optional()
})
.optional()
})
.optional(),
status: z
.object({
/**
* ClusterCount is the number of clusters in the cluster group.
*/
clusterCount: z.number().optional(),
/**
* Conditions is a list of conditions and their statuses for the cluster group.
*/
conditions: z
.array(z.object({
/**
* Last time the condition transitioned from one status to another.
*/
lastTransitionTime: z.string().optional(),
/**
* The last time this condition was updated.
*/
lastUpdateTime: z.string().optional(),
/**
* Human-readable message indicating details about last transition
*/
message: z.string().optional(),
/**
* The reason for the condition's last transition.
*/
reason: z.string().optional(),
/**
* Status of the condition, one of True, False, Unknown.
*/
status: z.string(),
/**
* Type of cluster condition.
*/
type: z.string()
}))
.optional(),
/**
* Display contains the number of ready, desiredready clusters and a
* summary state for the bundle's resources.
*/
display: z
.object({
/**
* ReadyBundles is a string in the form "%d/%d", that describes the
* number of bundles that are ready vs. the number of bundles desired
* to be ready.
*/
readyBundles: z.string().optional(),
/**
* ReadyClusters is a string in the form "%d/%d", that describes the
* number of clusters that are ready vs. the number of clusters desired
* to be ready.
*/
readyClusters: z.string().optional(),
/**
* State is a summary state for the cluster group, showing "NotReady" if
* there are non-ready resources.
*/
state: z.string().optional()
})
.optional(),
/**
* NonReadyClusterCount is the number of clusters that are not ready.
*/
nonReadyClusterCount: z.number().optional(),
/**
* NonReadyClusters is a list of cluster names that are not ready.
*/
nonReadyClusters: z.array(z.string()).optional(),
/**
* ResourceCounts contains the number of resources in each state over
* all bundles in the cluster group.
*/
resourceCounts: z
.object({
/**
* DesiredReady is the number of resources that should be ready.
*/
desiredReady: z.number().optional(),
/**
* Missing is the number of missing resources.
*/
missing: z.number().optional(),
/**
* Modified is the number of resources that have been modified.
*/
modified: z.number().optional(),
/**
* NotReady is the number of not ready resources. Resources are not
* ready if they do not match any other state.
*/
notReady: z.number().optional(),
/**
* Orphaned is the number of orphaned resources.
*/
orphaned: z.number().optional(),
/**
* Ready is the number of ready resources.
*/
ready: z.number().optional(),
/**
* Unknown is the number of resources in an unknown state.
*/
unknown: z.number().optional(),
/**
* WaitApplied is the number of resources that are waiting to be applied.
*/
waitApplied: z.number().optional()
})
.optional(),
/**
* Summary is a summary of the bundle deployments and their resources
* in the cluster group.
*/
summary: z
.object({
/**
* DesiredReady is the number of bundle deployments that should be
* ready.
*/
desiredReady: z.number().optional(),
/**
* ErrApplied is the number of bundle deployments that have been synced
* from the Fleet controller and the downstream cluster, but with some
* errors when deploying the bundle.
*/
errApplied: z.number().optional(),
/**
* Modified is the number of bundle deployments that have been deployed
* and for which all resources are ready, but where some changes from the
* Git repository have not yet been synced.
*/
modified: z.number().optional(),
/**
* NonReadyClusters is a list of states, which is filled for a bundle
* that is not ready.
*/
nonReadyResources: z
.array(z.object({
/**
* State is the state of the resource, like e.g. "NotReady" or "ErrApplied".
*/
bundleState: z.string().optional(),
/**
* Message contains information why the bundle is not ready.
*/
message: z.string().optional(),
/**
* ModifiedStatus lists the state for each modified resource.
*/
modifiedStatus: z
.array(z.object({
apiVersion: z.string().optional(),
delete: z.boolean().optional(),
kind: z.string().optional(),
missing: z.boolean().optional(),
name: z.string().optional(),
namespace: z.string().optional(),
patch: z.string().optional()
}))
.optional(),
/**
* Name is the name of the resource.
*/
name: z.string().optional(),
/**
* NonReadyStatus lists the state for each non-ready resource.
*/
nonReadyStatus: z
.array(z.object({
apiVersion: z.string().optional(),
kind: z.string().optional(),
name: z.string().optional(),
namespace: z.string().optional(),
summary: z
.object({
error: z.boolean().optional(),
message: z.array(z.string()).optional(),
state: z.string().optional(),
transitioning: z.boolean().optional()
})
.optional(),
/**
* UID is a type that holds unique ID values, including UUIDs. Because we
* don't ONLY use UUIDs, this is an alias to string. Being a type captures
* intent and helps make sure that UIDs and names do not get conflated.
*/
uid: z.string().optional()
}))
.optional()
}))
.optional(),
/**
* NotReady is the number of bundle deployments that have been deployed
* where some resources are not ready.
*/
notReady: z.number().optional(),
/**
* OutOfSync is the number of bundle deployments that have been synced
* from Fleet controller, but not yet by the downstream agent.
*/
outOfSync: z.number().optional(),
/**
* Pending is the number of bundle deployments that are being processed
* by Fleet controller.
*/
pending: z.number().optional(),
/**
* Ready is the number of bundle deployments that have been deployed
* where all resources are ready.
*/
ready: z.number().optional(),
/**
* WaitApplied is the number of bundle deployments that have been
* synced from Fleet controller and downstream cluster, but are waiting
* to be deployed.
*/
waitApplied: z.number().optional()
})
.optional()
})
.optional()
});