1package api
2
3import "encoding/json"
4
5type MeshConfigEntry struct {
6	Namespace        string                     `json:",omitempty"`
7	TransparentProxy TransparentProxyMeshConfig `alias:"transparent_proxy"`
8	Meta             map[string]string          `json:",omitempty"`
9	CreateIndex      uint64
10	ModifyIndex      uint64
11}
12
13type TransparentProxyMeshConfig struct {
14	MeshDestinationsOnly bool `alias:"mesh_destinations_only"`
15}
16
17func (e *MeshConfigEntry) GetKind() string {
18	return MeshConfig
19}
20
21func (e *MeshConfigEntry) GetName() string {
22	return MeshConfigMesh
23}
24
25func (e *MeshConfigEntry) GetNamespace() string {
26	return e.Namespace
27}
28
29func (e *MeshConfigEntry) GetMeta() map[string]string {
30	return e.Meta
31}
32
33func (e *MeshConfigEntry) GetCreateIndex() uint64 {
34	return e.CreateIndex
35}
36
37func (e *MeshConfigEntry) GetModifyIndex() uint64 {
38	return e.ModifyIndex
39}
40
41// MarshalJSON adds the Kind field so that the JSON can be decoded back into the
42// correct type.
43func (e *MeshConfigEntry) MarshalJSON() ([]byte, error) {
44	type Alias MeshConfigEntry
45	source := &struct {
46		Kind string
47		*Alias
48	}{
49		Kind:  MeshConfig,
50		Alias: (*Alias)(e),
51	}
52	return json.Marshal(source)
53}
54