github.com/kubeshop/testkube@v1.17.23/pkg/tcl/mappertcl/tests/kube_openapi.go (about)

     1  // Copyright 2024 Testkube.
     2  //
     3  // Licensed as a Testkube Pro file under the Testkube Community
     4  // License (the "License"); you may not use this file except in compliance with
     5  // the License. You may obtain a copy of the License at
     6  //
     7  //     https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt
     8  
     9  package tests
    10  
    11  import (
    12  	testsv3 "github.com/kubeshop/testkube-operator/api/tests/v3"
    13  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
    14  )
    15  
    16  // MapExecutionRequestFromSpec maps CRD to OpenAPI spec ExecutionREquest
    17  func MapExecutionRequestFromSpec(sourceRequest *testsv3.ExecutionRequest,
    18  	destinationRequest *testkube.ExecutionRequest) *testkube.ExecutionRequest {
    19  	if sourceRequest == nil || destinationRequest == nil {
    20  		return destinationRequest
    21  	}
    22  
    23  	destinationRequest.ExecutionNamespace = sourceRequest.ExecutionNamespace
    24  	return destinationRequest
    25  }
    26  
    27  // MapSpecExecutionRequestToExecutionUpdateRequest maps ExecutionRequest CRD spec to ExecutionUpdateRequest OpenAPI spec to
    28  func MapSpecExecutionRequestToExecutionUpdateRequest(
    29  	sourceRequest *testsv3.ExecutionRequest, destinationRequest *testkube.ExecutionUpdateRequest) {
    30  	if sourceRequest == nil || destinationRequest == nil {
    31  		return
    32  	}
    33  
    34  	destinationRequest.ExecutionNamespace = &sourceRequest.ExecutionNamespace
    35  }