Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #41 from hatchet-dev/belanger/set-module-monitor-c…
Browse files Browse the repository at this point in the history
…orrectly

Set module monitor in runner env properly
  • Loading branch information
abelanger5 authored Mar 24, 2023
2 parents 669b7d6 + be89e66 commit 8904b3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/provisioner/local/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (l *LocalProvisioner) getMonitorFunc(opts *provisioner.ProvisionOpts, monit
env := opts.Env
env = append(env, cmdProv.Environ()...)

env = append(env, fmt.Sprintf("MODULE_MONITOR_ID=%s", monitorID))
env = append(env, fmt.Sprintf("RUNNER_MODULE_MONITOR_ID=%s", monitorID))

env = append(env, "PATH=/usr/local/bin:/usr/bin:/bin")

Expand Down
10 changes: 9 additions & 1 deletion internal/runner/action/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func RunMonitorFunc(f MonitorFunc, action *RunnerAction, rc *runner.Config) (str
}

func DownloadMonitorPolicy(config *runner.Config) ([]byte, error) {
resp, _, err := config.FileClient.GetMonitorPolicy(config.ConfigFile.Resources.TeamID, config.ConfigFile.Resources.ModuleMonitorID)
resp, apiErr, err := config.FileClient.GetMonitorPolicy(config.ConfigFile.Resources.TeamID, config.ConfigFile.Resources.ModuleMonitorID)

if resp != nil {
defer resp.Close()
Expand All @@ -65,5 +65,13 @@ func DownloadMonitorPolicy(config *runner.Config) ([]byte, error) {
return nil, err
}

if apiErr != nil {
return nil, fmt.Errorf(apiErr.Description)
}

if resp == nil {
return nil, fmt.Errorf("empty body from server")
}

return ioutil.ReadAll(resp)
}

0 comments on commit 8904b3f

Please sign in to comment.