This repository has been archived by the owner on Apr 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: Ied4885b9a587c2cf23d3054f980d29e2b3505c20
- Loading branch information
Showing
17 changed files
with
4,823 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
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,48 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/mitchellh/mapstructure" | ||
) | ||
|
||
/* | ||
{ | ||
"type": "store", | ||
"playload": { | ||
"action": "install", | ||
"apps": [{ | ||
"name": "gedit", | ||
"packageURI": "dpk://deb/gedit" | ||
}, { | ||
"name": "deepin-music", | ||
"packageURI": "dpk://deb/deepin-music" | ||
}] | ||
} | ||
} | ||
*/ | ||
|
||
type msgInstall struct { | ||
Action string `json:"action"` | ||
Apps []struct { | ||
Name string `json:"name"` | ||
PackageURI string `json:"packageURI"` | ||
} `json:"apps"` | ||
} | ||
|
||
func (m *Metadata) handleInstall(playload map[string]interface{}) error { | ||
var msg msgInstall | ||
err := mapstructure.Decode(playload, &msg) | ||
if nil != err { | ||
logger.Errorf("decode message %v failed: %v", playload, err) | ||
return err | ||
} | ||
|
||
for _, app := range msg.Apps { | ||
packageName := strings.Replace(app.PackageURI, "dpk://deb/", "", -1) | ||
logger.Infof("install %v %v", app.Name, packageName) | ||
m.debBackend.Install(app.Name, packageName) | ||
} | ||
|
||
return nil | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/daemon/vendor/src/github.com/mitchellh/mapstructure/.travis.yml
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,8 @@ | ||
language: go | ||
|
||
go: | ||
- "1.11.x" | ||
- tip | ||
|
||
script: | ||
- go test |
21 changes: 21 additions & 0 deletions
21
src/daemon/vendor/src/github.com/mitchellh/mapstructure/CHANGELOG.md
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,21 @@ | ||
## 1.1.2 | ||
|
||
* Fix error when decode hook decodes interface implementation into interface | ||
type. [GH-140] | ||
|
||
## 1.1.1 | ||
|
||
* Fix panic that can happen in `decodePtr` | ||
|
||
## 1.1.0 | ||
|
||
* Added `StringToIPHookFunc` to convert `string` to `net.IP` and `net.IPNet` [GH-133] | ||
* Support struct to struct decoding [GH-137] | ||
* If source map value is nil, then destination map value is nil (instead of empty) | ||
* If source slice value is nil, then destination slice value is nil (instead of empty) | ||
* If source pointer is nil, then destination pointer is set to nil (instead of | ||
allocated zero value of type) | ||
|
||
## 1.0.0 | ||
|
||
* Initial tagged stable release. |
21 changes: 21 additions & 0 deletions
21
src/daemon/vendor/src/github.com/mitchellh/mapstructure/LICENSE
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2013 Mitchell Hashimoto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
46 changes: 46 additions & 0 deletions
46
src/daemon/vendor/src/github.com/mitchellh/mapstructure/README.md
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,46 @@ | ||
# mapstructure [![Godoc](https://godoc.org/github.com/mitchellh/mapstructure?status.svg)](https://godoc.org/github.com/mitchellh/mapstructure) | ||
|
||
mapstructure is a Go library for decoding generic map values to structures | ||
and vice versa, while providing helpful error handling. | ||
|
||
This library is most useful when decoding values from some data stream (JSON, | ||
Gob, etc.) where you don't _quite_ know the structure of the underlying data | ||
until you read a part of it. You can therefore read a `map[string]interface{}` | ||
and use this library to decode it into the proper underlying native Go | ||
structure. | ||
|
||
## Installation | ||
|
||
Standard `go get`: | ||
|
||
``` | ||
$ go get github.com/mitchellh/mapstructure | ||
``` | ||
|
||
## Usage & Example | ||
|
||
For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/mapstructure). | ||
|
||
The `Decode` function has examples associated with it there. | ||
|
||
## But Why?! | ||
|
||
Go offers fantastic standard libraries for decoding formats such as JSON. | ||
The standard method is to have a struct pre-created, and populate that struct | ||
from the bytes of the encoded format. This is great, but the problem is if | ||
you have configuration or an encoding that changes slightly depending on | ||
specific fields. For example, consider this JSON: | ||
|
||
```json | ||
{ | ||
"type": "person", | ||
"name": "Mitchell" | ||
} | ||
``` | ||
|
||
Perhaps we can't populate a specific structure without first reading | ||
the "type" field from the JSON. We could always do two passes over the | ||
decoding of the JSON (reading the "type" first, and the rest later). | ||
However, it is much simpler to just decode this into a `map[string]interface{}` | ||
structure, read the "type" key, then use something like this library | ||
to decode it into the proper structure. |
Oops, something went wrong.