Skip to content

Commit

Permalink
add an out script
Browse files Browse the repository at this point in the history
  • Loading branch information
mtharrison committed Jul 9, 2020
1 parent ef17249 commit b68c297
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/resource/input.go
Expand Up @@ -61,6 +61,17 @@ func (i *Input) Validate(requireVersion bool) error {
return nil
}

// PutInput is provided to the out script on STDIN
type PutInput struct {
Source *Source `json:"source"`
Params *PutParams `json:"params"`
}

// PutParams are the params that can be provided in a 'put' step
type PutParams struct {
CommentFile string `json:"comment_file"`
}

// Source is the configurable settings a user provides to this resource
type Source struct {
RepositoryString string `json:"repository"`
Expand Down Expand Up @@ -100,6 +111,23 @@ func GetInput(reader io.Reader, requireVersion bool) (Input, error) {
return input, nil
}

// GetPutInput takes a reader and constructs a PutInput
func GetPutInput(reader io.Reader) (PutInput, error) {
input := PutInput{}

rawInput, err := ioutil.ReadAll(reader)
if err != nil {
return input, err
}

err = json.Unmarshal(rawInput, &input)
if err != nil {
return input, err
}

return input, nil
}

func readInput(reader io.Reader) (Input, error) {
var input Input

Expand Down

0 comments on commit b68c297

Please sign in to comment.