(pkg *v1alpha1.Package, pkgBuild *buildconfigs.PackageBuild)
| 266 | } |
| 267 | |
| 268 | func (o *InitOptions) updatePackage(pkg *v1alpha1.Package, pkgBuild *buildconfigs.PackageBuild) error { |
| 269 | if len(pkg.Spec.Version) == 0 { |
| 270 | pkg.Spec.Version = "0.0.0" |
| 271 | } |
| 272 | pkg.Name = pkg.Spec.RefName + "." + pkg.Spec.Version |
| 273 | |
| 274 | if pkg.Spec.Template.Spec == nil { |
| 275 | pkg.Spec.Template.Spec = &kcv1alpha1.AppSpec{} |
| 276 | pkg.Spec.Template.Spec.Fetch = []kcv1alpha1.AppFetch{{Git: &kcv1alpha1.AppFetchGit{}}} |
| 277 | pkg.Spec.Template.Spec.Template = pkgBuild.GetAppSpec().Template |
| 278 | pkg.Spec.Template.Spec.Deploy = pkgBuild.GetAppSpec().Deploy |
| 279 | } else { |
| 280 | if !isAppSpecSame(pkg, pkgBuild) { |
| 281 | o.ui.PrintInformationalText("Found different AppSpec section in\n" + |
| 282 | "Package (inside package-resources.yml) and\n" + |
| 283 | "PackageBuild (inside package-build.yml)") |
| 284 | overrideOptions := []string{"Yes", "No"} |
| 285 | choiceOpts := ui.ChoiceOpts{ |
| 286 | Label: "Overwrite the Package AppSpec from PackageBuild", |
| 287 | Default: 1, |
| 288 | Choices: overrideOptions, |
| 289 | } |
| 290 | selectedIndex, err := o.ui.AskForChoice(choiceOpts) |
| 291 | if err != nil { |
| 292 | return err |
| 293 | } |
| 294 | if overrideOptions[selectedIndex] == "Yes" { |
| 295 | pkg.Spec.Template.Spec.Template = pkgBuild.GetAppSpec().Template |
| 296 | pkg.Spec.Template.Spec.Deploy = pkgBuild.GetAppSpec().Deploy |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | return nil |
| 301 | } |
| 302 | |
| 303 | // isAppSpecSame compares the template and deploy section of package and packageBuild. |
| 304 | // It doesn't consider fetch as this will always be different because PackageBuild doesn't |
no test coverage detected