(args []string)
| 49 | } |
| 50 | |
| 51 | func (cmd ApplyManifestCommand) Execute(args []string) error { |
| 52 | err := cmd.SharedActor.CheckTarget(true, true) |
| 53 | if err != nil { |
| 54 | return err |
| 55 | } |
| 56 | |
| 57 | user, err := cmd.Actor.GetCurrentUser() |
| 58 | if err != nil { |
| 59 | return err |
| 60 | } |
| 61 | |
| 62 | readPath := cmd.CWD |
| 63 | if cmd.PathToManifest != "" { |
| 64 | readPath = string(cmd.PathToManifest) |
| 65 | } |
| 66 | |
| 67 | pathToManifest, exists, err := cmd.ManifestLocator.Path(readPath) |
| 68 | if err != nil { |
| 69 | return err |
| 70 | } |
| 71 | |
| 72 | if !exists { |
| 73 | return translatableerror.ManifestFileNotFoundInDirectoryError{PathToManifest: readPath} |
| 74 | } |
| 75 | |
| 76 | cmd.UI.DisplayTextWithFlavor("Applying manifest {{.ManifestPath}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{ |
| 77 | "ManifestPath": pathToManifest, |
| 78 | "OrgName": cmd.Config.TargetedOrganization().Name, |
| 79 | "SpaceName": cmd.Config.TargetedSpace().Name, |
| 80 | "Username": user.Name, |
| 81 | }) |
| 82 | |
| 83 | spaceGUID := cmd.Config.TargetedSpace().GUID |
| 84 | |
| 85 | var pathsToVarsFiles []string |
| 86 | for _, varFilePath := range cmd.PathsToVarsFiles { |
| 87 | pathsToVarsFiles = append(pathsToVarsFiles, string(varFilePath)) |
| 88 | } |
| 89 | |
| 90 | interpolatedManifestBytes, err := cmd.ManifestParser.InterpolateManifest(pathToManifest, pathsToVarsFiles, cmd.Vars) |
| 91 | if err != nil { |
| 92 | return err |
| 93 | } |
| 94 | |
| 95 | manifest, err := cmd.ManifestParser.ParseManifest(pathToManifest, interpolatedManifestBytes) |
| 96 | if err != nil { |
| 97 | if _, ok := err.(*yaml.TypeError); ok { |
| 98 | return errors.New("Unable to apply manifest because its format is invalid.") |
| 99 | } |
| 100 | return err |
| 101 | } |
| 102 | |
| 103 | manifestBytes, err := cmd.ManifestParser.MarshalManifest(manifest) |
| 104 | if err != nil { |
| 105 | return err |
| 106 | } |
| 107 | |
| 108 | diff, warnings, err := cmd.Actor.DiffSpaceManifest(spaceGUID, manifestBytes) |
nothing calls this directly
no test coverage detected