// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
// SPDX-License-Identifier: Apache-2.0

package fixtures

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"

	greenhousemetav1alpha1 "github.com/cloudoperators/greenhouse/api/meta/v1alpha1"
	greenhousev1alpha1 "github.com/cloudoperators/greenhouse/api/v1alpha1"
)

/*
Updated version of the dummy type with second property
*/

// DummySpec defines the desired state of Dummy
type DummySpec struct {
	// Dummy Description
	Description string `json:"description,omitempty"`
	// Dummy Property
	Property string `json:"property,omitempty"`
	// Second Dummy Property with default
	//+kubebuilder:default="default"
	SecondProperty string `json:"secondProperty,omitempty"`
}

// DummyStatus defines the observed state of Dummy
type DummyStatus struct {
	greenhousemetav1alpha1.StatusConditions `json:"statusConditions,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Description",type=string,JSONPath=`.spec.description`
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// Dummy is the Schema for the dummy API
type Dummy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   DummySpec   `json:"spec,omitempty"`
	Status DummyStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// DummyList contains a list of Dummy Items
type DummyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Dummy `json:"items"`
}

func init() {
	greenhousev1alpha1.SchemeBuilder.Register(&Dummy{}, &DummyList{})
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Dummy) DeepCopyInto(out *Dummy) {
	*out = *in
	out.TypeMeta = in.TypeMeta
	in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
	out.Spec = in.Spec
	out.Status = in.Status
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dummy.
func (in *Dummy) DeepCopy() *Dummy {
	if in == nil {
		return nil
	}
	out := new(Dummy)
	in.DeepCopyInto(out)
	return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Dummy) DeepCopyObject() runtime.Object {
	if c := in.DeepCopy(); c != nil {
		return c
	}
	return nil
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DummyList) DeepCopyInto(out *DummyList) {
	*out = *in
	out.TypeMeta = in.TypeMeta
	in.ListMeta.DeepCopyInto(&out.ListMeta)
	if in.Items != nil {
		in, out := &in.Items, &out.Items
		*out = make([]Dummy, len(*in))
		for i := range *in {
			(*in)[i].DeepCopyInto(&(*out)[i])
		}
	}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DummyList.
func (in *DummyList) DeepCopy() *DummyList {
	if in == nil {
		return nil
	}
	out := new(DummyList)
	in.DeepCopyInto(out)
	return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DummyList) DeepCopyObject() runtime.Object {
	if c := in.DeepCopy(); c != nil {
		return c
	}
	return nil
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DummySpec) DeepCopyInto(out *DummySpec) {
	*out = *in
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DummySpec.
func (in *DummySpec) DeepCopy() *DummySpec {
	if in == nil {
		return nil
	}
	out := new(DummySpec)
	in.DeepCopyInto(out)
	return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DummyStatus) DeepCopyInto(out *DummyStatus) {
	*out = *in
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DummyStatus.
func (in *DummyStatus) DeepCopy() *DummyStatus {
	if in == nil {
		return nil
	}
	out := new(DummyStatus)
	in.DeepCopyInto(out)
	return out
}

func (in *Dummy) GetConditions() greenhousemetav1alpha1.StatusConditions {
	return in.Status.StatusConditions
}

func (in *Dummy) SetCondition(condition greenhousemetav1alpha1.Condition) {
	in.Status.SetConditions(condition)
}
