Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new KEP-9 package format in installs #343

Merged
merged 14 commits into from
Jun 21, 2019
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/go-openapi/swag v0.18.0 // indirect
github.com/go-playground/locales v0.12.1 // indirect
github.com/go-playground/universal-translator v0.16.0 // indirect
github.com/go-test/deep v1.0.1
github.com/gobuffalo/envy v1.6.15 // indirect
github.com/gogo/protobuf v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
Expand Down Expand Up @@ -48,7 +49,7 @@ require (
github.com/prometheus/common v0.2.0 // indirect
github.com/prometheus/procfs v0.0.0-20190209105433-f8d8b3f739bd // indirect
github.com/rogpeppe/go-internal v1.2.2 // indirect
github.com/spf13/afero v1.2.1 // indirect
github.com/spf13/afero v1.2.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now we are using afero just for our table tests in the package_test.go, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3 // indirect
github.com/stretchr/testify v1.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3yg
github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM=
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ=
github.com/gobuffalo/envy v1.6.15 h1:OsV5vOpHYUpP7ZLS6sem1y40/lNX1BZj+ynMiRi21lQ=
github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
Expand Down
1 change: 0 additions & 1 deletion pkg/bundle/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ type Framework struct {
URL string `json:"url,omitempty"`
Tasks map[string]v1alpha1.TaskSpec `json:"tasks"`
Plans map[string]v1alpha1.Plan `json:"plans"`
Parameters []v1alpha1.Parameter `json:"parameters,omitempty"`
Dependencies []v1alpha1.FrameworkDependency `json:"dependencies,omitempty"`
}
20 changes: 10 additions & 10 deletions pkg/kudoctl/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func installFramework(name, previous string, repository repo.FrameworkRepository

bundleName := bundleVersion.Name + "-" + bundleVersion.Version

bundle, err := repository.DownloadBundle(bundleName)
crds, err := repository.DownloadBundle(bundleName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we rename this method to DownloadPackage for consistency? Also, it doesn't just download but also untars and parses so maybe GetPackage?

if err != nil {
return errors.Wrap(err, "failed to download bundle")
}
Expand All @@ -160,7 +160,7 @@ func installFramework(name, previous string, repository repo.FrameworkRepository

// Check if Framework exists
if !kc.FrameworkExistsInCluster(name, options.Namespace) {
if err := installSingleFrameworkToCluster(name, options.Namespace, bundle.Framework, kc); err != nil {
if err := installSingleFrameworkToCluster(name, options.Namespace, crds.Framework, kc); err != nil {
return errors.Wrap(err, "installing single Framework")
}
}
Expand All @@ -170,25 +170,25 @@ func installFramework(name, previous string, repository repo.FrameworkRepository
// Check if AnyFrameworkVersion for Framework exists
if !kc.AnyFrameworkVersionExistsInCluster(name, options.Namespace) {
// FrameworkVersion CRD for Framework does not exist
if err := installSingleFrameworkVersionToCluster(name, options.Namespace, kc, bundle.FrameworkVersion); err != nil {
if err := installSingleFrameworkVersionToCluster(name, options.Namespace, kc, crds.FrameworkVersion); err != nil {
return errors.Wrapf(err, "installing FrameworkVersion CRD for framework %s", name)
}
}

// Check if FrameworkVersion is out of sync with official FrameworkVersion for this Framework
if !kc.FrameworkVersionInClusterOutOfSync(name, bundle.FrameworkVersion.Spec.Version, options.Namespace) {
if !kc.FrameworkVersionInClusterOutOfSync(name, crds.FrameworkVersion.Spec.Version, options.Namespace) {
// This happens when the given FrameworkVersion is not existing. E.g.
// when a version has been installed that is not part of the official kudobuilder/frameworks repo.
if !options.AutoApprove {
fmt.Printf("No official FrameworkVersion has been found for \"%s\". "+
"Do you want to install one? (Yes/no) ", name)
if helpers.AskForConfirmation() {
if err := installSingleFrameworkVersionToCluster(name, options.Namespace, kc, bundle.FrameworkVersion); err != nil {
if err := installSingleFrameworkVersionToCluster(name, options.Namespace, kc, crds.FrameworkVersion); err != nil {
return errors.Wrapf(err, "installing FrameworkVersion CRD for framework %s", name)
}
}
} else {
if err := installSingleFrameworkVersionToCluster(name, options.Namespace, kc, bundle.FrameworkVersion); err != nil {
if err := installSingleFrameworkVersionToCluster(name, options.Namespace, kc, crds.FrameworkVersion); err != nil {
return errors.Wrapf(err, "installing FrameworkVersion CRD for framework %s", name)
}
}
Expand All @@ -197,7 +197,7 @@ func installFramework(name, previous string, repository repo.FrameworkRepository

// Dependencies of the particular FrameworkVersion
if options.AllDependencies {
dependencyFrameworks, err := repository.GetFrameworkVersionDependencies(name, bundle.FrameworkVersion)
dependencyFrameworks, err := repository.GetFrameworkVersionDependencies(name, crds.FrameworkVersion)
if err != nil {
return errors.Wrap(err, "getting Framework dependencies")
}
Expand All @@ -220,7 +220,7 @@ func installFramework(name, previous string, repository repo.FrameworkRepository

// Check if Instance exists in cluster
// It won't create the Instance if any in combination with given Framework Name and FrameworkVersion exists
if !kc.AnyInstanceExistsInCluster(name, options.Namespace, bundle.FrameworkVersion.Spec.Version) {
if !kc.AnyInstanceExistsInCluster(name, options.Namespace, crds.FrameworkVersion.Spec.Version) {
// This happens when the given FrameworkVersion is not existing. E.g.
// when a version has been installed that is not part of the official kudobuilder/frameworks repo.
if !options.AutoApprove {
Expand All @@ -229,12 +229,12 @@ func installFramework(name, previous string, repository repo.FrameworkRepository
if helpers.AskForConfirmation() {
// If Instance is a dependency we need to make sure installSingleInstanceToCluster is aware of it.
// By having the previous string set we can make this distinction.
if err := installSingleInstanceToCluster(name, previous, bundle.Instance, kc, options); err != nil {
if err := installSingleInstanceToCluster(name, previous, crds.Instance, kc, options); err != nil {
return errors.Wrap(err, "installing single Instance")
}
}
} else {
if err := installSingleInstanceToCluster(name, previous, bundle.Instance, kc, options); err != nil {
if err := installSingleInstanceToCluster(name, previous, crds.Instance, kc, options); err != nil {
return errors.Wrap(err, "installing single Instance")
}
}
Expand Down
Loading