open-cluster-management.io/governance-policy-propagator@v0.13.0/api/v1beta1/policyset_types.go (about)

     1  // Copyright (c) 2021 Red Hat, Inc.
     2  // Copyright Contributors to the Open Cluster Management project
     3  
     4  package v1beta1
     5  
     6  import (
     7  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     8  )
     9  
    10  // A custom type is required since there is no way to have a kubebuilder marker
    11  // apply to the items of a slice.
    12  
    13  // +kubebuilder:validation:MinLength=1
    14  type NonEmptyString string
    15  
    16  // PolicySetSpec describes a group of policies that are related and
    17  // can be placed on the same managed clusters.
    18  type PolicySetSpec struct {
    19  	// Description of this PolicySet.
    20  	Description string `json:"description,omitempty"`
    21  	// Policies that are grouped together within the PolicySet.
    22  	// +kubebuilder:validation:Required
    23  	Policies []NonEmptyString `json:"policies"`
    24  }
    25  
    26  // PolicySetStatus defines the observed state of PolicySet
    27  type PolicySetStatus struct {
    28  	Placement     []PolicySetStatusPlacement `json:"placement,omitempty"`
    29  	Compliant     string                     `json:"compliant,omitempty"`
    30  	StatusMessage string                     `json:"statusMessage,omitempty"`
    31  }
    32  
    33  // PolicySetStatusPlacement defines a placement object for the status
    34  type PolicySetStatusPlacement struct {
    35  	PlacementBinding string `json:"placementBinding,omitempty"`
    36  	Placement        string `json:"placement,omitempty"`
    37  	PlacementRule    string `json:"placementRule,omitempty"`
    38  }
    39  
    40  // +kubebuilder:object:root=true
    41  // +kubebuilder:subresource:status
    42  // +kubebuilder:resource:path=policysets,scope=Namespaced
    43  // +kubebuilder:resource:path=policysets,shortName=plcset
    44  // +kubebuilder:printcolumn:name="Compliance state",type="string",JSONPath=".status.compliant"
    45  // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
    46  // PolicySet is the Schema for the policysets API
    47  type PolicySet struct {
    48  	metav1.TypeMeta   `json:",inline"`
    49  	metav1.ObjectMeta `json:"metadata,omitempty"`
    50  	// +kubebuilder:validation:Required
    51  	Spec   PolicySetSpec   `json:"spec"`
    52  	Status PolicySetStatus `json:"status,omitempty"`
    53  }
    54  
    55  //+kubebuilder:object:root=true
    56  
    57  // PolicySetList contains a list of PolicySet
    58  type PolicySetList struct {
    59  	metav1.TypeMeta `json:",inline"`
    60  	metav1.ListMeta `json:"metadata,omitempty"`
    61  	Items           []PolicySet `json:"items"`
    62  }
    63  
    64  func init() {
    65  	SchemeBuilder.Register(&PolicySet{}, &PolicySetList{})
    66  }