move Pauser and Resumer from the factory

This commit is contained in:
juanvallejo
2018-05-21 17:56:56 -04:00
parent 5f5e3a59c0
commit fb0794976a
15 changed files with 182 additions and 70 deletions

View File

@@ -19,7 +19,6 @@ limitations under the License.
package util
import (
"errors"
"fmt"
"io"
"os"
@@ -218,32 +217,6 @@ func (f *ring0Factory) SuggestedPodTemplateResources() []schema.GroupResource {
}
}
func (f *ring0Factory) Pauser(info *resource.Info) ([]byte, error) {
switch obj := info.Object.(type) {
case *extensions.Deployment:
if obj.Spec.Paused {
return nil, errors.New("is already paused")
}
obj.Spec.Paused = true
return runtime.Encode(InternalVersionJSONEncoder(), info.Object)
default:
return nil, fmt.Errorf("pausing is not supported")
}
}
func (f *ring0Factory) Resumer(info *resource.Info) ([]byte, error) {
switch obj := info.Object.(type) {
case *extensions.Deployment:
if !obj.Spec.Paused {
return nil, errors.New("is not paused")
}
obj.Spec.Paused = false
return runtime.Encode(InternalVersionJSONEncoder(), info.Object)
default:
return nil, fmt.Errorf("resuming is not supported")
}
}
func (f *ring0Factory) DefaultNamespace() (string, bool, error) {
return f.clientGetter.ToRawKubeConfigLoader().Namespace()
}