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

Instance + Flavor Plugin SPI Changes #371

Merged
merged 15 commits into from
Feb 1, 2017

Conversation

chungers
Copy link
Contributor

This PR introduces the following incompatible API changes to the Instance and Flavor Plugins:

New Label() Method Requirement for Instance Plugin

Addition of a new Label() method requirement on the Instance Plugin SPI. This adds a new requirement for Instance plugins to implement method for labeling / tagging a resource:

type Plugin interface {
    // existing methods
    Label(instance instance.ID, labels map[string]string) error
}
  • This new method is necessary to support features for InfraKit to "import" (or assimilate) resources that have been created outside of InfraKit.
  • It is also needed to ensure bootstrapping node is labeled properly to address some issues with rolling updates.

Use *types.Any instead of *json.RawMessage

  • Replace *json.RawMessage in the methods of Flavor and Instance plugin methods with *types.Any.
  • Makes consistent use of pointers in method parameters throughout and standardizes on a single abstraction of types.Any to represent user-defined, opaque structs.
  • Removes lots of boilerplate code for JSON unmarshalling.
  • This will make it easier to support other formats (e.g. YAML or GRPC) since we only need to change the encoding and decoding of data in a single location.

INSTANCE PLUGIN DEVELOPERS
Instead of the following boilerplate code

func (p *myPlugin) Validate(spec *json.RawMessage) error {
    mySpec := someStruct{}
    err := json.Unmarshal([]byte(*spec), &mySpec)
    if err != nil {
       return err
    }
    // ....  Do validate
}    

Use this instead:

func (p *myPlugin) Validate(spec *types.Any) error {
    mySpec := someStruct{}
    err := spec.Decode(&mySpec)
    if err != nil {
       return err
    }
    // ....  Do validate
}    

David Chung added 2 commits January 25, 2017 11:48
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "spi-tagging" git@github.com:chungers/infrakit.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353855840
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

David Chung added 2 commits January 26, 2017 22:31
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 27, 2017

Codecov Report

Merging #371 into master will increase coverage by -2.77%.

@@            Coverage Diff             @@
##           master     #371      +/-   ##
==========================================
- Coverage   66.34%   63.57%   -2.77%     
==========================================
  Files          47       52       +5     
  Lines        2371     2817     +446     
==========================================
+ Hits         1573     1791     +218     
- Misses        629      805     +176     
- Partials      169      221      +52
Impacted Files Coverage Δ
pkg/plugin/group/types/types.go 32.35% <ø> (+6.77%)
pkg/rpc/group/service.go 66.66% <ø> (ø)
pkg/rpc/server/reflector.go 68.05% <ø> (ø)
pkg/types/any.go 70.45% <ø> (-7.05%)
examples/instance/terraform/softlayer.go 100% <100%> (ø)
pkg/plugin/group/scaled.go 70% <100%> (-1.7%)
pkg/rpc/instance/client.go 94.28% <100%> (+0.95%)
pkg/rpc/flavor/client.go 93.93% <100%> (ø)
pkg/plugin/group/group.go 68.29% <25%> (ø)
examples/flavor/combo/flavor.go 51.31% <27.27%> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9b8799...c990220. Read the comment docs.

David Chung added 5 commits January 26, 2017 23:42
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>
Signed-off-by: David Chung <david.chung@docker.com>
@chungers chungers changed the title [Work in Progress] - Instance + Flavor Plugin SPI Changes Instance + Flavor Plugin SPI Changes Jan 30, 2017
@chungers chungers added this to the v0.3 milestone Jan 31, 2017
@chungers chungers removed the v0.3 label Jan 31, 2017
@chungers chungers merged commit 478b0e2 into docker-archive:master Feb 1, 2017
chungers pushed a commit to chungers/infrakit that referenced this pull request Sep 30, 2017
* Fixed swarm inquiry

Signed-off-by: French Ben <frenchben@docker.com>

* Fixed time format

Signed-off-by: French Ben <frenchben@docker.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants