github.com/SAP/cloud-mta-build-tool@v1.2.27/internal/archive/module_location.go (about)

     1  package dir
     2  
     3  import (
     4  	"github.com/SAP/cloud-mta/mta"
     5  	"path/filepath"
     6  )
     7  
     8  // ModuleLoc - module location type that provides services for stand alone module build command
     9  type ModuleLoc struct {
    10  	loc               *Loc
    11  	targetPathDefined bool
    12  }
    13  
    14  // GetTarget - gets the target path
    15  func (ep *ModuleLoc) GetTarget() string {
    16  	return ep.loc.GetTarget()
    17  }
    18  
    19  // GetTargetTmpRoot - gets the target root path
    20  func (ep *ModuleLoc) GetTargetTmpRoot() string {
    21  	if ep.targetPathDefined {
    22  		return ep.loc.GetTarget()
    23  	}
    24  	// default target folder for module build results is defined under the temp folder
    25  	return filepath.Dir(ep.loc.GetTarget())
    26  }
    27  
    28  // GetSourceModuleDir - gets the absolute path to the module
    29  func (ep *ModuleLoc) GetSourceModuleDir(modulePath string) string {
    30  	return ep.loc.GetSourceModuleDir(modulePath)
    31  }
    32  
    33  // GetSourceModuleArtifactRelPath - gets the relative path to the module artifact
    34  // The ModuleLoc type is used in context of stand alone module build command and as opposed to the module build command in the context
    35  // of Makefile saves its build result directly under the target (temporary or specific) without considering the original artifact path in the source folder
    36  func (ep *ModuleLoc) GetSourceModuleArtifactRelPath(modulePath, artifactPath string) (string, error) {
    37  	return "", nil
    38  }
    39  
    40  // GetTargetModuleDir - gets the to module build results
    41  func (ep *ModuleLoc) GetTargetModuleDir(moduleName string) string {
    42  	return ep.loc.GetTarget()
    43  }
    44  
    45  // ParseFile returns a reference to the MTA object resulting from the given mta.yaml file merged with the extension descriptors.
    46  func (ep *ModuleLoc) ParseFile() (*mta.MTA, error) {
    47  	return ep.loc.ParseFile()
    48  }
    49  
    50  // ModuleLocation - provides target location of stand alone MTA module build result
    51  func ModuleLocation(loc *Loc, targetPathDefined bool) *ModuleLoc {
    52  	return &ModuleLoc{loc: loc, targetPathDefined: targetPathDefined}
    53  }