ParseDeploymentDescriptor parses the deployment descriptor which is located in the provided direcotry
(deploymentDescriptorLocation string)
| 137 | |
| 138 | // ParseDeploymentDescriptor parses the deployment descriptor which is located in the provided direcotry |
| 139 | func ParseDeploymentDescriptor(deploymentDescriptorLocation string) (MtaDeploymentDescriptor, string, error) { |
| 140 | if _, err := os.Stat(deploymentDescriptorLocation); os.IsNotExist(err) { |
| 141 | return MtaDeploymentDescriptor{}, "", fmt.Errorf("Deployment descriptor location does not exist %s", deploymentDescriptorLocation) |
| 142 | } |
| 143 | deploymentDescriptor, err := findDeploymentDescriptor(deploymentDescriptorLocation) |
| 144 | if err != nil { |
| 145 | return MtaDeploymentDescriptor{}, "", err |
| 146 | } |
| 147 | deploymentDescriptorYaml, err := os.ReadFile(deploymentDescriptor) |
| 148 | if err != nil { |
| 149 | return MtaDeploymentDescriptor{}, "", fmt.Errorf("Could not read deployment descriptor: %s", err.Error()) |
| 150 | } |
| 151 | var descriptor MtaDeploymentDescriptor |
| 152 | err = yaml.Unmarshal(deploymentDescriptorYaml, &descriptor) |
| 153 | if err != nil { |
| 154 | return MtaDeploymentDescriptor{}, "", fmt.Errorf("Could not unmarshal deployment descriptor from yaml: %s", err.Error()) |
| 155 | } |
| 156 | |
| 157 | return descriptor, deploymentDescriptor, nil |
| 158 | } |
| 159 | |
| 160 | func findDeploymentDescriptor(deploymentDescriptorLocation string) (string, error) { |
| 161 | deploymentDescriptorOccurances, err := filepath.Glob(filepath.Join(deploymentDescriptorLocation, deploymentDescriptorYamlName)) |
no test coverage detected