github.com/redhat-appstudio/e2e-tests@v0.0.0-20240520140907-9709f6f59323/pkg/utils/contract/policy.go (about)

     1  package contract
     2  
     3  import ecp "github.com/enterprise-contract/enterprise-contract-controller/api/v1alpha1"
     4  
     5  // PolicySpecWithSourceConfig returns a new EnterpriseContractPolicySpec which is a deep copy of
     6  // the provided spec with each source config updated.
     7  func PolicySpecWithSourceConfig(spec ecp.EnterpriseContractPolicySpec, sourceConfig ecp.SourceConfig) ecp.EnterpriseContractPolicySpec {
     8  	var sources []ecp.Source
     9  	for _, s := range spec.Sources {
    10  		source := s.DeepCopy()
    11  		source.Config = sourceConfig.DeepCopy()
    12  		sources = append(sources, *source)
    13  	}
    14  
    15  	newSpec := *spec.DeepCopy()
    16  	newSpec.Sources = sources
    17  	return newSpec
    18  }