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

Comments on remote configuration #31

Closed
hadjian opened this issue Dec 1, 2023 · 5 comments · Fixed by #38
Closed

Comments on remote configuration #31

hadjian opened this issue Dec 1, 2023 · 5 comments · Fixed by #38
Assignees

Comments

@hadjian
Copy link
Contributor

hadjian commented Dec 1, 2023

@alexbrdn Testing the remote handling in the CLI:

  1. Why use a panic, when the configuration cannot be read? A CLI can exit and a server can refuse to start. An unreadable config is an external error, which doesn't seem to warrant a panic, no? It just dumps a stack trace on the terminal, which could be a nice error message.
    https://github.com/web-of-things-open-source/tm-catalog-cli/blob/71ec3a6ecced7e205172b704c20bfaedcd49ff4f/main.go#L44

  2. If you agree, I'd like to improve the error message for the case of multiple remotes with no default. I suggest:
    "push failed: multiple remotes configured, but remote target not specified and no default remote set."

Otherwise it looks quite good already.

@hadjian
Copy link
Contributor Author

hadjian commented Dec 1, 2023

  1. What if a fs remote was moved or deleted? Shall we improve the error message for that case?

@alexbrdn
Copy link
Contributor

alexbrdn commented Dec 1, 2023

how do you tell if a remote was moved or the config is wrong?

@alexbrdn alexbrdn self-assigned this Dec 1, 2023
@alexbrdn
Copy link
Contributor

RE 1: config is read in a package init() function. That is, before the app code has even started. There's no way to let this error float up the stack and be logged nicely, except if we're willing to delay the viper initialization. Which I don't particularly like.

@alexbrdn
Copy link
Contributor

RE 2: in light of the #28, I have removed the concept of default remote altogether. The only command that needs it is the push and it makes more sense to make the default flag mandatory for push, unless there's only one remote configured.

@alexbrdn
Copy link
Contributor

RE 3: I have added a check in FileRemote, which validates before list, versions, and fetch, that the configured root exists and is a directory. I don't know if there's a better way to deal with a moved/deleted directory.

alexbrdn added a commit that referenced this issue Dec 20, 2023
…ig-errmessages

- feat: remove concept of default remote in favor of explicit setting where necessary
- chore: improve some error messages, e.g. those mentioned in #31  
- fix: make remote.saveConfig() save only the remotes part to config
- test: make logger setup tests independent of config file in user's home dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants