Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

feat: add output middleware to the golang template #331

Conversation

lucasdittrichzup
Copy link

Pull Request

What I did

How I did it

How to verify it

What kind of change does this PR make

  • Major
  • Minor
  • Patch

Description for the changelog

Signed-off-by: lucas.dittrich <lucas.dittrich@zup.com.br>
@lucasdittrichzup lucasdittrichzup added feature New feature or enhancement request WIP Work in Progress labels Dec 10, 2020
@lucasdittrichzup lucasdittrichzup self-assigned this Dec 10, 2020
Output map[string]interface{} `json:"output"`
}

var outputFile = RitchieDir() + "/output.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to filepath join here as well, in case the use OS is windows

Comment on lines +31 to +41
data := OutputJSON{output}
outputJSON, err := json.Marshal(data)
if err != nil {
return err
}

if err := ioutil.WriteFile(outputFile, outputJSON, os.ModePerm); err != nil {
return err
}

return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this overwriting the out file? What happens if I add a key/value at one moment, then again at another moment in code

Comment on lines +44 to +53
func ReadOutput() (OutputJSON, error) {
file, _ := ioutil.ReadFile(outputFile)

var data OutputJSON
if err := json.Unmarshal(file, &data); err != nil {
return data, err
}

return data, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if we should have a method more like getValue in which we already pass the output key and just get that specific value. Maybe we could have both, what do you think?

@lucasdittrichzup
Copy link
Author

there was a change in the implementation of this feature and this PR became unnecessary

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or enhancement request WIP Work in Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants