Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Conversation

chungers
Copy link
Contributor

@chungers chungers commented Jan 15, 2017

This PR introduces a common type Any that models any user-defined / opaque structures in the input configuration.

Currently when a plugin defines its custom input, a Spec, this code pattern is used:

type Spec struct {
    Plugin string  // the name
    Properties *json.RawMessage // the custom blob
}

To provide better typing and a common abstraction (and not be so tightly coupled with JSON), the new pattern, including the plugin.Name introduced in #362, now look like:

type Spec struct {
    Plugin plugin.Name
    Properties *types.Any
}
  • Any has simple utility functions that help avoid boilerplate json.Marshal/Unmarshal code everywhere.
  • Provides a common object that can be used everywhere that will make support for additional formats easier in the future (e.g. YAML configs)
  • Any is currently typed aliased to json.RawMessage but this can be changed in the future without impacting code.
  • Any is similar in concept to the type Any in protobuf3.
  • Converted the Group plugin's Spec to use Any.
  • Converted the plugin launcher utility to use Any for configuration.

This PR does not change the plugin SPI where the use of json.RawMessage appears in methods like Validate. I'd like to propose that these be converted to use Any by v1.0.

David Chung added 7 commits January 14, 2017 13:36
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
…s parts of the project

Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
@codecov-io
Copy link

codecov-io commented Jan 15, 2017

Current coverage is 65.38% (diff: 60.65%)

Merging #363 into master will increase coverage by 0.22%

@@             master       #363   diff @@
==========================================
  Files            45         45          
  Lines          2167       2190    +23   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           1412       1432    +20   
- Misses          610        611     +1   
- Partials        145        147     +2   

Powered by Codecov. Last update a7d5dab...2fc3f74

@chungers chungers merged commit 3113b14 into docker-archive:master Jan 15, 2017
@chungers chungers deleted the plugin-any branch January 15, 2017 19:17
chungers pushed a commit to chungers/infrakit that referenced this pull request Sep 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants