Skip to content

Commit

Permalink
manifests: remove deps from sigs.k8s.io/scheduler-plugins
Browse files Browse the repository at this point in the history
no longer needed; the RenderConfig code uses
unstructured now.

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Oct 23, 2023
1 parent e95827d commit f773d59
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
35 changes: 0 additions & 35 deletions pkg/manifests/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ import (
"k8s.io/apimachinery/pkg/runtime"
k8sjson "k8s.io/apimachinery/pkg/runtime/serializer/json"
k8sscheme "k8s.io/client-go/kubernetes/scheme"
schedconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"

"sigs.k8s.io/controller-runtime/pkg/client"
schedscheme "sigs.k8s.io/scheduler-plugins/apis/config/scheme"
"sigs.k8s.io/scheduler-plugins/apis/config/v1beta2"
)

func SerializeObject(obj runtime.Object, out io.Writer) error {
Expand Down Expand Up @@ -77,38 +74,6 @@ func loadObject(path string) (runtime.Object, error) {
return DeserializeObjectFromData(data)
}

func DecodeSchedulerConfigFromData(data []byte) (*schedconfig.KubeSchedulerConfiguration, error) {
decoder := schedscheme.Codecs.UniversalDecoder()
obj, gvk, err := decoder.Decode(data, nil, nil)

if err != nil {
return nil, err
}

schedCfg, ok := obj.(*schedconfig.KubeSchedulerConfiguration)
if !ok {
return nil, fmt.Errorf("decoded unsupported type: %T gvk=%s", obj, gvk)
}
return schedCfg, nil
}

func EncodeSchedulerConfigToData(schedCfg *schedconfig.KubeSchedulerConfiguration) ([]byte, error) {
yamlInfo, ok := runtime.SerializerInfoForMediaType(schedscheme.Codecs.SupportedMediaTypes(), runtime.ContentTypeYAML)
if !ok {
return nil, fmt.Errorf("unable to locate encoder -- %q is not a supported media type", runtime.ContentTypeYAML)
}

encoder := schedscheme.Codecs.EncoderForVersion(yamlInfo.Serializer, v1beta2.SchemeGroupVersion)

var buf bytes.Buffer
err := encoder.Encode(schedCfg, &buf)
if err != nil {
return nil, err
}

return buf.Bytes(), nil
}

func RenderObjects(objs []client.Object, w io.Writer) error {
for _, obj := range objs {
fmt.Fprintf(w, "---\n")
Expand Down
9 changes: 0 additions & 9 deletions pkg/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ import (
"k8s.io/client-go/kubernetes/scheme"
kubeschedulerconfigv1beta2 "k8s.io/kube-scheduler/config/v1beta2"
"k8s.io/utils/pointer"
apiconfigv1beta2 "sigs.k8s.io/scheduler-plugins/apis/config/v1beta2"

k8sschedpluginsconf "sigs.k8s.io/scheduler-plugins/apis/config"
k8sschedpluginsconfv1beta2 "sigs.k8s.io/scheduler-plugins/apis/config/v1beta2"
k8sschedpluginsconfv1beta3 "sigs.k8s.io/scheduler-plugins/apis/config/v1beta3"

rteassets "github.com/k8stopologyawareschedwg/deployer/pkg/assets/rte"
selinuxassets "github.com/k8stopologyawareschedwg/deployer/pkg/assets/selinux"
Expand Down Expand Up @@ -80,11 +75,7 @@ var src embed.FS

func init() {
apiextensionv1.AddToScheme(scheme.Scheme)
apiconfigv1beta2.AddToScheme(scheme.Scheme)
kubeschedulerconfigv1beta2.AddToScheme(scheme.Scheme)
k8sschedpluginsconf.AddToScheme(scheme.Scheme)
k8sschedpluginsconfv1beta2.AddToScheme(scheme.Scheme)
k8sschedpluginsconfv1beta3.AddToScheme(scheme.Scheme)
machineconfigv1.Install(scheme.Scheme)
securityv1.Install(scheme.Scheme)
}
Expand Down

0 comments on commit f773d59

Please sign in to comment.