mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-22 10:00:39 +00:00
fix empty_dir formatting
This commit is contained in:
parent
98eb77b4c5
commit
b6add0c2d9
@ -189,11 +189,17 @@ func printVolumes(w writer, v []*yaml.Volume) {
|
|||||||
s.WriteTagValue("name", v.Name)
|
s.WriteTagValue("name", v.Name)
|
||||||
if v := v.EmptyDir; v != nil {
|
if v := v.EmptyDir; v != nil {
|
||||||
s.WriteTag("temp")
|
s.WriteTag("temp")
|
||||||
|
if isEmptyDirEmpty(v) {
|
||||||
|
w.WriteByte(' ')
|
||||||
|
w.WriteByte('{')
|
||||||
|
w.WriteByte('}')
|
||||||
|
} else {
|
||||||
s.IndentIncrease()
|
s.IndentIncrease()
|
||||||
s.WriteTagValue("medium", v.Medium)
|
s.WriteTagValue("medium", v.Medium)
|
||||||
s.WriteTagValue("size_limit", v.SizeLimit)
|
s.WriteTagValue("size_limit", v.SizeLimit)
|
||||||
s.IndentDecrease()
|
s.IndentDecrease()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if v := v.HostPath; v != nil {
|
if v := v.HostPath; v != nil {
|
||||||
s.WriteTag("host")
|
s.WriteTag("host")
|
||||||
@ -263,3 +269,9 @@ func isConditionsEmpty(v yaml.Conditions) bool {
|
|||||||
func isConditionEmpty(v yaml.Condition) bool {
|
func isConditionEmpty(v yaml.Condition) bool {
|
||||||
return len(v.Exclude) == 0 && len(v.Include) == 0
|
return len(v.Exclude) == 0 && len(v.Include) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper function returns true if the emptydir
|
||||||
|
// object is empty.
|
||||||
|
func isEmptyDirEmpty(v *yaml.VolumeEmptyDir) bool {
|
||||||
|
return v.SizeLimit == 0 && len(v.Medium) == 0
|
||||||
|
}
|
||||||
|
2
yaml/pretty/testdata/pipeline_volumes.yml
vendored
2
yaml/pretty/testdata/pipeline_volumes.yml
vendored
@ -21,6 +21,8 @@ volumes:
|
|||||||
- name: temp
|
- name: temp
|
||||||
temp:
|
temp:
|
||||||
medium: memory
|
medium: memory
|
||||||
|
- name: empty
|
||||||
|
temp: {}
|
||||||
- name: sock
|
- name: sock
|
||||||
host:
|
host:
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
|
@ -25,6 +25,8 @@ volumes:
|
|||||||
- name: temp
|
- name: temp
|
||||||
temp:
|
temp:
|
||||||
medium: memory
|
medium: memory
|
||||||
|
- name: empty
|
||||||
|
temp: {}
|
||||||
- name: sock
|
- name: sock
|
||||||
host:
|
host:
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
|
Loading…
Reference in New Issue
Block a user