github.com/openebs/api@v1.12.0/pkg/apis/openebs.io/v1alpha1/cstorrestore.go (about)

     1  /*
     2  Copyright 2020 The OpenEBS Authors.
     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  
    17  package v1alpha1
    18  
    19  import (
    20  	"k8s.io/apimachinery/pkg/api/resource"
    21  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    22  )
    23  
    24  // +genclient
    25  // +genclient:noStatus
    26  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    27  // +resource:path=cstorrestore
    28  
    29  // CStorRestore describes a cstor restore resource created as a custom resource
    30  type CStorRestore struct {
    31  	metav1.TypeMeta   `json:",inline"`
    32  	metav1.ObjectMeta `json:"metadata,omitempty"` // set name to restore name + volume name + something like csp tag
    33  	Spec              CStorRestoreSpec            `json:"spec"`
    34  	Status            CStorRestoreStatus          `json:"status"`
    35  }
    36  
    37  // CStorRestoreSpec is the spec for a CStorRestore resource
    38  type CStorRestoreSpec struct {
    39  	RestoreName   string            `json:"restoreName"` // set restore name
    40  	VolumeName    string            `json:"volumeName"`
    41  	RestoreSrc    string            `json:"restoreSrc"` // it can be ip:port in case of restore from remote or volumeName in case of local restore
    42  	MaxRetryCount int               `json:"maxretrycount"`
    43  	RetryCount    int               `json:"retrycount"`
    44  	StorageClass  string            `json:"storageClass,omitempty"`
    45  	Size          resource.Quantity `json:"size,omitempty"`
    46  	Local         bool              `json:"localRestore,omitempty"` // if restore is from local backup/snapshot
    47  }
    48  
    49  // CStorRestoreStatus is to hold result of action.
    50  type CStorRestoreStatus string
    51  
    52  // Status written onto CStrorRestore object.
    53  const (
    54  	// RSTCStorStatusEmpty ensures the create operation is to be done, if import fails.
    55  	RSTCStorStatusEmpty CStorRestoreStatus = ""
    56  
    57  	// RSTCStorStatusDone , restore operation is completed.
    58  	RSTCStorStatusDone CStorRestoreStatus = "Done"
    59  
    60  	// RSTCStorStatusFailed , restore operation is failed.
    61  	RSTCStorStatusFailed CStorRestoreStatus = "Failed"
    62  
    63  	// RSTCStorStatusInit , restore operation is initialized.
    64  	RSTCStorStatusInit CStorRestoreStatus = "Init"
    65  
    66  	// RSTCStorStatusPending , restore operation is pending.
    67  	RSTCStorStatusPending CStorRestoreStatus = "Pending"
    68  
    69  	// RSTCStorStatusInProgress , restore operation is in progress.
    70  	RSTCStorStatusInProgress CStorRestoreStatus = "InProgress"
    71  
    72  	// RSTCStorStatusInvalid , restore operation is invalid.
    73  	RSTCStorStatusInvalid CStorRestoreStatus = "Invalid"
    74  )
    75  
    76  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    77  // +resource:path=cstorrestore
    78  
    79  // CStorRestoreList is a list of CStorRestore resources
    80  type CStorRestoreList struct {
    81  	metav1.TypeMeta `json:",inline"`
    82  	metav1.ListMeta `json:"metadata"`
    83  
    84  	Items []CStorRestore `json:"items"`
    85  }