feat(local-config): host hash helper
This commit is contained in:
		
							
								
								
									
										28
									
								
								localconfig/host.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								localconfig/host.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					package localconfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						yaml "gopkg.in/yaml.v2"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type Host struct {
 | 
				
			||||||
 | 
						Name string
 | 
				
			||||||
 | 
						MACs []string
 | 
				
			||||||
 | 
						IPs  []string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Kernel string
 | 
				
			||||||
 | 
						Initrd string
 | 
				
			||||||
 | 
						Layers map[string]string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Config []byte
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (h *Host) WriteHashDataTo(w io.Writer) error {
 | 
				
			||||||
 | 
						return yaml.NewEncoder(w).Encode(Host{
 | 
				
			||||||
 | 
							Kernel: h.Kernel,
 | 
				
			||||||
 | 
							Initrd: h.Initrd,
 | 
				
			||||||
 | 
							Layers: h.Layers,
 | 
				
			||||||
 | 
							Config: h.Config,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -17,18 +17,6 @@ type Cluster struct {
 | 
				
			|||||||
	Addons []byte
 | 
						Addons []byte
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Host struct {
 | 
					 | 
				
			||||||
	Name string
 | 
					 | 
				
			||||||
	MACs []string
 | 
					 | 
				
			||||||
	IPs  []string
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	Kernel string
 | 
					 | 
				
			||||||
	Initrd string
 | 
					 | 
				
			||||||
	Layers map[string]string
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	Config []byte
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func FromBytes(data []byte) (*Config, error) {
 | 
					func FromBytes(data []byte) (*Config, error) {
 | 
				
			||||||
	config := &Config{}
 | 
						config := &Config{}
 | 
				
			||||||
	if err := yaml.Unmarshal(data, config); err != nil {
 | 
						if err := yaml.Unmarshal(data, config); err != nil {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user