package mutatefuncs

import (
	"github.com/crossplane-contrib/provider-aws/apis/eks/manualv1alpha1"
	iamv1beta1 "github.com/crossplane-contrib/provider-aws/apis/iam/v1beta1"
	route53v1alpha1 "github.com/crossplane-contrib/provider-aws/apis/route53/v1alpha1"

	// TODO: deprecate it
	vpcpeeringv1alpha1 "github.com/crossplane/provider-aws/apis/vpcpeering/v1alpha1"
)

func MutateIAMOpenIDConnectProvider(current, expected *iamv1beta1.OpenIDConnectProvider) error {
	current.Labels = expected.Labels
	current.Annotations = expected.Annotations

	current.Spec.ResourceSpec = expected.Spec.ResourceSpec
	current.Spec.ForProvider = expected.Spec.ForProvider

	return nil
}

func MutateIAMRole(current, expected *iamv1beta1.Role) error {
	current.Labels = expected.Labels
	current.Annotations = expected.Annotations

	current.Spec.ResourceSpec = expected.Spec.ResourceSpec
	current.Spec.ForProvider = expected.Spec.ForProvider

	return nil
}

func MutateIAMPolicy(current, expected *iamv1beta1.Policy) error {
	current.Labels = expected.Labels
	current.Annotations = expected.Annotations

	current.Spec.ResourceSpec = expected.Spec.ResourceSpec
	current.Spec.ForProvider = expected.Spec.ForProvider

	return nil
}

func MutateIAMRolePolicyAttachment(current, expected *iamv1beta1.RolePolicyAttachment) error {
	current.Labels = expected.Labels
	current.Annotations = expected.Annotations

	current.Spec.ResourceSpec = expected.Spec.ResourceSpec
	current.Spec.ForProvider = expected.Spec.ForProvider

	return nil
}

// MutateAWSDNSResourceRecordSet create a dns record managed by AWS Route53, it's also used by GKE clusters
func MutateAWSDNSResourceRecordSet(current, expected *route53v1alpha1.ResourceRecordSet) error {
	current.Labels = expected.Labels
	current.Annotations = expected.Annotations

	current.Spec.ResourceSpec = expected.Spec.ResourceSpec
	current.Spec.ForProvider = expected.Spec.ForProvider

	return nil

}

func MutateAWSVPCPeering(current, expected *vpcpeeringv1alpha1.VPCPeeringConnection) error {
	current.Labels = expected.Labels
	current.Annotations = expected.Annotations

	current.Spec.ResourceSpec = expected.Spec.ResourceSpec
	current.Spec.ForProvider = expected.Spec.ForProvider

	return nil
}

func MutateNodeGroup(current, expected *manualv1alpha1.NodeGroup) error {
	current.Labels = expected.Labels
	current.Annotations = expected.Annotations

	current.Spec = expected.Spec

	return nil
}
