Skip to content

Commit

Permalink
make env url templatable
Browse files Browse the repository at this point in the history
  • Loading branch information
msiegenthaler committed Mar 1, 2021
1 parent cde1a4f commit bfd7f29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.10.0
VERSION=v0.3.1

build:
docker build -t linkyard/github-deployment-resource:$(VERSION) .
4 changes: 0 additions & 4 deletions out_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err
EnvironmentURL: request.Params.EnvironmentURL,
}

if request.Params.LogURL != nil && *request.Params.LogURL != "" {
newStatus.LogURL = request.Params.LogURL
}

fmt.Fprintln(c.writer, "creating deployment status")
_, err = c.github.CreateDeploymentStatus(*deployment.ID, newStatus)
if err != nil {
Expand Down
26 changes: 16 additions & 10 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ type OutParams struct {
Payload *map[string]interface{}
PayloadPath *string `json:"payload_path"`
LogURL *string
EnvironmentURL *string `json:"environment_url,omitempty"`
EnvironmentURL *string

RawID json.RawMessage `json:"id"`
RawState json.RawMessage `json:"state"`
RawRef json.RawMessage `json:"ref"`
RawTask json.RawMessage `json:"task"`
RawEnvironment json.RawMessage `json:"environment"`
RawDescription json.RawMessage `json:"description"`
RawAutoMerge json.RawMessage `json:"auto_merge"`
RawPayload json.RawMessage `json:"payload"`
RawLogURL json.RawMessage `json:"log_url"`
RawID json.RawMessage `json:"id"`
RawState json.RawMessage `json:"state"`
RawRef json.RawMessage `json:"ref"`
RawTask json.RawMessage `json:"task"`
RawEnvironment json.RawMessage `json:"environment"`
RawEnvironmentURL json.RawMessage `json:"environment_url"`
RawDescription json.RawMessage `json:"description"`
RawAutoMerge json.RawMessage `json:"auto_merge"`
RawPayload json.RawMessage `json:"payload"`
RawLogURL json.RawMessage `json:"log_url"`
}

// Used to avoid recursion in UnmarshalJSON below.
Expand Down Expand Up @@ -106,6 +107,11 @@ func (p *OutParams) UnmarshalJSON(b []byte) (err error) {
p.Environment = github.String(getStringOrStringFromFile(p.RawEnvironment))
}

if p.RawEnvironmentURL != nil {
envUrl := os.ExpandEnv(getStringOrStringFromFile(p.RawEnvironmentURL)) // Interpolate ENV variables
p.EnvironmentURL = github.String(envUrl)
}

if p.RawDescription != nil {
p.Description = github.String(getStringOrStringFromFile(p.RawDescription))
}
Expand Down

0 comments on commit bfd7f29

Please sign in to comment.