Skip to content

Commit 4b534ac

Browse files
Merge pull request #79 from OpenCHAMI/synackd/add-yaml-tags
fix: add missing YAML reflect tags
2 parents 4d5d465 + 5e5f0e1 commit 4b534ac

8 files changed

Lines changed: 39 additions & 39 deletions

File tree

cmd/cloud-init-server/version.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
9191
runtime.ReadMemStats(memstats)
9292

9393
response := struct {
94-
ProcessName string `json:"process_name"`
95-
BuildInfo string `json:"build_info"`
96-
Uptime string `json:"uptime"`
97-
RuntimeHost string `json:"runtime_host"`
98-
BytesAllocated uint64 `json:"bytes_allocated"`
94+
ProcessName string `json:"process_name" yaml:"process_name"`
95+
BuildInfo string `json:"build_info" yaml:"build_info"`
96+
Uptime string `json:"uptime" yaml:"uptime"`
97+
RuntimeHost string `json:"runtime_host" yaml:"runtime_host"`
98+
BytesAllocated uint64 `json:"bytes_allocated" yaml:"bytes_allocated"`
9999
}{
100100
ProcessName: processName,
101101
BuildInfo: info,

internal/memstore/ciMemStore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
type MemStore struct {
14-
Groups map[string]cistore.GroupData `json:"groups,omitempty"`
14+
Groups map[string]cistore.GroupData `json:"groups,omitempty" yaml:"groups,omitempty"`
1515
GroupsMutex sync.RWMutex
1616
Instances map[string]cistore.OpenCHAMIInstanceInfo
1717
InstancesMutex sync.RWMutex

internal/smdclient/FakeSMDClient_handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
type OpenCHAMINodeWithGroups struct {
1313
cistore.OpenCHAMIComponent
14-
Groups []string `json:"groups,omitempty"`
14+
Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
1515
}
1616

1717
func AddNodeToInventoryHandler(f *FakeSMDClient) http.HandlerFunc {

internal/smdclient/SMDclient.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ type SMDClient struct {
5757
}
5858

5959
type NodeInterface struct {
60-
MAC string `json:"mac"`
61-
IP string `json:"ip"`
62-
WGIP string `json:"wgip"`
63-
Desc string `json:"description"`
60+
MAC string `json:"mac" yaml:"mac"`
61+
IP string `json:"ip" yaml:"ip"`
62+
WGIP string `json:"wgip" yaml:"wgip"`
63+
Desc string `json:"description" yaml:"description"`
6464
}
6565

6666
type NodeMapping struct {
67-
Xname string `json:"xname"`
68-
Interfaces []NodeInterface `json:"interfaces"`
67+
Xname string `json:"xname" yaml:"xname"`
68+
Interfaces []NodeInterface `json:"interfaces" yaml:"interfaces"`
6969
}
7070

7171
// NewSMDClient creates a new SMDClient which connects to the SMD server at baseurl

internal/smdclient/oidc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88

99
// Structure of a token reponse from OIDC server
1010
type oidcTokenData struct {
11-
Access_token string `json:"access_token"`
12-
Expires_in int `json:"expires_in"`
13-
Scope string `json:"scope"`
14-
Token_type string `json:"token_type"`
11+
Access_token string `json:"access_token" yaml:"access_token"`
12+
Expires_in int `json:"expires_in" yaml:"expires_in"`
13+
Scope string `json:"scope" yaml:"scope"`
14+
Token_type string `json:"token_type" yaml:"token_type"`
1515
}
1616

1717
// Refresh the cached access token, using the provided JWT server

pkg/cistore/models.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
)
1212

1313
type GroupData struct {
14-
Name string `json:"name" example:"compute" description:"Group name"`
15-
Description string `json:"description,omitempty" example:"The compute group" description:"A short description of the group"`
16-
Data map[string]interface{} `json:"meta-data,omitempty" description:"json map of a string (key) to a struct (value) representing group meta-data"`
17-
File CloudConfigFile `json:"file,omitempty" description:"Cloud-Init configuration for group"`
14+
Name string `json:"name" yaml:"name" example:"compute" description:"Group name"`
15+
Description string `json:"description,omitempty" yaml:"description,omitempty" example:"The compute group" description:"A short description of the group"`
16+
Data map[string]interface{} `json:"meta-data,omitempty" yaml:"meta-data,omitempty" description:"json map of a string (key) to a struct (value) representing group meta-data"`
17+
File CloudConfigFile `json:"file,omitempty" yaml:"file,omitempty" description:"Cloud-Init configuration for group"`
1818
}
1919

2020
func (g *GroupData) ParseFromJSON(body []byte) error {
@@ -33,13 +33,13 @@ func (g *GroupData) ParseFromJSON(body []byte) error {
3333

3434
type OpenCHAMIComponent struct {
3535
base.Component
36-
MAC string `json:"mac"` // MAC address of the inteface used to boot the component
37-
IP string `json:"ip"` // IP address of the interface used to boot the component
38-
WGIP string `json:"wgip,omitempty"` // Wireguard IP address of the interface used for cloud-init
36+
MAC string `json:"mac" yaml:"mac"` // MAC address of the inteface used to boot the component
37+
IP string `json:"ip" yaml:"ip"` // IP address of the interface used to boot the component
38+
WGIP string `json:"wgip,omitempty" yaml:"wgip,omitempty"` // Wireguard IP address of the interface used for cloud-init
3939
}
4040

4141
type OpenCHAMIInstanceInfo struct {
42-
ID string `json:"id" example:"x3000c1b1n1" description:"Node unique identifier, on systems that support xnames, this will be an xname which includes location information"`
42+
ID string `json:"id" yaml:"id" example:"x3000c1b1n1" description:"Node unique identifier, on systems that support xnames, this will be an xname which includes location information"`
4343
InstanceID string `json:"instance-id" yaml:"instance-id"`
4444
LocalHostname string `json:"local-hostname,omitempty" yaml:"local-hostname" example:"compute-1" description:"Node-specific hostname"`
4545
Hostname string `json:"hostname,omitempty" yaml:"hostname"`
@@ -85,7 +85,7 @@ func (f *CloudConfigFile) UnmarshalJSON(data []byte) error {
8585
// to f.Content.
8686
type Alias CloudConfigFile
8787
aux := &struct {
88-
Content string `json:"content"`
88+
Content string `json:"content" yaml:"content"`
8989
*Alias
9090
}{
9191
Alias: (*Alias)(f),
@@ -116,7 +116,7 @@ func (f *CloudConfigFile) UnmarshalYAML(n *yaml.Node) error {
116116
// to f, so we have to use json.Unmarshal.
117117
type Alias CloudConfigFile
118118
aux := &struct {
119-
Content string `json:"content"`
119+
Content string `json:"content" yaml:"content"`
120120
*Alias
121121
}{
122122
Alias: (*Alias)(f),
@@ -158,7 +158,7 @@ func (f CloudConfigFile) MarshalJSON() ([]byte, error) {
158158
// to prevent this. Then, aux gets marshalled instead of f.
159159
type Alias CloudConfigFile
160160
aux := &struct {
161-
Content string `json:"content"`
161+
Content string `json:"content" yaml:"content"`
162162
Alias
163163
}{
164164
Alias: (Alias)(f),

pkg/wgtunnel/handlers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ import (
1313

1414
// PublicKeyRequest represents the JSON payload for a WireGuard public key.
1515
type PublicKeyRequest struct {
16-
PublicKey string `json:"public_key" example:"9NS6+NR0J38SZ9IlY9hBDLs6aBpNDhxHUHL8OTlNEDU=" description:"WireGuard public key content"`
16+
PublicKey string `json:"public_key" yaml:"public_key" example:"9NS6+NR0J38SZ9IlY9hBDLs6aBpNDhxHUHL8OTlNEDU=" description:"WireGuard public key content"`
1717
}
1818

1919
// WGResponse represents the JSON payload for a response from the WireGuard
2020
// server.
2121
type WGResponse struct {
22-
Message string `json:"message" example:"WireGuard tunnel created successfully"`
23-
ClientVPNIP string `json:"client-vpn-ip" example:"10.89.0.7" description:"Assigned WireGuard VPN IP address"`
24-
ServerPubKey string `json:"server-public-key" example:"dHMOGL8vTGhTgqXyYdu6cLGXEPmTcWm+vS18GcQseyg="`
25-
ServerIP string `json:"server-ip" example:"10.87.0.1" description:"WireGuard server IP"`
26-
ServerPort string `json:"server-port" example:"51820" description:"WireGuard server port"`
22+
Message string `json:"message" yaml:"message" example:"WireGuard tunnel created successfully"`
23+
ClientVPNIP string `json:"client-vpn-ip" yaml:"client-vpn-ip" example:"10.89.0.7" description:"Assigned WireGuard VPN IP address"`
24+
ServerPubKey string `json:"server-public-key" yaml:"server-public-key" example:"dHMOGL8vTGhTgqXyYdu6cLGXEPmTcWm+vS18GcQseyg="`
25+
ServerIP string `json:"server-ip" yaml:"server-ip" example:"10.87.0.1" description:"WireGuard server IP"`
26+
ServerPort string `json:"server-port" yaml:"server-port" example:"51820" description:"WireGuard server port"`
2727
}
2828

2929
// AddClientHandler godoc

pkg/wgtunnel/tunnels.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import (
1313
)
1414

1515
type PeerConfig struct {
16-
PublicKey string `json:"public_key"`
17-
IP net.IPAddr `json:"ip"`
16+
PublicKey string `json:"public_key" yaml:"public_key"`
17+
IP net.IPAddr `json:"ip" yaml:"ip"`
1818
}
1919

2020
type ServerConfig struct {
21-
PublicKey string `json:"public_key"`
22-
IP string `json:"ip"`
23-
Port string `json:"port"`
21+
PublicKey string `json:"public_key" yaml:"public_key"`
22+
IP string `json:"ip" yaml:"ip"`
23+
Port string `json:"port" yaml:"port"`
2424
}
2525

2626
type Store interface {

0 commit comments

Comments
 (0)