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

Fix bug where name was not added to the manifest #143

Merged
merged 2 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/compute/compute_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ func TestInit(t *testing.T) {
"Updating package manifest...",
},
},
{
name: "with default name inferred from directory",
args: []string{"compute", "init"},
configFile: config.File{Token: "123"},
api: mock.API{
GetTokenSelfFn: tokenOK,
GetUserFn: getUserOk,
CreateServiceFn: createServiceOK,
CreateDomainFn: createDomainOK,
CreateBackendFn: createBackendOK,
},
manifestIncludes: `name = "fastly-build`,
},
} {
t.Run(testcase.name, func(t *testing.T) {
// We're going to chdir to an init environment,
Expand Down
9 changes: 5 additions & 4 deletions pkg/compute/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ func (c *InitCommand) Exec(in io.Reader, out io.Writer) (err error) {
c.path = abspath

if name == "" {
name = filepath.Base(c.path)
fmt.Fprintf(progress, "--name not specified, using %s\n\n", name)
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to keep the verbose output here.

Copy link
Member Author

Choose a reason for hiding this comment

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

None of the other options that have defaults show this and the message is incorrect since this is not necessarily the name you will end up using so I think removing this is better.


name, err = text.Input(out, fmt.Sprintf("Name: [%s] ", name), in)
defaultName := filepath.Base(c.path)
name, err = text.Input(out, fmt.Sprintf("Name: [%s] ", defaultName), in)
if err != nil {
return fmt.Errorf("error reading input: %w", err)
}
if name == "" {
name = defaultName
}
}

if description == "" {
Expand Down