Giter Site home page Giter Site logo

netlifyctl's Introduction

Build Status

netlifyctl

Legacy command line interface for managing and deploying sites on Netlify without leaving your terminal. Built in Go, on Netlify's OpenAPI definitions to interact with Netlify's API.

Netlify continues to support this version, but active development has moved to our new Node-based CLI. Find the full documentation at netlify.com/docs/cli.

Installation

Homebrew (Mac)

If you're running the Homebrew package manager for Mac, you can install netlifyctl with the following commands:

brew tap netlify/netlifyctl
brew install netlifyctl

When your installation completes, you can run netlifyctl --help for a list of available commands, or refer to this doc for more details.

Scoop (Windows)

Scoop is a package manager for Windows. You can install it with a single PowerShell command, then use it to install other command-line tools. To install netlifyctl using Scoop, run the following commands:

scoop bucket add netlifyctl https://github.com/netlify/scoop-netlifyctl
scoop install netlifyctl

When your installation completes, you can run netlifyctl --help for a list of available commands, or refer to this doc for more details.

Direct Binary Install (Linux, Mac, Windows)

Because netlifyctl is released as an executable binary file, you can download, extract, and run it from any directory you choose, with no dependencies.

You can download the latest version for your operating system directly from the following links:

If you're working on a local machine with administrator permissions, you may want to add netlifyctl to your PATH, so that you can access it directly from any project folder. You could do this by extracting it to a directory that is already on your PATH. (For example, /usr/local/bin is a common choice for Mac and Linux.) Alternatively, you can extract the netlifyctl binary to a different folder, then follow your operating system instructions for adding a path to your PATH environment variable.

In cases where you can't or don't want to install globally, like in many Continuous Integration (CI) environments, you can run netlifyctl from the folder of your choice by calling the path to the binary file.

For example, you could run the following command to download and extract the binary file directly into the current directory in a Linux terminal:

wget -qO- 'https://cli.netlify.com/download/latest/linux' | tar xz

Then, to use netlifyctl in that directory, you would use the relative path to the binary: ./netlifyctl. All netlifyctl commands in the rest of this document would follow the same pattern, for example:

./netlifyctl --help

Installing from Source with go get

Use the following commands to install netlifyctl from source:

go get -d github.com/netlify/netlifyctl
cd $GOPATH/src/github.com/netlify/netlifyctl
make deps build
go install

Authentication

Netlifyctl uses an access token to authenticate with Netlify. You can obtain this token via the command line or in the Netlify UI.

Command-line Login

To authenticate and obtain an access token via the command line, enter the following command:

netlifyctl login

This will open a browser window, asking you to log in with Netlify and grant access to Netlify Cli.

Once authorized, netlifyctl will store your access token in your home folder, under .config/netlify. Netlifyctl will use the token in this location automatically for all future commands.

If you'd like to store your token in a different location, you can remove it from the default location and add it manually to your commands by using the -A flag:

netlifyctl -A "YOUR_ACCESS_TOKEN" deploy

If you lose your token, you can repeat this process to generate a new one.

Obtain a Token in the Netlify UI

You can generate an access token manually in your Netlify account settings under OAuth applications, at https://app.netlify.com/applications.

  1. Under Personal access tokens, select New access token.
  2. Enter a description and select Generate token.
  3. Copy the generated token to your clipboard. Once you navigate from the page, the token cannot be seen again.

You can add the access token to individual commands with the -A flag:

netlifyctl -A "YOUR_ACCESS_TOKEN" deploy

Alternatively, you can store the token locally, and netlifyctl will use it automatically. To do this, enter the following line in a file titled netlify:

{"access_token": "YOUR_ACCESS_TOKEN"}

Store the file in a folder called .config, inside your home folder.

Revoking Access

To revoke access to your account for netlifyctl, go to the OAuth applications section of your account settings, at https://app.netlify.com/applications. Find the appropriate token or application, and select Revoke.

Continuous Deployment

With continuous deployment, Netlify will automatically deploy new versions of your site when you push commits to your connected Git repository. This also enables features like Deploy Previews, branch deploys, and split testing. (Some of these features must be enabled in the Netlify UI.)

Automated Setup

For repositories stored on GitHub or GitLab, you can use netlifyctl to connect your repository by running the following command from your local repository:

netlifyctl init

In order to connect your repository for continuous deployment, netlifyctl will need access to create a deploy key and a webhook on the repository. When you run the command above, you'll be prompted to log in to your GitHub account, which will create an account-level access token.

The access token will be stored in your home folder, under .config/hub. Your login password will never be stored. You can revoke the access token at any time from your GitHub account settings.

Manual Setup

For repositories stored on other Git providers, or if you prefer to give more limited, repository-only access, you can connect your repository manually by adding the --manual flag. From your local repository, run the following command:

netlifyctl init --manual

The tool will prompt you for your deploy settings, then provide you with two items you will need to add to your repository settings with your Git provider:

  • Deploy/access key: Netlify uses this key to fetch your repository via ssh for building and deploying. Sample terminal output reads: 'Give this Netlify SSH public key access to your repository,' and displays a key code. Copy the key printed in the command line, then add it as a deploy key in the repository settings on your Git Provider. The deploy key does not require write access. Note that if you have more than one site connected to a repo, you will need a unique key for each one.
  • Webhook: Your Git provider will send a message to this webhook when you push changes to your repository, triggering a new deploy on Netlify. Sample terminal output reads: 'Configure the following webhook for your repository,' and displays a URL. Copy the webhook address printed in the command line, then add it as the Payload URL for a new webhook in the repository settings on your Git provider. If available, the Content type should be set to application/json. When selecting events to trigger the webhook, Push events will trigger production and branch deploys on watched branches, and Pull/Merge request events will trigger deploy previews.

Manual Deploy

It's also possible to deploy a site manually, without continuous deployment. This method uploads files directly from your local project directory to your site on Netlify, without running a build step. It also works with directories that are not Git repositories.

A common use case for this command is when you're using a separate Contiuous Integration (CI) tool, deploying prebuilt files to Netlify at the end of the CI tool tasks.

To deploy manually, run the following command from the base of your project directory:

netlifyctl deploy

Netlifyctl will deploy the site using the configuration settings in a netlify.toml file stored at the base of your project directory. If this file doesn't exist, netlifyctl will prompt you for your site settings, then create a new netlify.toml file to store them.

After the first deploy, you can run netlifyctl deploy again to update your site whenever you make changes. Only new and changed files will be uploaded.

Draft Deploys

If you'd like to preview a manual deploy without changing it in production, you can use the --draft flag:

netlifyctl deploy --draft

This will run a deploy just like your production deploy, but at a unique address. The draft site URL will display in the command line when the deploy is done.

Debugging

Netlifyctl generates debug logs with all the request and response interations when there is an error running any command. Those logs are stored in a file called netlifyctl-debug.log in the directory where you ran the command. These logs include your access token for the API! Please make sure you don't share them with anyone without masking those first.

You can force the CLI to generate these logs even when there are no errors with the -D flag: netlifyctl -D deploy.

Additional Commands

For a full list of commands and global flags available with netlifyctl, run the following:

netlifyctl help

For more information about a specific command, run help with the name of the command.

netlifyctl help deploy

This also works for sub-commands.

netlifyctl help site update

License

MIT

netlifyctl's People

Contributors

bcomnes avatar bdougie avatar biilmann avatar brycekahle avatar calavera avatar davidwells avatar dcreemer avatar depadiernos avatar dvrkps avatar erans avatar fool avatar haegin avatar j-d-b avatar jakebellacera avatar keiko713 avatar lannonbr avatar robphoenix avatar rybit avatar verythorough avatar ykzts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netlifyctl's Issues

Follow symlinks

Hi,

Netlify-cli follows symlinks, netlifyctl should probably have the same behavior.

give verbose messaging about explicitly setting the webhook type to 'application/json' in GH UI

When a user runs netlifyctl init -m they are given a webhook URL to put in place in GitHub's UI. This is pretty straightforward:

image

...however there is a default setting on the Content type to be "application/x-www-form-urlencoded" which doesn't at present work with our system (GitHub sends JSON with this content type, rails does not parse it successfully).

We should call this out when giving the user the webhook that the content-type should be adjusted to "application/json" and then things will just work.

return some indication of whether the old deployment was locked when a new production deploy is sent

This was a suggestion from a customer.

Scenario: You use locked deploys in the UI to prevent autopublishing from git. This works fine until you send a deploy via netlifyctl deploy which will publish the current deploy - and leave deploys UNLOCKED.

Suggestion: before deploying, check for the current deploy being locked and output some sort of warning that you've now turned off locking and should revisit the site dashboard to re-lock deploys.

Failed to install netlifyctl using go get

Step 20/22 : RUN go get github.com/netlify/netlifyctl
 ---> Running in 746bece28fc4
๏ฟฝ[91m# github.com/netlify/netlifyctl/commands/init
go/src/github.com/netlify/netlifyctl/commands/init/git.go:25:34: undefined: models.RepoSetup
go/src/github.com/netlify/netlifyctl/commands/init/github.go:88:62: undefined: models.RepoSetup
go/src/github.com/netlify/netlifyctl/commands/init/github.go:95:10: undefined: models.RepoSetup
go/src/github.com/netlify/netlifyctl/commands/init/gitlab.go:66:62: undefined: models.RepoSetup
go/src/github.com/netlify/netlifyctl/commands/init/gitlab.go:73:10: undefined: models.RepoSetup
go/src/github.com/netlify/netlifyctl/commands/init/manual.go:37:61: undefined: models.RepoSetup
go/src/github.com/netlify/netlifyctl/commands/init/manual.go:40:10: undefined: models.RepoSetup
๏ฟฝ[0mThe command '/bin/sh -c go get github.com/netlify/netlifyctl' returned a non-zero code: 2

Used to work a couple of months ago.
Go version: 1.9.2

Missing "Continue?" prompt when using init --manual (Gitlab)

Following the steps for init --manual

after reaching:

Configuring Continuous Deployment ... ๐ŸŒŽ
Give this Netlify SSH public key access to your repository:

(SSH_KEY)

and copying and adding the SSH key to the gitlab repo:
GITLAB_PROJECT > Settings > Repository - Deploy Keys

the command line holds with
Configuring Continuous Deployment ... ๐ŸŒ (with the globe animating)

Failed to publish site using v0.2.0 binaries

netlifyctl deploy -A 9e06ca34686***0b3c69e0e
Counting objects .... 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x84ca01]

goroutine 1 [running]:
github.com/netlify/netlifyctl/operations.(*DeployObserver).OnSuccessfulStep(0xc4200103c0, 0xc4202a05a0, 0xa, 0xc4202a05a0)
	/home/david/src/github.com/netlify/netlifyctl/operations/deploy.go:43 +0xc1
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.walk.func1(0xc4200a0240, 0x89, 0x10559e0, 0xc42051e4e0, 0x0, 0x0, 0x0, 0x0)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:480 +0x343
path/filepath.walk(0xc4200a0240, 0x89, 0x10559e0, 0xc42051e4e0, 0xc4202a0540, 0x0, 0x0)
	/usr/local/go/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0xc420520380, 0x7e, 0x10559e0, 0xc42051e410, 0xc4202a0540, 0x0, 0x30)
	/usr/local/go/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0xc420520380, 0x7e, 0xc4202a0540, 0x0, 0xc4202a0510)
	/usr/local/go/src/path/filepath/path.go:398 +0x14c
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.walk(0xc420520380, 0x7e, 0x1056920, 0xc4200103c0, 0x0, 0x0, 0xc4200a5680)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:487 +0x1be
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).DoDeploy(0xc42051c420, 0x7fec00ee8f98, 0xc42020cb10, 0xc4200a01b0, 0x0, 0xba29a0, 0xbc3d00, 0xc42051a400)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:173 +0xc5
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).DeploySite(0xc42051c420, 0x7fec00ee8f98, 0xc42020cb10, 0xc4202a00f0, 0x24, 0xc420520380, 0x7e, 0x0, 0x0, 0x0, ...)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:153 +0x9d
github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).deploySite(0xc420324ba0, 0x7fec00ee8f58, 0xc42020cb10, 0xc42052cb40, 0xc42051c3c0, 0x0, 0x2, 0xc4201918b0, 0x84f912)
	/home/david/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:85 +0x61b
github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).(github.com/netlify/netlifyctl/commands/deploy.deploySite)-fm(0x7fec00ee8f58, 0xc42020cb10, 0xc42052cb40, 0xc42051c3c0, 0x0, 0x2, 0x0, 0x10a3da0)
	/home/david/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:44 +0x69
github.com/netlify/netlifyctl/commands/middleware.DebugMiddleware.func1(0x7fec00ee8f58, 0xc42020cb10, 0xc42052cb40, 0xc42051c3c0, 0x0, 0x2, 0x0, 0x0)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:87 +0x509
github.com/netlify/netlifyctl/commands/middleware.LoggingMiddleware.func1(0x7fec00ee8f58, 0xc42020cab0, 0xc42052cb40, 0xc42051c3c0, 0x0, 0x2, 0x10534a0, 0xc42007e158)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:113 +0x1f7
github.com/netlify/netlifyctl/commands/middleware.AuthMiddleware.func1(0x7fec00ee8f58, 0xc42020ca20, 0xc42052cb40, 0xc42051c3c0, 0x0, 0x2, 0x1, 0xc42020c960)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:124 +0x1d4
github.com/netlify/netlifyctl/commands/middleware.ClientMiddleware.func1(0x7fec00ee8ed8, 0xc42007e158, 0xc42052cb40, 0xc42051c3c0, 0x0, 0x2, 0xc687bd, 0x4)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:177 +0x316
github.com/netlify/netlifyctl/commands/middleware.NewRunFunc.func1(0xc42052cb40, 0xc42051c3c0, 0x0, 0x2, 0x0, 0x0)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:52 +0xf5
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).execute(0xc42052cb40, 0xc42051c220, 0x2, 0x2, 0xc42052cb40, 0xc42051c220)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:644 +0x3ef
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1095c60, 0x10bf6b7, 0xc67fba, 0x3)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:734 +0x339
github.com/netlify/netlifyctl/commands.Execute()
	/home/david/src/github.com/netlify/netlifyctl/commands/netlify.go:41 +0x2a5
main.main()
	/home/david/src/github.com/netlify/netlifyctl/main.go:16 +0x7e

After downgrading to v0.1.5 everything went well.

netlifyctl deploy hangs during object upload

After #67, netlifyctl deploy no longer crashes (thanks!), but it does now hang, even if I run it with a TTY. (In contrast, 0.2.0 worked fine with a TTY, just crashing when run headless).

The output I see is just the following:

Counting objects: 352 total objects  โœ”
Resolving deltas: 2 objects to upload  โœ”
Uploading objects: 0/2 ๐ŸŒ

(and then it appears not to make any forward progress, even though the objects it's uploading are tiny: the largest is ~50KB.)

Any idea how to debug this? I've tried running with --debug, but that doesn't help because the upload attempt never seems to complete, and so the debug log is never written.

Given the delta between 0.2.0 and 0.2.1, I guess d0ea834 must be the cause, though I've no idea why.

Why rewrite in golang?

Hi,
May I know why rewrite it in golang? Is there any benefit? Or it just an experiment?

inability to specify deploy message with -m

It seems like we are trying to support this:

https://github.com/netlify/netlifyctl/blob/master/commands/deploy/deploy.go#L39

...but I sure can't get it to work, using either of the invocations that I think ought to do the trick:

$ netlifyctl -m "a deploy message from netlifyctl" deploy
What path would you like deployed? (default: .)
Counting objects: 62 total objects  โœ”
Resolving deltas: 0 objects to upload  โœ”
Uploading objects: 0/0 done  โœ”
Deploy done  ๐ŸŒŽ
    https://www.cyclocrass.com
$ netlifyctl deploy -m "your ad here"
What path would you like deployed? (default: .)
Counting objects: 62 total objects  โœ”
Resolving deltas: 0 objects to upload  โœ”
Uploading objects: 0/0 done  โœ”
Deploy done  ๐ŸŒŽ

leads to these deploys:

image

Deploying in windows creates paths with backslashes that don't work once deployed

Deploying in windows creates paths with backslashes that don't work once deployed.

While version 0.3.2 was released to address this, the issue still persists:

Deploy.find("5a8c9c467b6ee80bfd6616ed").files.map{|f| puts f.path }; nil
/index.html
/subtest\subbing.html
=> nil

And to confirm the version of the CTL being used:

.\netlifyctl version
Version: 0.3.2
Git SHA: a1b86648871d4a5888a6a50e5e524cf650d5fa61

deploy error: "too many open files"

$ cd mywebsite && netlifyctl deploy
CCounting objects  โœ˜    
open netlifyctl-debug.log: too many open files
$ echo $?
255
$ find .git -type f |wc -l
108
$ find . -type f |wc -l
34929
$ netlifyctl version
cb64d2d16fb15394bb7d24b9fdc6d535e3071560

I am trying to deploy a documentation website (small and numerous pages). It works using the git push-deploy though. I would prefer to rely on this client though...

This error seems to come from golang itself, while accumulating file hashes.

It seems something deadlocks while trying to read from my ssd? Should I do something like bumping my ulimit? I have 99% inodes free...
stacktrace: https://gist.github.com/fenollp/e2c63ba00e03246054563a02900f7361

Possible solutions:

  • tar the website before sending (great for sending a lot of smallish files)
  • add --source & --target flags to deploy that, in addition to --base-directory, allow uploading parts of a website. May also benefit people who want to update only part of their website.

Thanks

go get/go build failure - missing function parameter

I get the following error when trying to go get , go install or go build netlifyctl.

commands/deploy/deploy.go:90:44: not enough arguments in call to client.WaitUntilDeployReady
        have ("github.com/netlify/netlifyctl/context".Context, *models.Deploy)
        want ("github.com/netlify/open-api/go/porcelain/context".Context, *models.Deploy, time.Duration)

The timeout arg is missing from the function call

ready, err := client.WaitUntilDeployReady(ctx, d)

I'd be happy to open a PR for this, though I'm not sure what the timeout value should be.

Always use SSH remote for manual configuration

Right now when doing netlifyctl init -m in a repository configured with an https URL in /.git/config, we fail to detect tha,t and the repo setup ends up not working properly with our automated checkouts.

netlifyctl should detect https URLs and automatically transform them into ssh URLs for use with deploy keys.

Print errors to stderr only

Print errors to stderr rather than writing everything to the file system in the CWD.

This is fairly annoying as it just pollutes the repo one is working in.

Contain the logging

As a library this should not be logging by default. It should be something that we can enable when called from the command line, but when used as a library it shouldn't put things out unless explicitly configured to.

Most commands fail

Listing sites works, but deploy etc all give:

$ netlifyctl deploy
panic: interface conversion: interface {} is nil, not *porcelain.Netlify

goroutine 1 [running]:
github.com/netlify/netlifyctl/context.GetClient(0x11a4300, 0xc420014058, 0xc420014058)
	/home/david/src/github.com/netlify/netlifyctl/context/context.go:30 +0x88
github.com/netlify/netlifyctl/operations.ChooseOrCreateSite(0x7f841e4f8528, 0xc420014058, 0xc4204d5680, 0x0, 0x0, 0xc4203beb88)
	/home/david/src/github.com/netlify/netlifyctl/operations/site.go:69 +0xc5
github.com/netlify/netlifyctl/commands/middleware.SiteConfigMiddleware.func1(0x7f841e4f8528, 0xc420014058, 0xc4204d5680, 0x121efa0, 0x0, 0x0, 0xcf5e2e, 0x4)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:200 +0x2b4
github.com/netlify/netlifyctl/commands/middleware.NewRunFunc.func1(0xc4204d5680, 0x121efa0, 0x0, 0x0, 0x0, 0x0)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:52 +0xf2
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).execute(0xc4204d5680, 0x121efa0, 0x0, 0x0, 0xc4204d5680, 0x121efa0)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:644 +0x3e8
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x11ef9e0, 0x121ec1c, 0xcf56fa, 0x3)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:734 +0x2fe
github.com/netlify/netlifyctl/commands.Execute()
	/home/david/src/github.com/netlify/netlifyctl/commands/netlify.go:41 +0x2a5
main.main()
	/home/david/src/github.com/netlify/netlifyctl/main.go:16 +0x79

0.2.2 works.
(Sorry for abruptness, late here!)

How to use Deploy Previews with this?

Can't use the web interface to setup Deploy Previews because the repo belongs to a Github Org that has restricted 3rd party app access, and the owners are all in the IT department and it would be a long wait to get them to approve

Tried netlify-cli but web hooks only manage to trigger production builds and not Deploy Previews (pushes and PRs on other branches trigger a production deployment build)

Tried this, but it also only deploys to the production url

It's cool that I can deploy without associating with a git repo, assumed it'd be possible to pass a flag to tell it this is a preview deploy, not implemented yet or did I miss it?

edit: looking at the api docs, it looks like deploy previews aren't exposed via api?

Handle login and signups

Add command:

$ netlifyctl login

Detect when there is no access token and ask for credentials in the Auth middleware too.

out of memory with 'netlifyctl deploy'

I just downloaded the pre-built Linux version and experimented with my site, It failed with the following log.
environment: Linux version 4.13.0-39-generic (buildd@lgw01-amd64-038) (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)) #44-Ubuntu SMP Thu Apr 5 14:25:01 UTC 2018

it looks like some memory leak as my laptop has 8GB memory with nothing else but Firefox on while running the command.

CCCCCCCCCCounting objects: 494 total objects โœ”
RRRRResolving deltas: 3 objects to upload โœ”
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUploading objects: 0/3 ๐ŸŒŽUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUploading objects: 0/3 ๐ŸŒUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUploading objects: 0/3 ๐ŸŒUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUploading objects: 0/3 ๐ŸŒŽUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUploading objects: 0/3 ๐ŸŒUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUploading objects: 0/3 ๐ŸŒŽUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUploading objects: 0/3 ๐ŸŒUUUUUUUUUUUUUUUUUUUUploading objects โœ˜
fatal error: runtime: out of memory

runtime stack:
runtime.throw(0xcb150b, 0x16)
/usr/local/go/src/runtime/panic.go:619 +0x81
runtime.sysMap(0xc6d9b10000, 0xbc860000, 0x0, 0x11bfcf8)
/usr/local/go/src/runtime/mem_linux.go:216 +0x20a
runtime.(*mheap).sysAlloc(0x11a6880, 0xbc860000, 0x1)
/usr/local/go/src/runtime/malloc.go:470 +0xd4
runtime.(*mheap).grow(0x11a6880, 0x5e42d, 0x0)
/usr/local/go/src/runtime/mheap.go:907 +0x60
runtime.(*mheap).allocSpanLocked(0x11a6880, 0x5e42d, 0x11bfd08, 0x2cd16)
/usr/local/go/src/runtime/mheap.go:820 +0x301
runtime.(*mheap).alloc_m(0x11a6880, 0x5e42d, 0x101, 0xc4205d9f10)
/usr/local/go/src/runtime/mheap.go:686 +0x118
runtime.(*mheap).alloc.func1()
/usr/local/go/src/runtime/mheap.go:753 +0x4d
runtime.(*mheap).alloc(0x11a6880, 0x5e42d, 0xc420010101, 0xc42047bc80)
/usr/local/go/src/runtime/mheap.go:752 +0x8a
runtime.largeAlloc(0xbc858f0f, 0x11a0101, 0xc42047bc01)
/usr/local/go/src/runtime/malloc.go:826 +0x94
runtime.mallocgc.func1()
/usr/local/go/src/runtime/malloc.go:721 +0x46
runtime.systemstack(0x11a4e74100000000)
/usr/local/go/src/runtime/asm_amd64.s:409 +0x79
runtime.mstart()
/usr/local/go/src/runtime/proc.go:1170

goroutine 31 [running]:
runtime.systemstack_switch()
/usr/local/go/src/runtime/asm_amd64.s:363 fp=0xc4205d7658 sp=0xc4205d7650 pc=0x454000
runtime.mallocgc(0xbc858f0f, 0xb29d40, 0x45f701, 0xc4205d7730)
/usr/local/go/src/runtime/malloc.go:720 +0x8a2 fp=0xc4205d76f8 sp=0xc4205d7658 pc=0x4109c2
runtime.makeslice(0xb29d40, 0xbc858f0f, 0xbc858f0f, 0xc420146070, 0x410c68, 0x11be250)
/usr/local/go/src/runtime/slice.go:61 +0x77 fp=0xc4205d7728 sp=0xc4205d76f8 pc=0x43ff07
bytes.makeSlice(0xbc858f0f, 0x0, 0x0, 0x0)
/usr/local/go/src/bytes/buffer.go:230 +0x6d fp=0xc4205d7768 sp=0xc4205d7728 pc=0x4d18dd
bytes.(*Buffer).grow(0xc4201476c0, 0x2cd15425, 0x506d3d)
/usr/local/go/src/bytes/buffer.go:144 +0x151 fp=0xc4205d77b8 sp=0xc4205d7768 pc=0x4d1291
bytes.(*Buffer).Write(0xc4201476c0, 0xc5f6424000, 0x2cd15425, 0x59a2a849, 0x59a2a849, 0x0, 0x0)
/usr/local/go/src/bytes/buffer.go:174 +0xd9 fp=0xc4205d77e8 sp=0xc4205d77b8 pc=0x4d1569
github.com/netlify/netlifyctl/vendor/github.com/sirupsen/logrus.Entry.log(0xc4200ae140, 0xc4203a2060, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb29a05, ...)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/sirupsen/logrus/entry.go:113 +0x357 fp=0xc4205d78c8 sp=0xc4205d77e8 pc=0x504fe7
github.com/netlify/netlifyctl/vendor/github.com/sirupsen/logrus.(*Entry).Debug(0xc4203a40f0, 0xc4205d7980, 0x1, 0x1)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/sirupsen/logrus/entry.go:130 +0xaa fp=0xc4205d7938 sp=0xc4205d78c8 pc=0x5052da
github.com/netlify/netlifyctl/vendor/github.com/sirupsen/logrus.(*Entry).Debugf(0xc4203a40f0, 0xc5c9712000, 0x2cd10b19, 0x0, 0x0, 0x0)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/sirupsen/logrus/entry.go:178 +0xef fp=0xc4205d79a0 sp=0xc4205d7938 pc=0x5058df
github.com/netlify/netlifyctl/vendor/github.com/go-openapi/runtime/client.(*Runtime).Submit(0xc420326000, 0xc42041c3c0, 0x0, 0x0, 0x0, 0x0)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/go-openapi/runtime/client/runtime.go:277 +0xbec fp=0xc4205d7b28 sp=0xc4205d79a0 pc=0x795b8c
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/plumbing/operations.(*Client).UploadDeployFile(0xc4203be100, 0xc420519860, 0xd2b0a0, 0xcd49d0, 0x0, 0x1, 0x2)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/plumbing/operations/operations_client.go:2066 +0x30f fp=0xc4205d7b78 sp=0xc4205d7b28 pc=0x806bdf
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).uploadFile.func2(0x0, 0x0)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:409 +0x5fa fp=0xc4205d7c68 sp=0xc4205d7b78 pc=0x85edda
github.com/netlify/netlifyctl/vendor/github.com/cenkalti/backoff.RetryNotify(0xc4207041e0, 0xd2c680, 0xc420704180, 0x0, 0xcfe3b001, 0xc4207041e0)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/cenkalti/backoff/retry.go:37 +0x88 fp=0xc4205d7d58 sp=0xc4205d7c68 pc=0x844d68
github.com/netlify/netlifyctl/vendor/github.com/cenkalti/backoff.Retry(0xc4207041e0, 0xd2c680, 0xc420704180, 0x0, 0xc420482f08)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/cenkalti/backoff/retry.go:25 +0x48 fp=0xc4205d7d98 sp=0xc4205d7d58 pc=0x844cb8
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).uploadFile(0xc4203be120, 0x7ff0ac42e9a8, 0xc4203a2630, 0xc4203521c0, 0xc42051df40, 0xd35500, 0xc420078140, 0x0, 0x0, 0xc4203f48c0, ...)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:386 +0x4b7 fp=0xc4205d7f80 sp=0xc4205d7d98 pc=0x85bf37
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4205d7f88 sp=0xc4205d7f80 pc=0x456b21
created by github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).uploadFiles
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:343 +0x3a1

goroutine 1 [semacquire, 7 minutes]:
sync.runtime_Semacquire(0xc4203f48cc)
/usr/local/go/src/runtime/sema.go:56 +0x39
sync.(*WaitGroup).Wait(0xc4203f48c0)
/usr/local/go/src/sync/waitgroup.go:129 +0x72
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).uploadFiles(0xc4203be120, 0x7ff0ac42e9a8, 0xc4203a2630, 0xc4203521c0, 0xc4203be860, 0xd35500, 0xc420078140, 0x0, 0x0, 0x4ded5d, ...)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:348 +0x461
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).DoDeploy(0xc4203be120, 0x7ff0ac42e9a8, 0xc4203a2630, 0xc4203880a0, 0xc4203521c0, 0xbc3500, 0xbe7440, 0xc420440400)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:262 +0x96e
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).DeploySite(0xc4203be120, 0x7ff0ac42e9a8, 0xc4203a2630, 0xc4200a41e0, 0x24, 0xc4200a4210, 0x24, 0x0, 0x0, 0x0, ...)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:144 +0x98
github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).deploySite(0xc42013aea0, 0x7ff0ac42e9e0, 0xc4203a2630, 0xc4202bf200, 0x11be250, 0x0, 0x0, 0xd31200, 0x7ff0ac42e9e0)
/home/david/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:89 +0x62f
github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).(github.com/netlify/netlifyctl/commands/deploy.deploySite)-fm(0x7ff0ac42e9e0, 0xc4203a2630, 0xc4202bf200, 0x11be250, 0x0, 0x0, 0xc282a0, 0xc4203a2270)
/home/david/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:45 +0x69
github.com/netlify/netlifyctl/commands/middleware.SiteConfigMiddleware.func1(0x7ff0ac42e9e0, 0xc4203a2270, 0xc4202bf200, 0x11be250, 0x0, 0x0, 0x1, 0xc4203a21b0)
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:222 +0x252
github.com/netlify/netlifyctl/commands/middleware.ClientMiddleware.func1(0x7ff0ac42e9e0, 0xc4203a20f0, 0xc4202bf200, 0x11be250, 0x0, 0x0, 0x81b82f, 0xbc3500)
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:183 +0x339
github.com/netlify/netlifyctl/commands/middleware.AuthMiddleware.func1(0x7ff0ac42e9e0, 0xc4203a2090, 0xc4202bf200, 0x11be250, 0x0, 0x0, 0x11a10a0, 0xd23250)
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:128 +0x1ca
github.com/netlify/netlifyctl/commands/middleware.LoggingMiddleware.func1(0x7ff0ac3db1a8, 0xc4200a8030, 0xc4202bf200, 0x11be250, 0x0, 0x0, 0xc4203e2570, 0xc4202b9b80)
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:116 +0x1f1
github.com/netlify/netlifyctl/commands/middleware.DebugMiddleware.func1(0x7ff0ac3db1a8, 0xc4200a8030, 0xc4202bf200, 0x11be250, 0x0, 0x0, 0x0, 0x0)
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:89 +0x4bb
github.com/netlify/netlifyctl/commands/middleware.NewRunFunc.func1(0xc4202bf200, 0x11be250, 0x0, 0x0, 0x0, 0x0)
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:52 +0xf2
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).execute(0xc4202bf200, 0x11be250, 0x0, 0x0, 0xc4202bf200, 0x11be250)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:644 +0x3db
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x118f980, 0x11bdebc, 0xca05bc, 0x3)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:734 +0x2d4
github.com/netlify/netlifyctl/commands.Execute()
/home/david/src/github.com/netlify/netlifyctl/commands/netlify.go:41 +0x29b
main.main()
/home/david/src/github.com/netlify/netlifyctl/main.go:16 +0x79

goroutine 18 [syscall, 7 minutes]:
os/signal.signal_recv(0x0)
/usr/local/go/src/runtime/sigqueue.go:139 +0xa6
os/signal.loop()
/usr/local/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.0
/usr/local/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 5 [select, 7 minutes, locked to thread]:
runtime.gopark(0xcd5f30, 0x0, 0xca307f, 0x6, 0x18, 0x1)
/usr/local/go/src/runtime/proc.go:291 +0x11a
runtime.selectgo(0xc420052750, 0xc42009a780)
/usr/local/go/src/runtime/select.go:392 +0xe50
runtime.ensureSigM.func1()
/usr/local/go/src/runtime/signal_unix.go:549 +0x1f4
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2361 +0x1

goroutine 49 [chan receive, 7 minutes]:
github.com/netlify/netlifyctl/commands/middleware.DebugMiddleware.func1.1(0xc42013b3e0, 0x0, 0xc4201476c0)
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:79 +0x38
created by github.com/netlify/netlifyctl/commands/middleware.DebugMiddleware.func1
/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:78 +0x464

goroutine 30 [chan send, 5 minutes]:
github.com/netlify/netlifyctl/operations.(*DeployObserver).OnFailedUpload(0xc420078140, 0xc42051dcc0)
/home/david/src/github.com/netlify/netlifyctl/operations/deploy.go:87 +0x3b
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).uploadFile(0xc4203be120, 0x7ff0ac42e9a8, 0xc4203a2630, 0xc4203521c0, 0xc42051dcc0, 0xd35500, 0xc420078140, 0x0, 0x0, 0xc4203f48c0, ...)
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:437 +0x56b
created by github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).uploadFiles
/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:343 +0x3a1

netlifyctl should allow native setup for existing sites

As far as I can tell, there is no way to let netlifyctl create a netlify.toml file for my existing site. I would accept a solution that made me input a site ID or sitename, but I would rather it do as netlify-cli does and list all the sites I have access to with my access token.

Currently, the workflow is:

"run netlifyctl deploy, don't let it create a new site. Experience error, and edit netlify.toml with site ID manually":

$ netlifyctl -A $NETLIFY_ACCESS_TOKEN deploy
=> We cannot find a site for this repository, do you want to create a new one? (yes/no) no
=> What path would you like deployed? (default: .)
Error: no consumer: "text/html; charset=utf-8"

Please implement some form of site choosing that will create a valid netlify.toml for an existing site without manually editing the file :)

some styles of header definition (to add to a redirect) do not work as expected in netlify.toml (only when parsed by netlifyctl)

CONTEXT:
Unable to use the following in a netlify.toml file:

[[redirects]]
  from = "/map"
  to = "https://maps.google.com"
  status = 200
  force = true
  headers = {X-From = "netlify_live", x-api-key= "LIVE API KEY"}

This causes the following error when running netlifyctl deploy

"Near line 13 (last key parsed 'redirects.headers'): Expected value but found '{' instead."

WORKAROUND:

The following format, however, works:

[[redirects]]
  from = "/calculator/test"
  to = "https://futuregerald-requestbin.herokuapp.com/pzyoldpz"
  status = 200
  force = true
  [redirects.headers]
    X-From = "netlify_test"
    x-api-key= "TEST API KEY"

Installation fails on circleci/golang:1.9 docker image

Hey guys,

in our CircleCI build we use a circleci/golang:1.9 docker image and install the netlifyctl CLI using go get github.com/netlify/netlifyctl.

Until a couple of days ago it was working fine but we now get this error:

$ go get github.com/netlify/netlifyctl
# github.com/netlify/netlifyctl/commands/deploy
/go/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:90:44: not enough arguments in call to client.WaitUntilDeployReady
	have ("github.com/netlify/netlifyctl/context".Context, *models.Deploy)
	want ("github.com/netlify/open-api/go/porcelain/context".Context, *models.Deploy, time.Duration)

Is there something wrong with the image itself or with the installation script?

Many thanks ๐Ÿ™

Ability to add comment to deploys

I am currently using this tool for manual deploys and would like to add a name/comment to manual deploys that would display on the deploys tab for an application. This is essentially a replacement for the sha / commit message that appears on the website for automated deploys.

I messaged support already and am aware that there is currently no API endpoint for this but they asked me to open an issue here so it can be tracked publicly.

enable "manual" repository setup with netlifyctl

I'm looking for the same thing that netlify init -m does using the old netlify-cli:

  • reads .git/config for repo info for directory it is init'ing
  • creates in our system a deploy key and webhook for a site and
  • tells $customer the public_key and webhook address so they can put them in place manually in their repo settings

panic: runtime error: invalid memory address or nil pointer dereference

When running netlifyctl init manual
it asks for the username (gitlab for this project)
it then pauses with no feedback

when pressing enter I get this error

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x165cf2b]

goroutine 1 [running]:
github.com/netlify/netlifyctl/vendor/github.com/xanzy/go-gitlab.(*Client).NewRequest(0xc420192000, 0x189f111, 0x4, 0x18a2b00, 0x7, 0x16ff200, 0xc4203daba0, 0xc420421680, 0x1, 0x1, ...)
        /home/david/src/github.com/netlify/netlifyctl/vendor/github.com/xanzy/go-gitlab/gitlab.go:298 +0x4b
github.com/netlify/netlifyctl/commands/init.getSession(0xc4203daba0, 0xc420421680, 0x1, 0x1, 0x0, 0x0, 0x1, 0xc4204e4570)
        /home/david/src/github.com/netlify/netlifyctl/commands/init/gitlab.go:131 +0xbc
github.com/netlify/netlifyctl/commands/init.newGitLabConfigurator(0x21f10d0, 0xc4204e4210, 0xc42051e100, 0xc4204e43f0, 0xc42051e100, 0xc420241038)
        /home/david/src/github.com/netlify/netlifyctl/commands/init/gitlab.go:33 +0x180
github.com/netlify/netlifyctl/commands/init.loadConfigurator(0x21f10d0, 0xc4204e4210, 0xc42051e100, 0x1010199, 0xc4204e4210, 0x30, 0x30)
        /home/david/src/github.com/netlify/netlifyctl/commands/init/git.go:39 +0x113
github.com/netlify/netlifyctl/commands/init.initSite(0x21f10d0, 0xc4204e4210, 0xc4204926c0, 0xc4201b9280, 0x1, 0x1, 0x1, 0xc4204e4180)
        /home/david/src/github.com/netlify/netlifyctl/commands/init/init.go:38 +0x6e6
github.com/netlify/netlifyctl/commands/middleware.ClientMiddleware.func1(0x21f10d0, 0xc4204e40f0, 0xc4204926c0, 0xc4201b9280, 0x1, 0x1, 0x142370f, 0x17c1b20)
        /home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:183 +0x339
github.com/netlify/netlifyctl/commands/middleware.AuthMiddleware.func1(0x21f10d0, 0xc4204e4090, 0xc4204926c0, 0xc4201b9280, 0x1, 0x1, 0x1d9e9e0, 0x19214b8)
        /home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:128 +0x1ca
github.com/netlify/netlifyctl/commands/middleware.LoggingMiddleware.func1(0x20097d0, 0xc420034088, 0xc4204926c0, 0xc4201b9280, 0x1, 0x1, 0xc4202a3560, 0xc420421b80)
        /home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:116 +0x1f1
github.com/netlify/netlifyctl/commands/middleware.DebugMiddleware.func1(0x20097d0, 0xc420034088, 0xc4204926c0, 0xc4201b9280, 0x1, 0x1, 0x0,0x0)
        /home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:89 +0x4bb
github.com/netlify/netlifyctl/commands/middleware.NewRunFunc.func1(0xc4204926c0, 0xc4201b9280, 0x1, 0x1, 0x0, 0x0)
        /home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:52 +0xf2
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).execute(0xc4204926c0, 0xc4201b9240, 0x1, 0x1, 0xc4204926c0, 0xc4201b9240)
        /home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:644 +0x3db
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1d8d7c0, 0x1dbb7fd, 0x189eb65, 0x3)
        /home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:734 +0x2d4
github.com/netlify/netlifyctl/commands.Execute()
        /home/david/src/github.com/netlify/netlifyctl/commands/netlify.go:41 +0x29b
main.main()
        /home/david/src/github.com/netlify/netlifyctl/main.go:16 +0x79

Request: appropriate error codes on success / failure

Hi there

Apparently this netlify go client will be the successor to the node one.

Could you please ensure that this client returns appropriate (unix) error codes, depending on success / failure? E.g. on website deploy success, return 0 else non-zero.

This makes it easier to integrate the netlify client into a large shell script.

Many thanks!

Greg

Question: How to use this lib in other go project?

We have a need to automatically deploy app from our go application.
I have tried using your app but with no success.
Is there an example of how to use it this way?

Here is the example:

package deployment

import (
  "path/filepath"

  "github.com/netlify/netlifyctl/context"
  netlify "github.com/netlify/open-api/go/porcelain"
)

// DeployApp deploys application on remote server.
func DeployApp(appID string) {
  siteID := "78cf1c0c-6834-4cd8-9b9d-ee5765ef921e"
  dir := filepath.Join("./data", appID)
  draft := false

  ctx := context.Background()
  client := context.GetClient(ctx)
  options := netlify.DeployOptions{
    SiteID:  siteID,
    Dir:     dir,
    IsDraft: draft,
  }

  client.DeploySite(ctx, options)
}

This gives me error interface conversion: interface {} is nil, not *porcelain.Netlify

Also, the alternative would be to call command using exec, but this is blocked by #42 so I'm kinda stuck. :(

segfault when deploying

reported in a support ticket. I encouraged the reporter to follow this issue.

They are running on ubuntu 14.04 64 bit.


No site configured in the netlify.toml, fetching your existing sites.

Choose a site to deploy to or 0 to create a new site.

[0] Create a new site
[1] site1
[2] site2
[3] site3
[...]
[13] site13
=> Which site? (default: 0) 2

panic: runtime error: invalid memory address or nil pointer dereference

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7f98fd]

goroutine 1 [running]:

github.com/netlify/netlifyctl/operations.AskForInput(0x8f8869, 0xb, 0x8f18e7, 0x1, 0xc42015f5b0, 0x1, 0x1, 0x0, 0x0, 0x410760, ...)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/operations/ui.go:57 +0x26d

github.com/netlify/netlifyctl/operations.ChooseOrCreateSite(0xc42012c180, 0x7f01a4f5a430, 0xc4202017a0, 0x7f01a4f5a430, 0xc4202017a0, 0x4118cc)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/operations/site.go:86 +0x4a7

github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).deploySite(0xc42041fe60, 0x7f01a4f5a470, 0xc4202017a0, 0xc420370b40, 0xc42012c100, 0x0, 0x2, 0x0, 0x0)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:48 +0x90e

github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).(github.com/netlify/netlifyctl/commands/deploy.deploySite)-fm(0x7f01a4f5a470, 0xc4202017a0, 0xc420370b40, 0xc42012c100, 0x0, 0x2, 0x7f01a4f5a430, 0xc4204efa38)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:33 +0x69

github.com/netlify/netlifyctl/commands/middleware.DebugMiddleware.func1(0x7f01a4f5a470, 0xc4202017a0, 0xc420370b40, 0xc42012c100, 0x0, 0x2, 0x0, 0x0)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:67 +0x104

github.com/netlify/netlifyctl/commands/middleware.AuthMiddleware.func1(0x7f01a4f5a470, 0xc420201710, 0xc420370b40, 0xc42012c100, 0x0, 0x2, 0x1, 0xc420201680)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:86 +0x1d4

github.com/netlify/netlifyctl/commands/middleware.ClientMiddleware.func1(0x7f01a4f5a470, 0xc420201590, 0xc420370b40, 0xc42012c100, 0x0, 0x2, 0x88ebe0, 0x7f01a4f5a3b0)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:124 +0x26b

github.com/netlify/netlifyctl/commands/middleware.LoggingMiddleware.func1(0x7f01a4f5a470, 0xc420201590, 0xc420370b40, 0xc42012c100, 0x0, 0x2, 0x8f2c24, 0x4)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:75 +0x216

github.com/netlify/netlifyctl/commands/middleware.NewRunFunc.func1(0xc420370b40, 0xc42012c100, 0x0, 0x2, 0x0, 0x0)

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:42 +0xf5

github.com/spf13/cobra.(*Command).execute(0xc420370b40, 0xc42041ffa0, 0x2, 0x2, 0xc420370b40, 0xc42041ffa0)

/home/boxofmonocles/gocode/src/github.com/spf13/cobra/command.go:643 +0x3f8

github.com/spf13/cobra.(*Command).ExecuteC(0xb4bda0, 0xb70c8b, 0x8f26e7, 0x3)

/home/boxofmonocles/gocode/src/github.com/spf13/cobra/command.go:733 +0x339

github.com/netlify/netlifyctl/commands.Execute()

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/commands/netlify.go:42 +0x2a5

main.main()

/home/boxofmonocles/gocode/src/github.com/netlify/netlifyctl/main.go:16 +0x7e

Installable package releases, NPM, brew, deb...

Since we will eventually complete the deprecation of netlify-cli, we'll need to provide netlifyctl via an npm wrapper of some sort.

I'd say this is probably blocked on #6 to give netlifyctl the same powers that netlify-cli has for site configuration instead of just deployment.

@rybit has suggested this is the eventual plan, not just a wish, but that there is no timeline for this update yet.

netlifyctl deploy crashes when output is not a TTY

I'm running netlifyctl headless, in a script executed on the end of a pipe. It looks like 0.2.0 crashes if the output isn't a TTY (?).

This is easy to demonstrate by running netlifyctl deploy ... | cat, which crashes with:

Counting objects .... 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x84ca01]

goroutine 1 [running]:
github.com/netlify/netlifyctl/operations.(*DeployObserver).OnSuccessfulStep(0xc4201526c0, 0xc4204eb5f0, 0xa, 0xc4204eb5f0)
	/home/david/src/github.com/netlify/netlifyctl/operations/deploy.go:43 +0xc1
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.walk.func1(0xc4204eb560, 0x22, 0x10559e0, 0xc420287ba0, 0x0, 0x0, 0x0, 0x0)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:480 +0x343
path/filepath.walk(0xc4204eb560, 0x22, 0x10559e0, 0xc420287ba0, 0xc4204eb4a0, 0x0, 0x0)
	/usr/local/go/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0x7ffd72860e0f, 0x17, 0x10559e0, 0xc420287a00, 0xc4204eb4a0, 0x0, 0x30)
	/usr/local/go/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x7ffd72860e0f, 0x17, 0xc4204eb4a0, 0x0, 0xc4204eb470)
	/usr/local/go/src/path/filepath/path.go:398 +0x14c
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.walk(0x7ffd72860e0f, 0x17, 0x1056920, 0xc4201526c0, 0x0, 0x0, 0xc4200c1080)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:487 +0x1be
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).DoDeploy(0xc4202845e0, 0x7fa822de02c0, 0xc4204eae70, 0xc4200ccf30, 0x0, 0xba29a0, 0xbc3d00, 0xc4204f2900)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:173 +0xc5
github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain.(*Netlify).DeploySite(0xc4202845e0, 0x7fa822de02c0, 0xc4204eae70, 0xc4204eb050, 0x24, 0x7ffd72860e0f, 0x17, 0x0, 0x0, 0x0, ...)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/netlify/open-api/go/porcelain/deploy.go:153 +0x9d
github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).deploySite(0xc4202f66c0, 0x7fa822de0280, 0xc4204eae70, 0xc420282000, 0xc4201f6280, 0x0, 0x8, 0xc4203638b0, 0x84f912)
	/home/david/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:85 +0x61b
github.com/netlify/netlifyctl/commands/deploy.(*deployCmd).(github.com/netlify/netlifyctl/commands/deploy.deploySite)-fm(0x7fa822de0280, 0xc4204eae70, 0xc420282000, 0xc4201f6280, 0x0, 0x8, 0x0, 0x10a3da0)
	/home/david/src/github.com/netlify/netlifyctl/commands/deploy/deploy.go:44 +0x69
github.com/netlify/netlifyctl/commands/middleware.DebugMiddleware.func1(0x7fa822de0280, 0xc4204eae70, 0xc420282000, 0xc4201f6280, 0x0, 0x8, 0x0, 0x0)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:87 +0x509
github.com/netlify/netlifyctl/commands/middleware.LoggingMiddleware.func1(0x7fa822de0280, 0xc4204eae10, 0xc420282000, 0xc4201f6280, 0x0, 0x8, 0x10534a0, 0xc420016320)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:113 +0x1f7
github.com/netlify/netlifyctl/commands/middleware.AuthMiddleware.func1(0x7fa822de0280, 0xc4204ead80, 0xc420282000, 0xc4201f6280, 0x0, 0x8, 0x1, 0xc4204eacc0)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:124 +0x1d4
github.com/netlify/netlifyctl/commands/middleware.ClientMiddleware.func1(0x7fa822de0200, 0xc420016320, 0xc420282000, 0xc4201f6280, 0x0, 0x8, 0xc687bd, 0x4)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:177 +0x316
github.com/netlify/netlifyctl/commands/middleware.NewRunFunc.func1(0xc420282000, 0xc4201f6280, 0x0, 0x8, 0x0, 0x0)
	/home/david/src/github.com/netlify/netlifyctl/commands/middleware/middleware.go:52 +0xf5
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).execute(0xc420282000, 0xc4201f6200, 0x8, 0x8, 0xc420282000, 0xc4201f6200)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:644 +0x3ef
github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1095c60, 0x10bf6b7, 0xc67fba, 0x3)
	/home/david/src/github.com/netlify/netlifyctl/vendor/github.com/spf13/cobra/command.go:734 +0x339
github.com/netlify/netlifyctl/commands.Execute()
	/home/david/src/github.com/netlify/netlifyctl/commands/netlify.go:41 +0x2a5
main.main()
	/home/david/src/github.com/netlify/netlifyctl/main.go:16 +0x7e

0.1.5 works fine, in comparison. (It doesn't have ac209cb, which I suspect is the problem.)

Ensure feature parity with netlify-cli

It's difficult to recommend netlifyctl to users when it doesn't quite do everything netlify-cli does. If we want to be able to deprecate netlify-cli, let's get it on the roadmap to make netlifyctl do all that we need it to.

I'd appreciate input from those in the know to start a list here of the features needed to make this complete.

In the meantime, I'll commit to writing up a doc to explain what can be done on each tool.

Replace `conf.Settings.Path` with `conf.Build.publish`

Hey guys,
the previous version of netlify.toml has:

[build]
  publish = 'dist/'

But netlifyctl now uses:

[build]
  publish = 'dist/'
[settings]
  path = 'dist/'

Perhaps we could streamline this to avoid redundancy and confusion?

s := conf.Settings
var path = s.Path
if path == "" {
path, err = ui.AskForInput("What path would you like deployed?", ".")
if err != nil {
logrus.WithError(err).Fatal("Failed to get deploy path")
}
s.Path = path
logrus.Debugf("Got new path from the user %s", s.Path)
}
if !strings.HasPrefix(s.Path, "/") {
path = filepath.Join(conf.Root(), s.Path)
logrus.Debugf("Relative path detected, going to deploy: '%s'", path)
}

deploy of a new site will overwrite the toml file

I had written a toml file with redirects in it and when I deployed it to a new site (with a new site id) it overwrote my existing file.

// edit
Further testing has shown that this overwrites it all the time.

ryan@ryan-mbp [~/go_home/src/github.com/rybit/junk/proxy-test]
$ cat netlify.toml
[Settings]
  ID = "59b0612d-9e56-407a-b958-3987c05d17fa"
  Path = "."

[[redirects]]
  origin = "/other"
  destination = "/otherpage.html"
ryan@ryan-mbp [~/go_home/src/github.com/rybit/junk/proxy-test]
$ netlifyctl deploy -D
DEBU[07 Jul 17 16:08 -0700] PreRun                                        arguments=[] command=deploy
DebugFlags called on deploy
deploy
  -A, --access-token []     [L]
  -b, --base-directory []     [L]
  -C, --config [netlify.toml]  netlify.toml   [L]
  -D, --debug [false]  true   [L]
  -d, --draft [false]  false   [L]
  -E, --endpoint [https://api.netlify.com]  https://api.netlify.com   [L]
  -h, --help [false]  false   [L]
  -m, --message []     [L]
  -y, --yes [false]  false   [L]

DEBU[07 Jul 17 16:08 -0700] Parsed configuration: {Settings:{ID:59b0612d-9e56-407a-b958-3987c05d17fa Path:.} root:/Users/ryan/go_home/src/github.com/rybit/junk/proxy-test}
DEBU[07 Jul 17 16:08 -0700] Relative path detected, going to deploy: '/Users/ryan/go_home/src/github.com/rybit/junk/proxy-test'
DEBU[07 Jul 17 16:08 -0700] deploying site                                draft=false path="/Users/ryan/go_home/src/github.com/rybit/junk/proxy-test" site=59b0612d-9e56-407a-b958-3987c05d17fa
DEBU[07 Jul 17 16:08 -0700] Starting to deploy files                      deploy_files=3 site_id=59b0612d-9e56-407a-b958-3987c05d17fa
=> Done, your website is live in http://ryan-proxy-test.netlify.com
ryan@ryan-mbp [~/go_home/src/github.com/rybit/junk/proxy-test]
$ cat netlify.toml
[Settings]
  ID = "59b0612d-9e56-407a-b958-3987c05d17fa"
  Path = "."

enable passing site ID or name via command line

Currently, the site ID must be read from the terminal (and thus entered in the toml file by netlifyctl to be used). Would be great to be able to pass this via command line!

Make sure to update the help text if this option gets added please :)

`netlifyctl dev` local testing server

There are some great Netlify-unique features that can significantly change the operation of a site, but which currently can't easily be tested on a local development machine-- particularly _headers, _redirects, and netlify.toml.

I made a little dev server for my own use which reads these files and reproduces the Netlify production behavior, and I feel like an open source version of this could be useful for others. Is this something that would make sense as a feature pull request to the Netlify CLI? Or should I release it as a standalone tool? (Or maybe this already exists and I just haven't come across it :D)

Internal support for netlifyctl at Netlify

Does this project have much support at Netlify? Seems like the pace of adding basic features is pretty slow.

For example, having decent error messages #4 has been an issue for over 18 months.

Also, the docs encourage the use of this newer, undocumented cli tool, but it seems pretty flakey. Seems better to just point to this tool as a beta.

Bug: can't programmatically use netlifyctl due to recent commit

Hi there,

This recent commit has busted my programmatic use of netlifyctl.

When I now run netlifyctl, I get:

[1] SOME-WEBSITE-prod
[2] SOME-WEBSITE-staging
=> Which site?

This is a bug, as netlifyctl already knows which website I'm deploying: I specify the appropriate website api id in the supplied config file.

The "Which site?" option means that programmatic use of netlifyctl is now busted. Everything worked until I pulled in this commit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.