MCPcopy Create free account
hub / github.com/cloudfoundry/multiapps-cli-plugin / Build

Method Build

util/archive_builder.go:31–119  ·  view source on GitHub ↗

Build creates deployment archive from the provided deployment descriptor

(deploymentDescriptorLocation string)

Source from the content-addressed store, hash-verified

29
30// Build creates deployment archive from the provided deployment descriptor
31func (builder MtaArchiveBuilder) Build(deploymentDescriptorLocation string) (string, error) {
32 descriptor, deploymentDescriptorFile, err := ParseDeploymentDescriptor(deploymentDescriptorLocation)
33 if err != nil {
34 return "", err
35 }
36
37 modulesPaths, err := builder.getModulesPaths(descriptor.Modules)
38 if err != nil {
39 return "", fmt.Errorf("Error building MTA Archive: %s", err.Error())
40 }
41 resourcesPaths, err := builder.getResourcesPaths(descriptor.Resources)
42 if err != nil {
43 return "", fmt.Errorf("Error building MTA Archive: %s", err.Error())
44 }
45 bindingParametersPaths := builder.getBindingParametersPaths(descriptor.Modules)
46
47 modulesSections := buildSection(normalizePathsUsingUnixSeparator(modulesPaths), MtaModule)
48 resourcesSections := buildSection(normalizePathsUsingUnixSeparator(resourcesPaths), MtaResource)
49 bindingParametersSections := buildSection(normalizePathsUsingUnixSeparator(bindingParametersPaths), MtaRequires)
50
51 manifestBuilder := NewMtaManifestBuilder()
52 manifestBuilder.ManifestSections(modulesSections)
53 manifestBuilder.ManifestSections(resourcesSections)
54 manifestBuilder.ManifestSections(bindingParametersSections)
55 manifestBuilder.ManifestSections([]ManifestSection{NewMtaManifestSectionBuilder().Name(MtadAttribute).Build()})
56
57 manifestLocation, err := manifestBuilder.Build()
58 if err != nil {
59 return "", err
60 }
61 defer os.Remove(manifestLocation)
62
63 mtaAssembly, err := os.MkdirTemp("", "mta-assembly")
64 if err != nil {
65 return "", err
66 }
67 defer os.RemoveAll(mtaAssembly)
68
69 metaInfLocation := filepath.Join(mtaAssembly, "META-INF")
70 err = os.Mkdir(metaInfLocation, os.ModePerm)
71 if err != nil {
72 return "", err
73 }
74
75 manifestInfo, err := os.Stat(manifestLocation)
76 if err != nil {
77 return "", err
78 }
79
80 err = copyFile(manifestLocation, filepath.Join(metaInfLocation, manifestInfo.Name()))
81 if err != nil {
82 return "", err
83 }
84
85 err = copyFile(deploymentDescriptorFile, filepath.Join(metaInfLocation, "mtad.yaml"))
86 if err != nil {
87 return "", err
88 }

Callers

nothing calls this directly

Calls 15

getModulesPathsMethod · 0.95
getResourcesPathsMethod · 0.95
ManifestSectionsMethod · 0.95
BuildMethod · 0.95
buildSectionFunction · 0.85
NewMtaManifestBuilderFunction · 0.85
copyFileFunction · 0.85
copyContentFunction · 0.85

Tested by

no test coverage detected