@@ -398,7 +398,7 @@ func (g *Generator) SetProcessArgs(args []string) {
398
398
399
399
// ClearProcessEnv clears g.spec.Process.Env.
400
400
func (g * Generator ) ClearProcessEnv () {
401
- if g .spec == nil {
401
+ if g .spec == nil || g . spec . Process == nil {
402
402
return
403
403
}
404
404
g .spec .Process .Env = []string {}
@@ -440,7 +440,7 @@ func (g *Generator) AddProcessRlimits(rType string, rHard uint64, rSoft uint64)
440
440
441
441
// RemoveProcessRlimits removes a rlimit from g.spec.Process.Rlimits.
442
442
func (g * Generator ) RemoveProcessRlimits (rType string ) error {
443
- if g .spec == nil {
443
+ if g .spec == nil || g . spec . Process == nil {
444
444
return nil
445
445
}
446
446
for i , rlimit := range g .spec .Process .Rlimits {
@@ -454,15 +454,15 @@ func (g *Generator) RemoveProcessRlimits(rType string) error {
454
454
455
455
// ClearProcessRlimits clear g.spec.Process.Rlimits.
456
456
func (g * Generator ) ClearProcessRlimits () {
457
- if g .spec == nil {
457
+ if g .spec == nil || g . spec . Process == nil {
458
458
return
459
459
}
460
460
g .spec .Process .Rlimits = []rspec.POSIXRlimit {}
461
461
}
462
462
463
463
// ClearProcessAdditionalGids clear g.spec.Process.AdditionalGids.
464
464
func (g * Generator ) ClearProcessAdditionalGids () {
465
- if g .spec == nil {
465
+ if g .spec == nil || g . spec . Process == nil {
466
466
return
467
467
}
468
468
g .spec .Process .User .AdditionalGids = []uint32 {}
@@ -737,10 +737,7 @@ func (g *Generator) SetLinuxRootPropagation(rp string) error {
737
737
738
738
// ClearPreStartHooks clear g.spec.Hooks.Prestart.
739
739
func (g * Generator ) ClearPreStartHooks () {
740
- if g .spec == nil {
741
- return
742
- }
743
- if g .spec .Hooks == nil {
740
+ if g .spec == nil || g .spec .Hooks == nil {
744
741
return
745
742
}
746
743
g .spec .Hooks .Prestart = []rspec.Hook {}
@@ -787,10 +784,7 @@ func (g *Generator) AddPreStartHookTimeout(path string, timeout int) {
787
784
788
785
// ClearPostStopHooks clear g.spec.Hooks.Poststop.
789
786
func (g * Generator ) ClearPostStopHooks () {
790
- if g .spec == nil {
791
- return
792
- }
793
- if g .spec .Hooks == nil {
787
+ if g .spec == nil || g .spec .Hooks == nil {
794
788
return
795
789
}
796
790
g .spec .Hooks .Poststop = []rspec.Hook {}
@@ -837,10 +831,7 @@ func (g *Generator) AddPostStopHookTimeout(path string, timeout int) {
837
831
838
832
// ClearPostStartHooks clear g.spec.Hooks.Poststart.
839
833
func (g * Generator ) ClearPostStartHooks () {
840
- if g .spec == nil {
841
- return
842
- }
843
- if g .spec .Hooks == nil {
834
+ if g .spec == nil || g .spec .Hooks == nil {
844
835
return
845
836
}
846
837
g .spec .Hooks .Poststart = []rspec.Hook {}
@@ -976,7 +967,7 @@ func (g *Generator) SetupPrivileged(privileged bool) {
976
967
977
968
// ClearProcessCapabilities clear g.spec.Process.Capabilities.
978
969
func (g * Generator ) ClearProcessCapabilities () {
979
- if g .spec == nil {
970
+ if g .spec == nil || g . spec . Process == nil || g . spec . Process . Capabilities == nil {
980
971
return
981
972
}
982
973
g .spec .Process .Capabilities .Bounding = []string {}
0 commit comments