@@ -912,20 +912,15 @@ func (g *Generator) ClearPreStartHooks() {
912
912
}
913
913
914
914
// AddPreStartHook add a prestart hook into g.spec.Hooks.Prestart.
915
- func (g * Generator ) AddPreStartHook (hookObject string ) error {
915
+ func (g * Generator ) AddPreStartHook (preStartHook rspec. Hook ) error {
916
916
g .initSpecHooks ()
917
- tmpHook := rspec.Hook {}
918
- err := json .Unmarshal ([]byte (hookObject ), & tmpHook )
919
- if err != nil {
920
- return err
921
- }
922
917
for i , hook := range g .spec .Hooks .Prestart {
923
- if hook .Path == tmpHook .Path {
924
- g .spec .Hooks .Prestart [i ] = tmpHook
918
+ if hook .Path == preStartHook .Path {
919
+ g .spec .Hooks .Prestart [i ] = preStartHook
925
920
return nil
926
921
}
927
922
}
928
- g .spec .Hooks .Prestart = append (g .spec .Hooks .Prestart , tmpHook )
923
+ g .spec .Hooks .Prestart = append (g .spec .Hooks .Prestart , preStartHook )
929
924
return nil
930
925
}
931
926
@@ -938,20 +933,15 @@ func (g *Generator) ClearPostStopHooks() {
938
933
}
939
934
940
935
// AddPostStopHook adds a poststop hook into g.spec.Hooks.Poststop.
941
- func (g * Generator ) AddPostStopHook (hookObject string ) error {
936
+ func (g * Generator ) AddPostStopHook (postStopHook rspec. Hook ) error {
942
937
g .initSpecHooks ()
943
- tmpHook := rspec.Hook {}
944
- err := json .Unmarshal ([]byte (hookObject ), & tmpHook )
945
- if err != nil {
946
- return err
947
- }
948
938
for i , hook := range g .spec .Hooks .Poststop {
949
- if hook .Path == tmpHook .Path {
950
- g .spec .Hooks .Poststop [i ] = tmpHook
939
+ if hook .Path == postStopHook .Path {
940
+ g .spec .Hooks .Poststop [i ] = postStopHook
951
941
return nil
952
942
}
953
943
}
954
- g .spec .Hooks .Poststop = append (g .spec .Hooks .Poststop , tmpHook )
944
+ g .spec .Hooks .Poststop = append (g .spec .Hooks .Poststop , postStopHook )
955
945
return nil
956
946
}
957
947
@@ -964,20 +954,15 @@ func (g *Generator) ClearPostStartHooks() {
964
954
}
965
955
966
956
// AddPostStartHook adds a poststart hook into g.spec.Hooks.Poststart.
967
- func (g * Generator ) AddPostStartHook (hookObject string ) error {
957
+ func (g * Generator ) AddPostStartHook (postStartHook rspec. Hook ) error {
968
958
g .initSpecHooks ()
969
- tmpHook := rspec.Hook {}
970
- err := json .Unmarshal ([]byte (hookObject ), & tmpHook )
971
- if err != nil {
972
- return err
973
- }
974
959
for i , hook := range g .spec .Hooks .Poststart {
975
- if hook .Path == tmpHook .Path {
976
- g .spec .Hooks .Poststart [i ] = tmpHook
960
+ if hook .Path == postStartHook .Path {
961
+ g .spec .Hooks .Poststart [i ] = postStartHook
977
962
return nil
978
963
}
979
964
}
980
- g .spec .Hooks .Poststart = append (g .spec .Hooks .Poststart , tmpHook )
965
+ g .spec .Hooks .Poststart = append (g .spec .Hooks .Poststart , postStartHook )
981
966
return nil
982
967
}
983
968
0 commit comments