github.com/crossplane/upjet@v1.3.0/pkg/migration/fake/objects.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Crossplane Authors <https://crossplane.io>
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  //go:generate go run github.com/golang/mock/mockgen -copyright_file ../../../hack/boilerplate.txt -destination=./mocks/mock.go -package mocks github.com/crossplane/crossplane-runtime/pkg/resource Managed
     6  
     7  package fake
     8  
     9  import (
    10  	xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
    11  	"k8s.io/apimachinery/pkg/runtime/schema"
    12  
    13  	"github.com/crossplane/upjet/pkg/migration/fake/mocks"
    14  )
    15  
    16  const (
    17  	MigrationSourceGroup   = "fakesourceapi"
    18  	MigrationSourceVersion = "v1alpha1"
    19  	MigrationSourceKind    = "VPC"
    20  
    21  	MigrationTargetGroup   = "faketargetapi"
    22  	MigrationTargetVersion = "v1alpha1"
    23  	MigrationTargetKind    = "VPC"
    24  )
    25  
    26  var (
    27  	MigrationSourceGVK = schema.GroupVersionKind{
    28  		Group:   MigrationSourceGroup,
    29  		Version: MigrationSourceVersion,
    30  		Kind:    MigrationSourceKind,
    31  	}
    32  
    33  	MigrationTargetGVK = schema.GroupVersionKind{
    34  		Group:   MigrationTargetGroup,
    35  		Version: MigrationTargetVersion,
    36  		Kind:    MigrationTargetKind,
    37  	}
    38  )
    39  
    40  type MigrationSourceObject struct {
    41  	mocks.MockManaged
    42  	// cannot inline v1.TypeMeta here as mocks.MockManaged is also inlined
    43  	APIVersion string `json:"apiVersion,omitempty"`
    44  	Kind       string `json:"kind,omitempty"`
    45  	// cannot inline v1.ObjectMeta here as mocks.MockManaged is also inlined
    46  	ObjectMeta ObjectMeta `json:"metadata,omitempty"`
    47  	Spec       SourceSpec `json:"spec"`
    48  	Status     Status     `json:"status,omitempty"`
    49  }
    50  
    51  type SourceSpec struct {
    52  	xpv1.ResourceSpec `json:",inline"`
    53  	ForProvider       SourceSpecParameters `json:"forProvider"`
    54  }
    55  
    56  type EmbeddedParameter struct {
    57  	Param *string `json:"param,omitempty"`
    58  }
    59  
    60  type SourceSpecParameters struct {
    61  	Region    *string            `json:"region,omitempty"`
    62  	CIDRBlock string             `json:"cidrBlock"`
    63  	Tags      []Tag              `json:"tags,omitempty"`
    64  	TestParam *EmbeddedParameter `json:",inline"`
    65  }
    66  
    67  type Tag struct {
    68  	Key   string `json:"key"`
    69  	Value string `json:"value"`
    70  }
    71  
    72  type Status struct {
    73  	xpv1.ResourceStatus `json:",inline"`
    74  	AtProvider          Observation `json:"atProvider,omitempty"`
    75  }
    76  
    77  type Observation struct{}
    78  
    79  func (m *MigrationSourceObject) GetName() string {
    80  	return m.ObjectMeta.Name
    81  }
    82  
    83  type MigrationTargetObject struct {
    84  	mocks.MockManaged
    85  	// cannot inline v1.TypeMeta here as mocks.MockManaged is also inlined
    86  	APIVersion string `json:"apiVersion,omitempty"`
    87  	Kind       string `json:"kind,omitempty"`
    88  	// cannot inline v1.ObjectMeta here as mocks.MockManaged is also inlined
    89  	ObjectMeta ObjectMeta `json:"metadata,omitempty"`
    90  	Spec       TargetSpec `json:"spec"`
    91  	Status     Status     `json:"status,omitempty"`
    92  }
    93  
    94  type ObjectMeta struct {
    95  	Name         string            `json:"name,omitempty"`
    96  	GenerateName string            `json:"generateName,omitempty"`
    97  	Labels       map[string]string `json:"labels,omitempty"`
    98  }
    99  
   100  type TargetSpec struct {
   101  	xpv1.ResourceSpec `json:",inline"`
   102  	ForProvider       TargetSpecParameters `json:"forProvider"`
   103  }
   104  
   105  type TargetSpecParameters struct {
   106  	Region    *string           `json:"region,omitempty"`
   107  	CIDRBlock string            `json:"cidrBlock"`
   108  	Tags      map[string]string `json:"tags,omitempty"`
   109  	TestParam EmbeddedParameter `json:",inline"`
   110  }
   111  
   112  type targetObjectKind struct{}
   113  
   114  func (t *targetObjectKind) SetGroupVersionKind(_ schema.GroupVersionKind) {}
   115  
   116  func (t *targetObjectKind) GroupVersionKind() schema.GroupVersionKind {
   117  	return MigrationTargetGVK
   118  }
   119  
   120  func (m *MigrationTargetObject) GetObjectKind() schema.ObjectKind {
   121  	return &targetObjectKind{}
   122  }
   123  
   124  func (m *MigrationTargetObject) GetName() string {
   125  	return m.ObjectMeta.Name
   126  }
   127  
   128  func (m *MigrationTargetObject) GetGenerateName() string {
   129  	return m.ObjectMeta.GenerateName
   130  }