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

Interactive init #5

Merged
merged 10 commits into from
Mar 11, 2020
Merged

Interactive init #5

merged 10 commits into from
Mar 11, 2020

Conversation

phamann
Copy link
Member

@phamann phamann commented Mar 9, 2020

TL;DR

Refactors compute init to accept its input interactively and act as a setup wizard to provision a service, backend and domain.

Why?

We have observed friction in user testing and feedback that a users has to create a service then attach a domain and backend before a compute package can be deployed and activated. If you are new to Fastly this may be confusing. Therefore, we think that provisioning all of this for you within a single command will reduce this on-boarding friction.

What?

  • Refactor command to take input interactively
  • Refactor fastly configure to persist user email to global config file so that it can be read by compute init for default author email.
  • Add a NullProgress writer which swallows all writes
  • Add an UndoStack which we use to teardown any state we have created in the API if an error occurs.
  • Add golang-petname dep to randomly generate nice domain names

Example:

Screenshot 2020-03-09 at 12 23 28

@phamann phamann requested a review from peterbourgon March 9, 2020 12:36
@phamann phamann force-pushed the phamann/interactive-init branch from 02a073d to 25c3c8f Compare March 9, 2020 13:31
Copy link
Contributor

@peterbourgon peterbourgon left a comment

Choose a reason for hiding this comment

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

A few questions and nits, but with those acknowledged, seems reasonable.

Man but testing is tedious, eh?

pkg/common/file.go Show resolved Hide resolved
pkg/common/undo.go Show resolved Hide resolved

var (
gitRepositoryRegEx = regexp.MustCompile(`((git|ssh|http(s)?)|(git@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(\.git)(/)?`)
domainNameRegEx = regexp.MustCompile(`(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]`)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am afraid this is incomplete, but I don't have the strength/knowledge/intelligence to test it. Does it come from some known source? Is it possible to be abused?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seemed the most robust in the top SO response for this question, however I agree with you that it could be brittle and I'm sad the Go standard library doesn't offer something such as how you can parse and validate IP addresses.

pkg/compute/init.go Outdated Show resolved Hide resolved
pkg/compute/init.go Show resolved Hide resolved
pkg/compute/init.go Outdated Show resolved Hide resolved
pkg/text/progress.go Show resolved Hide resolved
@phamann phamann merged commit 79b1177 into master Mar 11, 2020
@phamann phamann deleted the phamann/interactive-init branch March 11, 2020 09:37
phamann added a commit that referenced this pull request Mar 11, 2020
* Bump go-fastly to v1.7.0

* Add golang-petname dep

* Add NullProgress writer

* Add UndoStack to pkg/common

* Persist user email to global config file

* Make `compute init` accept input interactively and add logic to provision service, domain and backend during initialization.

* Surpress gosec G307 on file.Close() defers

* Add RunIfError method to UndoStack which unwinds the stack if passed an error

* Add text.Description() output helper to print term:description groupings.

* Refactor compute init to use new helpers
@phamann phamann added the enhancement New feature or request label Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants