Unverified Commit d44b841c authored by Oren Shomron's avatar Oren Shomron Committed by GitHub
Browse files

Merge pull request #632 from shomron/remove-registry-add-version-flag

Remove defunct --version flag from registry add command
parents 05578f9a 9b5e717f
......@@ -10,10 +10,7 @@ provided that their file structures follow the appropriate schema. *You can look
at the `incubator` repo (https://github.com/ksonnet/parts/tree/master/incubator)
as an example.*
A registry is uniquely identified by its:
1. Name (e.g. `incubator`)
2. Version (e.g. `master`)
A registry is given a string identifier, which must be unique within a ksonnet application.
There are two supported registry protocols: **github** and **fs**.
......@@ -21,8 +18,7 @@ GitHub registries expect a path in a GitHub repository, and filesystem based
registries expect a path on the local filesystem.
During creation, all registries must specify a unique name and URI where the
registry lives. Optionally, a version can be provided (e.g. the *Github branch
name*). If a version is not specified, it will default to `latest`.
registry lives. GitHub registries can specify a commit, tag, or branch to follow as part of the URI.
Registries can be overridden with `--override`. Overridden registries
are stored in `app.override.yaml` and can be safely ignored using your
......@@ -46,17 +42,15 @@ ks registry add <registry-name> <registry-uri> [flags]
ks registry add databases github.com/example
# Add a registry with the name 'databases' at the uri
# 'github.com/example/tree/master/reg' and the version (branch name) 0.0.1
# NOTE that "0.0.1" overrides the branch name in the URI ("master")
ks registry add databases github.com/example/tree/master/reg --version=0.0.1
# 'github.com/org/example/tree/0.0.1/registry' (0.0.1 is the branch name)
ks registry add databases github.com/org/example/tree/0.0.1/registry
```
### Options
```
-h, --help help for add
-o, --override Store in override configuration
--version string Version of the registry to add
-h, --help help for add
-o, --override Store in override configuration
```
### Options inherited from parent commands
......
......@@ -39,9 +39,8 @@ type RegistryAdd struct {
app app.App
name string
uri string
version string
isOverride bool
registryAddFn func(a app.App, protocol registry.Protocol, name, uri, version string, isOverride bool) (*registry.Spec, error)
registryAddFn func(a app.App, protocol registry.Protocol, name string, uri string, isOverride bool) (*registry.Spec, error)
}
// NewRegistryAdd creates an instance of RegistryAdd.
......@@ -52,7 +51,6 @@ func NewRegistryAdd(m map[string]interface{}) (*RegistryAdd, error) {
app: ol.LoadApp(),
name: ol.LoadString(OptionName),
uri: ol.LoadString(OptionURI),
version: ol.LoadString(OptionVersion),
isOverride: ol.LoadBool(OptionOverride),
registryAddFn: registry.Add,
......@@ -72,7 +70,7 @@ func (ra *RegistryAdd) Run() error {
return errors.Wrap(err, "detect registry protocol")
}
_, err = ra.registryAddFn(ra.app, rd.Protocol, ra.name, rd.URI, ra.version, ra.isOverride)
_, err = ra.registryAddFn(ra.app, rd.Protocol, ra.name, rd.URI, ra.isOverride)
return err
}
......
......@@ -83,11 +83,10 @@ func TestRegistryAdd(t *testing.T) {
a, err := NewRegistryAdd(in)
require.NoError(t, err)
a.registryAddFn = func(a app.App, protocol registry.Protocol, name, uri, version string, isOverride bool) (*registry.Spec, error) {
a.registryAddFn = func(a app.App, protocol registry.Protocol, name string, uri string, isOverride bool) (*registry.Spec, error) {
assert.Equal(t, "new", name)
assert.Equal(t, tc.protocol, protocol)
assert.Equal(t, tc.expectedURI, uri)
assert.Equal(t, tc.version, version)
assert.Equal(t, tc.isOverride, isOverride)
return &registry.Spec{}, nil
......
......@@ -26,7 +26,6 @@ import (
)
const (
vRegistryAddVersion = "registry-add-version"
vRegistryAddOverride = "registry-add-override"
)
......@@ -37,10 +36,7 @@ provided that their file structures follow the appropriate schema. *You can look
at the ` + "`incubator`" + ` repo (https://github.com/ksonnet/parts/tree/master/incubator)
as an example.*
A registry is uniquely identified by its:
1. Name (e.g. ` + "`incubator`" + `)
2. Version (e.g. ` + "`master`" + `)
A registry is given a string identifier, which must be unique within a ksonnet application.
There are two supported registry protocols: **github** and **fs**.
......@@ -48,8 +44,7 @@ GitHub registries expect a path in a GitHub repository, and filesystem based
registries expect a path on the local filesystem.
During creation, all registries must specify a unique name and URI where the
registry lives. Optionally, a version can be provided (e.g. the *Github branch
name*). If a version is not specified, it will default to ` + "`latest`" + `.
registry lives. GitHub registries can specify a commit, tag, or branch to follow as part of the URI.
Registries can be overridden with ` + "`--override`" + `. Overridden registries
are stored in ` + "`app.override.yaml`" + ` and can be safely ignored using your
......@@ -65,9 +60,8 @@ SCM configuration.
ks registry add databases github.com/example
# Add a registry with the name 'databases' at the uri
# 'github.com/example/tree/master/reg' and the version (branch name) 0.0.1
# NOTE that "0.0.1" overrides the branch name in the URI ("master")
ks registry add databases github.com/example/tree/master/reg --version=0.0.1`
# 'github.com/org/example/tree/0.0.1/registry' (0.0.1 is the branch name)
ks registry add databases github.com/org/example/tree/0.0.1/registry`
)
func newRegistryAddCmd(a app.App) *cobra.Command {
......@@ -85,7 +79,6 @@ func newRegistryAddCmd(a app.App) *cobra.Command {
actions.OptionApp: a,
actions.OptionName: args[0],
actions.OptionURI: args[1],
actions.OptionVersion: viper.GetString(vRegistryAddVersion),
actions.OptionOverride: viper.GetBool(vRegistryAddOverride),
}
......@@ -93,9 +86,6 @@ func newRegistryAddCmd(a app.App) *cobra.Command {
},
}
registryAddCmd.Flags().String(flagVersion, "", "Version of the registry to add")
viper.BindPFlag(vRegistryAddVersion, registryAddCmd.Flags().Lookup(flagVersion))
registryAddCmd.Flags().BoolP(flagOverride, shortOverride, false, "Store in override configuration")
viper.BindPFlag(vRegistryAddOverride, registryAddCmd.Flags().Lookup(flagOverride))
......
......@@ -22,7 +22,7 @@ import (
// Add adds a registry with `name`, `protocol`, and `uri` to
// the current ksonnet application.
func Add(a app.App, protocol Protocol, name, uri, version string, isOverride bool) (*Spec, error) {
func Add(a app.App, protocol Protocol, name string, uri string, isOverride bool) (*Spec, error) {
var r Registry
var err error
......
......@@ -70,7 +70,7 @@ func TestAdd_GitHub(t *testing.T) {
return NewGitHub(a, registryRef, ghOpt)
}
spec, err := Add(appMock, ProtocolGitHub, "new", "github.com/foo/bar", "", true)
spec, err := Add(appMock, ProtocolGitHub, "new", "github.com/foo/bar", true)
require.NoError(t, err)
require.Equal(t, registrySpec, spec)
......@@ -80,14 +80,14 @@ func TestAdd_GitHub(t *testing.T) {
func TestAdd_fs(t *testing.T) {
test.WithApp(t, "/app", func(a *amocks.App, fs afero.Fs) {
_, err := Add(a, ProtocolFilesystem, "/invalid", "", "", false)
_, err := Add(a, ProtocolFilesystem, "/invalid", "", false)
require.Error(t, err)
})
}
func TestAdd_invalid(t *testing.T) {
test.WithApp(t, "/app", func(a *amocks.App, fs afero.Fs) {
_, err := Add(a, Protocol("invalid"), "", "", "", false)
_, err := Add(a, Protocol("invalid"), "", "", false)
require.Error(t, err)
})
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment