Restore old json encoders
This commit is contained in:
@@ -129,20 +129,20 @@ pub fn (mut d Deployment) add_signature(twin u32, signature string) {
|
|||||||
signature_type: 'sr25519'
|
signature_type: 'sr25519'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn (d Deployment) json_encode() string {
|
// pub fn (d Deployment) json_encode() string {
|
||||||
return json.encode(d)
|
// return json.encode(d)
|
||||||
}
|
|
||||||
|
|
||||||
// pub fn (mut d Deployment) json_encode() string {
|
|
||||||
// mut encoded_workloads := []string{}
|
|
||||||
// for mut w in d.workloads {
|
|
||||||
// encoded_workloads << w.json_encode()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// workloads := '[${encoded_workloads.join(',')}]'
|
|
||||||
// return '{"version":${d.version},"twin_id":${d.twin_id},"contract_id":${d.contract_id},"expiration":${d.expiration},"metadata":"${d.metadata}","description":"${d.description}","workloads":${workloads},"signature_requirement":${json.encode(d.signature_requirement)}}'
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
pub fn (mut d Deployment) json_encode() string {
|
||||||
|
mut encoded_workloads := []string{}
|
||||||
|
for mut w in d.workloads {
|
||||||
|
encoded_workloads << w.json_encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
workloads := '[${encoded_workloads.join(',')}]'
|
||||||
|
return '{"version":${d.version},"twin_id":${d.twin_id},"contract_id":${d.contract_id},"expiration":${d.expiration},"metadata":"${d.metadata}","description":"${d.description}","workloads":${workloads},"signature_requirement":${json.encode(d.signature_requirement)}}'
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (dl Deployment) count_public_ips() u8 {
|
pub fn (dl Deployment) count_public_ips() u8 {
|
||||||
mut count := u8(0)
|
mut count := u8(0)
|
||||||
for wl in dl.workloads {
|
for wl in dl.workloads {
|
||||||
@@ -173,14 +173,14 @@ pub:
|
|||||||
project_name string @[json: 'projectName']
|
project_name string @[json: 'projectName']
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn (data DeploymentData) json_encode() string {
|
pub fn (data DeploymentData) json_encode() string {
|
||||||
// return "{\\\"type\\\":\\\"${data.type_}\\\",\\\"name\\\":\\\"${data.name}\\\",\\\"projectName\\\":\\\"${data.project_name}\\\"}"
|
return "{\\\"type\\\":\\\"${data.type_}\\\",\\\"name\\\":\\\"${data.name}\\\",\\\"projectName\\\":\\\"${data.project_name}\\\"}"
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn (d DeploymentData) json_encode() string {
|
|
||||||
return json.encode(d)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pub fn (d DeploymentData) json_encode() string {
|
||||||
|
// return json.encode(d)
|
||||||
|
// }
|
||||||
|
|
||||||
pub fn (mut dl Deployment) add_metadata(type_ string, project_name string) {
|
pub fn (mut dl Deployment) add_metadata(type_ string, project_name string) {
|
||||||
mut data := DeploymentData{
|
mut data := DeploymentData{
|
||||||
type_: type_
|
type_: type_
|
||||||
|
|||||||
Reference in New Issue
Block a user