Skip to content
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
16 changes: 15 additions & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,14 @@ func (s *ScalewayAPI) GetResponse(resource string) (*http.Response, error) {
req.Header.Set("Content-Type", "application/json")

curl, err := http2curl.GetCurlCommand(req)
if err != nil {
return nil, err
}
if os.Getenv("SCW_SENSITIVE") != "1" {
log.Debug(s.HideAPICredentials(curl.String()))
} else {
log.Debug(curl.String())
}

return s.client.Do(req)
}

Expand All @@ -663,6 +665,9 @@ func (s *ScalewayAPI) PostResponse(resource string, data interface{}) (*http.Res
req.Header.Set("Content-Type", "application/json")

curl, err := http2curl.GetCurlCommand(req)
if err != nil {
return nil, err
}
if os.Getenv("SCW_SENSITIVE") != "1" {
log.Debug(s.HideAPICredentials(curl.String()))
} else {
Expand All @@ -689,6 +694,9 @@ func (s *ScalewayAPI) PatchResponse(resource string, data interface{}) (*http.Re
req.Header.Set("Content-Type", "application/json")

curl, err := http2curl.GetCurlCommand(req)
if err != nil {
return nil, err
}
if os.Getenv("SCW_SENSITIVE") != "1" {
log.Debug(s.HideAPICredentials(curl.String()))
} else {
Expand All @@ -715,6 +723,9 @@ func (s *ScalewayAPI) PutResponse(resource string, data interface{}) (*http.Resp
req.Header.Set("Content-Type", "application/json")

curl, err := http2curl.GetCurlCommand(req)
if err != nil {
return nil, err
}
if os.Getenv("SCW_SENSITIVE") != "1" {
log.Debug(s.HideAPICredentials(curl.String()))
} else {
Expand All @@ -736,6 +747,9 @@ func (s *ScalewayAPI) DeleteResponse(resource string) (*http.Response, error) {
req.Header.Set("Content-Type", "application/json")

curl, err := http2curl.GetCurlCommand(req)
if err != nil {
return nil, err
}
if os.Getenv("SCW_SENSITIVE") != "1" {
log.Debug(s.HideAPICredentials(curl.String()))
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func RunCommit(ctx CommandContext, args CommitArgs) error {
if err != nil {
return fmt.Errorf("Cannot create snapshot: %v", err)
}
fmt.Println(snapshot)
fmt.Fprintln(ctx.Stdout, snapshot)
return nil
}
2 changes: 1 addition & 1 deletion pkg/commands/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RunEvents(ctx CommandContext, args EventsArgs) error {
terminatedAt = units.HumanDuration(time.Now().UTC().Sub(terminatedAtTime))
}

fmt.Printf("%s %s: %s (%s %d) %s\n", startedAt, event.HrefFrom, event.Description, event.Status, event.Progress, terminatedAt)
fmt.Fprintf(ctx.Stdout, "%s %s: %s (%s %d) %s\n", startedAt, event.HrefFrom, event.Description, event.Status, event.Progress, terminatedAt)
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/commands/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func RunInfo(ctx CommandContext, args InfoArgs) error {
if err != nil {
return err
} else {
fmt.Fprintf(ctx.Stdout, " [%d] %s", id, fingerprint)
fmt.Fprintf(ctx.Stdout, " [%d] %s\n", id, fingerprint)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ func getToken(connect api.ScalewayConnect) (string, error) {
if err != nil {
return "", fmt.Errorf("unable to connect %v", err)
}
defer resp.Body.Close()

// Succeed POST code
if resp.StatusCode != 201 {
return "", fmt.Errorf("[%d] maybe your email or your password is not valid", resp.StatusCode)
}
var data api.ScalewayConnectResponse

defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body)
err = decoder.Decode(&data)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion pkg/commands/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func RunTop(ctx CommandContext, args TopArgs) error {
sshCommand := utils.NewSSHExecCmd(server.PublicAddress.IP, server.PrivateIP, true, []string{command}, gateway)
logrus.Debugf("Executing: %s", sshCommand)
out, err := exec.Command("ssh", sshCommand.Slice()[1:]...).CombinedOutput()
fmt.Printf("%s", out)
if err != nil {
fmt.Fprintf(ctx.Stdout, "%s", out)
}
return err
}