(plan InstallPlan)
| 279 | } |
| 280 | |
| 281 | func ValidateInstallPlan(plan InstallPlan) error { |
| 282 | plan = NormalizeInstallPlan(plan) |
| 283 | if plan.Type == "" { |
| 284 | return fmt.Errorf("missing install type") |
| 285 | } |
| 286 | if plan.Type != InstallTypeDirect && plan.Type != InstallTypeGitHubRelease { |
| 287 | return fmt.Errorf("unsupported install type %q", plan.Type) |
| 288 | } |
| 289 | if plan.Type != InstallTypeDirect { |
| 290 | return nil |
| 291 | } |
| 292 | if len(plan.Artifacts) == 0 { |
| 293 | return fmt.Errorf("direct install requires at least one artifact") |
| 294 | } |
| 295 | for index, artifact := range plan.Artifacts { |
| 296 | if errArtifact := ValidateArtifact(artifact); errArtifact != nil { |
| 297 | return fmt.Errorf("artifacts[%d]: %w", index, errArtifact) |
| 298 | } |
| 299 | } |
| 300 | return nil |
| 301 | } |
| 302 | |
| 303 | func ValidateArtifact(artifact Artifact) error { |
| 304 | artifact.GOOS = normalizeGOOS(artifact.GOOS) |
no test coverage detected