-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
168 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
artifacts/ | ||
.DS_STORE | ||
.*.swp |
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,32 @@ | ||
# Contributing | ||
|
||
Thank you for considering contributing! There are many ways you can help. | ||
|
||
## Issues | ||
|
||
File an issue if you think you've found a bug. Be sure to describe | ||
|
||
1. How can it be reproduced? | ||
2. What did you expect? | ||
3. What actually occurred? | ||
4. Version, platform, etc. if possibly relevant. | ||
|
||
## Docs | ||
|
||
Documentation, READMEs, and examples are extremely important. Please help improve them and if you find a typo or notice a problem, please send a fix or say something. | ||
|
||
## Submitting Patches | ||
|
||
Patches for fixes, features, and improvements are accepted through pull requests. | ||
|
||
* Write good commit messages, in the present tense! (Add X, not Added X). Short title, blank line, bullet points if needed. Capitalize the first letter of the title or bullet item. No punctuation in the title. | ||
* Code must pass lint and style checks. | ||
* All external methods must be documented. | ||
* Include tests to improve coverage and prevent regressions. | ||
* Squash changes into a single commit per feature/fix. Ask if you're unsure how to discretize your work. | ||
|
||
Please ask before embarking on a large improvement so you're not disappointed if it does not align with the goals of the project or owner(s). | ||
|
||
## Feature Requests | ||
|
||
Make the case for a feature via an issue with a good title. The feature should be discussed and given a target inclusion milestone or closed. |
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,24 @@ | ||
Copyright 2016 Yahoo Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of the Yahoo! Inc. nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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 |
---|---|---|
@@ -1,2 +1,15 @@ | ||
# launcher | ||
The entrypoint for job launching in Screwdriver. | ||
# Screwdriver Job Launcher | ||
[![Build Status][wercker-image]][wercker-url] [![Open Issues][issues-image]][issues-url] | ||
|
||
> The entrypoint for job launching in Screwdriver. | ||
## Usage | ||
|
||
## License | ||
|
||
Code licensed under the BSD 3-Clause license. See LICENSE file for terms. | ||
|
||
[issues-image]: https://img.shields.io/github/issues/screwdriver-cd/launcher.svg | ||
[issues-url]: https://github.com/screwdriver-cd/launcher/issues | ||
[wercker-image]: https://app.wercker.com/status/822503b7af879d54018006aeafb317ae | ||
[wercker-url]: https://app.wercker.com/project/bykey/822503b7af879d54018006aeafb317ae |
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,41 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
type shellOutInterface interface { | ||
run(string, ...string) ([]byte, error) | ||
} | ||
|
||
var shellOut shellOutInterface | ||
|
||
type shellOutImpl struct{} | ||
|
||
func init() { | ||
shellOut = shellOutImpl{} | ||
} | ||
|
||
func (s shellOutImpl) run(cmd string, args ...string) (out []byte, err error) { | ||
return exec.Command(cmd, args...).CombinedOutput() | ||
} | ||
|
||
func runLauncher(args ...string) (out []byte, err error) { | ||
cmdName := "/opt/screwdriver/launch.sh" | ||
return shellOut.run(cmdName, args...) | ||
} | ||
|
||
func main() { | ||
var out []byte | ||
var err error | ||
|
||
fmt.Println("Launching the launcher...") | ||
if out, err = runLauncher(os.Args[1:]...); err != nil { | ||
fmt.Fprintln(os.Stderr, "There was an error shelling out to the launcher: ", err) | ||
os.Exit(1) | ||
} | ||
fmt.Println(string(out)) | ||
fmt.Println("Launched successfully.") | ||
} |
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 main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
var shellOutSetup map[string]string | ||
|
||
type shellOutMock struct{} | ||
|
||
func (s shellOutMock) run(cmd string, args ...string) (out []byte, err error) { | ||
cmdslice := []string{cmd} | ||
cmdslice = append(cmdslice, args...) | ||
|
||
cmd = strings.Join(cmdslice, " ") | ||
output := shellOutSetup[cmd] | ||
if output == "" { | ||
return nil, fmt.Errorf("Error: %s not mocked", cmd) | ||
} | ||
|
||
return []byte(output), nil | ||
} | ||
|
||
func Test(t *testing.T) { | ||
shellOut = shellOutMock{} | ||
|
||
shellOutSetup = map[string]string{ | ||
"/opt/screwdriver/launch.sh abc": "abc", | ||
} | ||
|
||
output, err := runLauncher("abc") | ||
if string(output) != shellOutSetup["/opt/screwdriver/launch.sh abc"] { | ||
errmsg := fmt.Sprintf("Expected %s, got %s", shellOutSetup["echo"], output) | ||
t.Error(errmsg) | ||
} | ||
if err != nil { | ||
errmsg := fmt.Sprintf("Error running command: %s", err) | ||
t.Error(errmsg) | ||
} | ||
} |
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,11 @@ | ||
box: google/golang | ||
|
||
build: | ||
steps: | ||
- script: | ||
name: go test | ||
code: go test ./... | ||
|
||
- script: | ||
name: go build | ||
code: go build launch.go |