Skip to content

Commit

Permalink
Installing Local Operators Requires Abs or relative notation (#1579)
Browse files Browse the repository at this point in the history
Signed-off-by: Ken Sipe <[email protected]>
  • Loading branch information
kensipe authored Jul 9, 2020
1 parent f25a54a commit f58547c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/kudoctl/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
or a path to an unpacked package directory.
# Install the most recent Flink package to your cluster.
kubectl kudo install flink
kubectl kudo install ./flink
#*Note*: should you have a local "flink" folder in the current directory it will take precedence over the remote repository.
# Install operator from a local filesystem
Expand Down
20 changes: 16 additions & 4 deletions pkg/kudoctl/packages/resolver/resolver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package resolver

import (
"path/filepath"

"github.com/kudobuilder/kudo/pkg/kudoctl/clog"
"github.com/kudobuilder/kudo/pkg/kudoctl/http"
"github.com/kudobuilder/kudo/pkg/kudoctl/packages"
Expand Down Expand Up @@ -37,13 +39,23 @@ func New(repo *repo.Client) *PackageResolver {
// - a local directory
// - a url to a tgz
// - an operator name in the remote repository
// in that order. Should there exist a local folder e.g. `cassandra` it will take precedence
// over the remote repository package with the same name.
// in that order.
// For local access there is a need to provide absolute or relative path as part of the name argument. `cassandra` without a path
// component will resolve to the remote repo. `./cassandra` will resolve to a folder which is expected to have the operator structure on the filesystem.
// `../folder/cassandra.tgz` will resolve to the cassandra package tarball on the filesystem.
func (m *PackageResolver) Resolve(name string, appVersion string, operatorVersion string) (p *packages.Package, err error) {

// Local files/folder have priority
if _, err = m.local.fs.Stat(name); err == nil {
clog.V(2).Printf("local operator discovered: %v", name)
_, err = m.local.fs.Stat(name)
// force local operators usage to be either absolute or express a relative path
// or put another way, a name can NOT be mistaken to be the name of a local folder
if filepath.Base(name) != name && err == nil {
var abs string
abs, err = filepath.Abs(name)
if err != nil {
return nil, err
}
clog.V(2).Printf("local operator discovered: %v", abs)
p, err = m.local.Resolve(name, appVersion, operatorVersion)
return
}
Expand Down

0 comments on commit f58547c

Please sign in to comment.