vmware / vic

vSphere Integrated Containers Engine is a container runtime for vSphere.
http://vmware.github.io/vic
Other
640 stars 173 forks source link

add inline annotation to pkg/vsphere/extraconfig #1145

Open hickeng opened 8 years ago

hickeng commented 8 years ago

Basic struct composition is simple and handled well by the extraConfig package:

type ContainerNetwork struct {
  metadata.ContainerNetwork
  PortGroup object.NetworkReference
}

referencing that extended struct in place of the base type, such as:

type Configuration struct { 
    // The default bridge network supplied for the Virtual Container Host 
    BridgeNetwork string `vic:"0.1" scope:"read-only" key:"bridge_network"` 
    // Published networks available for containers to join, keyed by consumption name 
    ContainerNetworks map[string]*ContainerNetwork `vic:"0.1" scope:"read-only" key:"container_networks"` 
}

is more problematic - this is because when walking that structure with reflection the ContainerNetwork structure appears as deeper in the hierarchy and the generated keys reflect this - the contents of metadata.ContainerNetwork would be keyed as: ./container_networks|mapkey/ContainerNetwork/... instead of ./container_networks|mapkey/...

To address this we need an inline annotation that inhibits that extra depth - a naïve implementation is very simple, but a correct one will need to check for name collisions with the extended struct. While there are ways to do so a fault if detected instead of trying to handle it neatly is preferable on the first pass.

type ContainerNetwork struct {
  metadata.ContainerNetwork `vic:"0.1" scope:"read-only" recurse:"inline"` 
  PortGroup object.NetworkReference
}
mdubya66 commented 8 years ago

Moving to Icebox per 9/20 Triage

mdubya66 commented 7 years ago

marking low for 1.1. raise if required.