-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement analytics for executor exit code.
- Loading branch information
1 parent
7a54123
commit 00ab186
Showing
10 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/ActiveState/cli/internal/svcctl/svcmsg" | ||
) | ||
|
||
func newExitCodeMessage(exitCode int) (*svcmsg.ExitCode, error) { | ||
execPath, err := os.Executable() | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot get executable info: %w", err) | ||
} | ||
return &svcmsg.ExitCode{execPath, strconv.Itoa(exitCode)}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Package svcmsg models the Exit Code data that the executor must communicate | ||
// to the service. | ||
// | ||
// IMPORTANT: This package should have minimal dependencies as it will be | ||
// imported by cmd/state-exec. The resulting compiled executable must remain as | ||
// small as possible. | ||
package svcmsg | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type ExitCode struct { | ||
ExecPath string | ||
ExitCode string | ||
} | ||
|
||
func NewExitCodeFromSvcMsg(data string) *ExitCode { | ||
var execPath, exitCode string | ||
|
||
ss := strings.SplitN(data, "<", 2) | ||
if len(ss) > 0 { | ||
execPath = ss[0] | ||
} | ||
if len(ss) > 1 { | ||
exitCode = ss[1] | ||
} | ||
|
||
return NewExitCode(execPath, exitCode) | ||
} | ||
|
||
func NewExitCode(execPath, exitCode string) *ExitCode { | ||
return &ExitCode{ | ||
ExecPath: execPath, | ||
ExitCode: exitCode, | ||
} | ||
} | ||
|
||
func (e *ExitCode) SvcMsg() string { | ||
return fmt.Sprintf("exitcode<%s<%s", e.ExecPath, e.ExitCode) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package svcmsg | ||
|
||
type Messager interface { | ||
SvcMsg() string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters