forked from kubernetes-sigs/kube-scheduler-wasm-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubernetes-sigs#65 from codefromthecrypt/metadata
guest: Add proto.Metadata and fix prefilter unmarshalling
- Loading branch information
Showing
22 changed files
with
224 additions
and
111 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package proto | ||
|
||
import ( | ||
"sigs.k8s.io/kube-scheduler-wasm-extension/guest/api/proto" | ||
protoapi "sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/api" | ||
meta "sigs.k8s.io/kube-scheduler-wasm-extension/kubernetes/proto/meta" | ||
) | ||
|
||
type object interface { | ||
GetMetadata() *meta.ObjectMeta | ||
} | ||
|
||
func GetName[O object](o O) string { | ||
if md := o.GetMetadata(); md != nil && md.Name != nil { | ||
return *md.Name | ||
} | ||
return "" | ||
} | ||
|
||
func GetNamespace[O object](o O) string { | ||
if md := o.GetMetadata(); md != nil && md.Namespace != nil { | ||
return *md.Namespace | ||
} | ||
return "" | ||
} | ||
|
||
func GetUid[O object](o O) string { | ||
if md := o.GetMetadata(); md != nil && md.Uid != nil { | ||
return *md.Uid | ||
} | ||
return "" | ||
} | ||
|
||
var _ proto.Node = (*Node)(nil) | ||
|
||
type Node struct { | ||
Msg *protoapi.Node | ||
} | ||
|
||
func (o *Node) GetName() string { | ||
return GetName(o.Msg) | ||
} | ||
|
||
func (o *Node) GetNamespace() string { | ||
return GetNamespace(o.Msg) | ||
} | ||
|
||
func (o *Node) GetUid() string { | ||
return GetUid(o.Msg) | ||
} | ||
|
||
func (o *Node) Spec() *protoapi.NodeSpec { | ||
return o.Msg.Spec | ||
} | ||
|
||
func (o *Node) Status() *protoapi.NodeStatus { | ||
return o.Msg.Status | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build tinygo.wasm | ||
|
||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package prescore | ||
|
||
import "sigs.k8s.io/kube-scheduler-wasm-extension/guest/internal/mem" | ||
|
||
//go:wasmimport k8s.io/api nodeList | ||
func k8sApiNodeList(ptr uint32, limit mem.BufLimit) (len uint32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build !tinygo.wasm | ||
|
||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package prescore | ||
|
||
import "sigs.k8s.io/kube-scheduler-wasm-extension/guest/internal/mem" | ||
|
||
// k8sApiNodeList is stubbed for compilation outside TinyGo. | ||
func k8sApiNodeList(uint32, mem.BufLimit) (len uint32) { return } |
Oops, something went wrong.