This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from taskcluster/bug1279019
Bug 1279019: add artifact public/logs/worker_type_metadata.json to each task
- Loading branch information
Showing
13 changed files
with
228 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/peterbourgon/mergemap" | ||
) | ||
|
||
func (c *Config) mergeInJSON(data []byte) error { | ||
// This is all HORRIBLE | ||
// but it seems about the only reasonable way to properly merge | ||
// the json schemas such that json objects are recursively merged. | ||
// Steps: convert c to json and then back to a go type, so that | ||
// it is a map[string]interface{} and not a Config type. Get | ||
// the json bytes also into a map[string]interface{} so that | ||
// the two map[string]interface{} objects can be merged. Finally | ||
// convert the merge result to json again so that it can be | ||
// marshaled back into the original Config type... Yuck! | ||
m1 := new(map[string]interface{}) | ||
m2 := new(map[string]interface{}) | ||
m1bytes, err := json.Marshal(c) | ||
if err != nil { | ||
return err | ||
} | ||
err = json.Unmarshal(m1bytes, m1) | ||
if err != nil { | ||
return err | ||
} | ||
err = json.Unmarshal(data, m2) | ||
if err != nil { | ||
return err | ||
} | ||
merged := mergemap.Merge(*m1, *m2) | ||
mergedBytes, err := json.Marshal(merged) | ||
if err != nil { | ||
return err | ||
} | ||
return json.Unmarshal(mergedBytes, c) | ||
} |
Oops, something went wrong.