github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/imagepublishers/amipublisher/marshal.go (about)

     1  package amipublisher
     2  
     3  import (
     4  	"encoding/json"
     5  )
     6  
     7  func (v InstanceResult) marshalJSON() ([]byte, error) {
     8  	errString := ""
     9  	if v.Error != nil {
    10  		errString = v.Error.Error()
    11  	}
    12  	val := struct {
    13  		AccountName string
    14  		Region      string
    15  		InstanceId  string `json:",omitempty"`
    16  		PrivateIp   string `json:",omitempty"`
    17  		Error       string `json:",omitempty"`
    18  	}{v.AccountName, v.Region, v.InstanceId, v.PrivateIp, errString}
    19  	return json.Marshal(val)
    20  }
    21  
    22  func (v TargetResult) marshalJSON() ([]byte, error) {
    23  	errString := ""
    24  	if v.Error != nil {
    25  		errString = v.Error.Error()
    26  	}
    27  	val := struct {
    28  		AccountName    string
    29  		Region         string
    30  		SharedFrom     string `json:",omitempty"`
    31  		SnapshotId     string `json:",omitempty"`
    32  		S3Bucket       string `json:",omitempty"`
    33  		S3ManifestFile string `json:",omitempty"`
    34  		AmiId          string `json:",omitempty"`
    35  		Size           uint   `json:",omitempty"`
    36  		Error          string `json:",omitempty"`
    37  	}{v.AccountName, v.Region, v.SharedFrom, v.SnapshotId, v.S3Bucket,
    38  		v.S3ManifestFile, v.AmiId, v.Size, errString}
    39  	return json.Marshal(val)
    40  }