Build creates deployment archive from the provided deployment descriptor
(deploymentDescriptorLocation string)
| 29 | |
| 30 | // Build creates deployment archive from the provided deployment descriptor |
| 31 | func (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 | } |
nothing calls this directly
no test coverage detected