
// This file was autogenerated by go-to-protobuf. Do not edit it manually!

syntax = 'proto2';

package github.com.open_cluster_management.api.work.v1;

import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";

// Package-wide variables from generator "generated".
option go_package = "v1";

// AppliedManifestResourceMeta represents the gvr, name and namespace of a resource.
// Since these resources have been created, they must have valid group, version, resource, namespace, and name.
message AppliedManifestResourceMeta {
  // Group is the API Group of the kubernetes resource
  // +required
  optional string group = 1;

  // Version is the version of the kubernetes resource
  // +required
  optional string version = 2;

  // Resource is the resource name of the kubernetes resource
  // +required
  optional string resource = 3;

  // Name is the name of the kubernetes resource
  // +required
  optional string name = 4;

  // Name is the namespace of the kubernetes resource, empty string indicates
  // it is a cluster scoped resource.
  // +required
  optional string namespace = 5;
}

// Manifest represents a resource to be deployed on managed cluster
message Manifest {
  // +kubebuilder:validation:EmbeddedResource
  // +kubebuilder:pruning:PreserveUnknownFields
  optional k8s.io.apimachinery.pkg.runtime.RawExtension rawExtension = 1;
}

// ManifestCondition represents the conditions of the resources deployed on
// managed cluster
message ManifestCondition {
  // ResourceMeta represents the gvk, name and namespace of a resoure
  // +required
  optional ManifestResourceMeta resourceMeta = 1;

  // Conditions represents the conditions of this resource on managed cluster
  // +required
  repeated StatusCondition conditions = 2;
}

// ManifestResourceMeta represents the gvk, gvr, name and namespace of a resoure
message ManifestResourceMeta {
  // Ordinal represents the index of the manifest on spec
  // +required
  optional int32 ordinal = 1;

  // Group is the API Group of the kubernetes resource
  // +optional
  optional string group = 2;

  // Version is the version of the kubernetes resource
  // +optional
  optional string version = 3;

  // Kind is the kind of the kubernetes resource
  // +optional
  optional string kind = 4;

  // Resource is the resource name of the kubernetes resource
  // +optional
  optional string resource = 5;

  // Name is the name of the kubernetes resource
  // +optional
  optional string name = 6;

  // Name is the namespace of the kubernetes resource
  // +optional
  optional string namespace = 7;
}

// ManifestResourceStatus represents the status of each resource in manifest work deployed on
// managed cluster
message ManifestResourceStatus {
  // Manifests represents the condition of manifests deployed on managed cluster.
  // Valid condition types are:
  // 1. Progressing represents the resource is being applied on managed cluster.
  // 2. Applied represents the resource is applied successfully on managed cluster.
  // 3. Available represents the resource exists on the managed cluster.
  // 4. Degraded represents the current state of resource does not match the desired
  // state for a certain period.
  repeated ManifestCondition manifests = 2;
}

// ManifestWork represents a manifests workload that hub wants to deploy on the managed cluster.
// A manifest workload is defined as a set of kubernetes resources.
// ManifestWork must be created in the cluster namespace on the hub, so that agent on the
// corresponding managed cluster can access this resource and deploy on the managed
// cluster.
message ManifestWork {
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  // Spec represents a desired configuration of work to be deployed on the managed cluster.
  optional ManifestWorkSpec spec = 2;

  // Status represents the current status of work
  // +optional
  optional ManifestWorkStatus status = 3;
}

// ManifestWorkList is a collection of manifestworks.
message ManifestWorkList {
  // Standard list metadata.
  // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
  // +optional
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;

  // Items is a list of manifestworks.
  repeated ManifestWork items = 2;
}

// ManifestWorkSpec represents a desired configuration of manifests to be deployed on the managed cluster.
message ManifestWorkSpec {
  // Workload represents the manifest workload to be deployed on managed cluster
  optional ManifestsTemplate workload = 1;
}

// ManifestWorkStatus represents the current status of managed cluster ManifestWork
message ManifestWorkStatus {
  // Conditions contains the different condition statuses for this work.
  // Valid condition types are:
  // 1. Applied represents workload in ManifestWork is applied successfully on managed cluster.
  // 2. Progressing represents workload in ManifestWork is being applied on managed cluster.
  // 3. Available represents workload in ManifestWork exists on the managed cluster.
  // 4. Degraded represents the current state of workload does not match the desired
  // state for a certain period.
  repeated StatusCondition conditions = 1;

  // ResourceStatus represents the status of each resource in manifestwork deployed on
  // managed cluster. The Klusterlet agent on managed cluster syncs the condition from managed to the hub.
  // +optional
  optional ManifestResourceStatus resourceStatus = 2;

  // AppliedResources represents a list of resources defined within the manifestwork that are applied.
  // Only resources with valid GroupVersionResource, namespace, and name are suitable.
  // An item in this slice is deleted when there is no mapped manifest in manifestwork.Spec or by finalizer.
  // The resource relating to the item will also be removed from managed cluster.
  // The deleted resource may still be present until the finalizers for that resource are finished.
  // However, the resource will not be undeleted, so it can be removed from this list and eventual consistency is preserved.
  // +optional
  repeated AppliedManifestResourceMeta appliedResources = 3;
}

// ManifestsTemplate represents the manifest workload to be deployed on managed cluster
message ManifestsTemplate {
  // Manifests represents a list of kuberenetes resources to be deployed on the managed cluster.
  // +optional
  repeated Manifest manifests = 1;
}

// StatusCondition contains condition information for a ManifestWork applied to a managed cluster.
message StatusCondition {
  // Type is the type of the ManifestWork condition.
  // +required
  optional string type = 1;

  // Status is the status of the condition. One of True, False, Unknown.
  // +required
  optional string status = 2;

  // LastTransitionTime is the last time the condition changed from one status to another.
  // +required
  optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 3;

  // Reason is a (brief) reason for the condition's last status change.
  // +required
  optional string reason = 4;

  // Message is a human-readable message indicating details about the last status change.
  // +required
  optional string message = 5;
}

