@@ -912,20 +912,15 @@ func (g *Generator) ClearPreStartHooks() {
912912}
913913
914914// 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 {
916916 g .initSpecHooks ()
917- tmpHook := rspec.Hook {}
918- err := json .Unmarshal ([]byte (hookObject ), & tmpHook )
919- if err != nil {
920- return err
921- }
922917 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
925920 return nil
926921 }
927922 }
928- g .spec .Hooks .Prestart = append (g .spec .Hooks .Prestart , tmpHook )
923+ g .spec .Hooks .Prestart = append (g .spec .Hooks .Prestart , preStartHook )
929924 return nil
930925}
931926
@@ -938,20 +933,15 @@ func (g *Generator) ClearPostStopHooks() {
938933}
939934
940935// 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 {
942937 g .initSpecHooks ()
943- tmpHook := rspec.Hook {}
944- err := json .Unmarshal ([]byte (hookObject ), & tmpHook )
945- if err != nil {
946- return err
947- }
948938 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
951941 return nil
952942 }
953943 }
954- g .spec .Hooks .Poststop = append (g .spec .Hooks .Poststop , tmpHook )
944+ g .spec .Hooks .Poststop = append (g .spec .Hooks .Poststop , postStopHook )
955945 return nil
956946}
957947
@@ -964,20 +954,15 @@ func (g *Generator) ClearPostStartHooks() {
964954}
965955
966956// 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 {
968958 g .initSpecHooks ()
969- tmpHook := rspec.Hook {}
970- err := json .Unmarshal ([]byte (hookObject ), & tmpHook )
971- if err != nil {
972- return err
973- }
974959 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
977962 return nil
978963 }
979964 }
980- g .spec .Hooks .Poststart = append (g .spec .Hooks .Poststart , tmpHook )
965+ g .spec .Hooks .Poststart = append (g .spec .Hooks .Poststart , postStartHook )
981966 return nil
982967}
983968
0 commit comments