Skip to content

Commit

Permalink
fix(CreateDataset): remove transform creating default viz
Browse files Browse the repository at this point in the history
also added a 'none' option b/c currently our registry is dead & without
it you can't create a repo
  • Loading branch information
b5 committed Sep 13, 2018
1 parent 679d147 commit 4536dc6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
1 change: 0 additions & 1 deletion actions/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func UpdateDataset(node *p2p.QriNode, dsp *dataset.DatasetPod) (ds *dataset.Data

// CreateDataset initializes a dataset from a dataset pointer and data file
func CreateDataset(node *p2p.QriNode, name string, ds *dataset.Dataset, data cafs.File, secrets map[string]string, pin bool) (ref repo.DatasetRef, err error) {
log.Debugf("CreateDataset: %s", name)
var (
r = node.Repo
pro *profile.Profile
Expand Down
8 changes: 5 additions & 3 deletions actions/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
var ErrHandleTaken = fmt.Errorf("handle is taken")

// Setup provisions a new qri instance
func Setup(repoPath, cfgPath string, cfg *config.Config) error {
func Setup(repoPath, cfgPath string, cfg *config.Config, register bool) error {
if err := cfg.Validate(); err != nil {
return fmt.Errorf("invalid configuration: %s", err.Error())
}

if cfg.Registry != nil {
if register && cfg.Registry != nil {
pro, err := profile.NewProfile(cfg.Profile)
if err != nil {
return err
Expand All @@ -36,7 +36,9 @@ func Setup(repoPath, cfgPath string, cfg *config.Config) error {
if strings.Contains(err.Error(), "taken") {
return ErrHandleTaken
}
return err
// TODO - restore this error
// return err
err = nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion actions/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestSetupInitIPFSTeardown(t *testing.T) {

cfg := config.DefaultConfigForTesting()
cfg.Registry = nil
if err := Setup(path, path+"/config.yaml", cfg); err != nil {
if err := Setup(path, path+"/config.yaml", cfg, true); err != nil {
t.Error(err.Error())
}
if err := InitIPFS(path, nil); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions actions/viz.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import (

// PrepareViz loads vizualization bytes from a local filepath
func PrepareViz(ds *dataset.Dataset) (err error) {
// remove any empty vizualizations
if ds.Viz != nil && ds.Viz.IsEmpty() {
ds.Viz = nil
return nil
}

if ds.Viz != nil && ds.Viz.ScriptPath != "" {
// create a reader of script bytes
scriptdata, err := ioutil.ReadFile(ds.Viz.ScriptPath)
Expand Down
7 changes: 5 additions & 2 deletions cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ including all your datasets, and de-registers your peername from the registry.`,
cmd.Flags().BoolVarP(&o.Overwrite, "overwrite", "", false, "overwrite repo if one exists")
cmd.Flags().BoolVarP(&o.IPFS, "init-ipfs", "", true, "initialize an IPFS repo if one isn't present")
cmd.Flags().BoolVarP(&o.Remove, "remove", "", false, "permanently remove qri, overrides all setup options")
cmd.Flags().StringVarP(&o.Registry, "registry", "", "", "override default registry URL")
cmd.Flags().StringVarP(&o.Registry, "registry", "", "", "override default registry URL, set to 'none' to remove registry")
cmd.Flags().StringVarP(&o.Peername, "peername", "", "", "choose your desired peername")
cmd.Flags().StringVarP(&o.IPFSConfigData, "ipfs-config", "", "", "json-encoded configuration data, specify a filepath with '@' prefix")
cmd.Flags().StringVarP(&o.ConfigData, "config-data", "", "", "json-encoded configuration data, specify a filepath with '@' prefix")
Expand Down Expand Up @@ -168,7 +168,9 @@ func (o *SetupOptions) DoSetup(f Factory) (err error) {
cfg.Profile.Peername = inputText(o.Out, o.In, "choose a peername:", doggos.DoggoNick(cfg.Profile.ID))
}

if o.Registry != "" {
if o.Registry == "none" {
cfg.Registry = nil
} else if o.Registry != "" {
cfg.Registry.Location = o.Registry
}

Expand All @@ -178,6 +180,7 @@ func (o *SetupOptions) DoSetup(f Factory) (err error) {
ConfigFilepath: filepath.Join(o.QriRepoPath, "config.yaml"),
SetupIPFS: o.IPFS,
IPFSFsPath: o.IpfsFsPath,
Register: o.Registry == "none",
}

if o.IPFSConfigData != "" {
Expand Down
3 changes: 2 additions & 1 deletion lib/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ type SetupParams struct {
QriRepoPath string
ConfigFilepath string
SetupIPFS bool
Register bool
IPFSFsPath string
SetupIPFSConfigData []byte
}

// Setup provisions a new qri instance, it intentionally doesn't conform to the RPC function signature
// because remotely invoking setup doesn't make much sense
func Setup(p SetupParams) error {
if err := actions.Setup(p.QriRepoPath, p.ConfigFilepath, p.Config); err != nil {
if err := actions.Setup(p.QriRepoPath, p.ConfigFilepath, p.Config, p.Register); err != nil {
return err
}

Expand Down

0 comments on commit 4536dc6

Please sign in to comment.