-
Notifications
You must be signed in to change notification settings - Fork 72
feat: add output middleware to the golang template #331
feat: add output middleware to the golang template #331
Conversation
Signed-off-by: lucas.dittrich <lucas.dittrich@zup.com.br>
Output map[string]interface{} `json:"output"` | ||
} | ||
|
||
var outputFile = RitchieDir() + "/output.json" |
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
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
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 | ||
} |
There was a problem hiding this comment.
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?
there was a change in the implementation of this feature and this PR became unnecessary |
Pull Request
What I did
How I did it
How to verify it
What kind of change does this PR make
Description for the changelog