1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-28 02:37:11 +00:00

Merge pull request #687 from marquiz/fixes/lint

Lint fixes to pkg/apis
This commit is contained in:
Kubernetes Prow Robot 2021-12-01 05:49:16 -08:00 committed by GitHub
commit 4e6e730d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 18 deletions

View file

@ -25,6 +25,7 @@ func NewDomainFeatures() *DomainFeatures {
Instances: make(map[string]InstanceFeatureSet)}
}
// NewKeyFeatures creates a new instance of KeyFeatureSet.
func NewKeyFeatures(keys ...string) KeyFeatureSet {
e := make(map[string]Nil, len(keys))
for _, k := range keys {
@ -33,6 +34,7 @@ func NewKeyFeatures(keys ...string) KeyFeatureSet {
return KeyFeatureSet{Elements: e}
}
// NewValueFeatures creates a new instance of ValueFeatureSet.
func NewValueFeatures(values map[string]string) ValueFeatureSet {
if values == nil {
values = make(map[string]string)
@ -40,10 +42,12 @@ func NewValueFeatures(values map[string]string) ValueFeatureSet {
return ValueFeatureSet{Elements: values}
}
// NewInstanceFeatures creates a new instance of InstanceFeatureSet.
func NewInstanceFeatures(instances []InstanceFeature) InstanceFeatureSet {
return InstanceFeatureSet{Elements: instances}
}
// NewInstanceFeature creates a new InstanceFeature instance.
func NewInstanceFeature(attrs map[string]string) *InstanceFeature {
if attrs == nil {
attrs = make(map[string]string)

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package v1alpha1 is the v1alpha1 version of the nfd API.
// +k8s:deepcopy-gen=package
// +kubebuilder:object:generate=true
// +groupName=nfd.k8s-sigs.io

View file

@ -443,13 +443,12 @@ func (m *MatchExpressionSet) UnmarshalJSON(data []byte) error {
expressions := make(map[string]*MatchExpression)
if err := json.Unmarshal(data, &expressions); err != nil {
return err
} else {
for k, v := range expressions {
if v != nil {
(*m).Expressions[k] = v
} else {
(*m).Expressions[k] = newMatchExpression(MatchExists)
}
}
for k, v := range expressions {
if v != nil {
(*m).Expressions[k] = v
} else {
(*m).Expressions[k] = newMatchExpression(MatchExists)
}
}
}

View file

@ -23,14 +23,17 @@ import (
)
var (
// GroupVersion is group version used to register these objects
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "nfd.k8s-sigs.io", Version: "v1alpha1"}
// SchemeBuilder is the scheme builder for this API.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// AddToScheme is a function to register this API group and version to a scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
// Resource takes an unqualified resource name and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

View file

@ -217,19 +217,19 @@ func newTemplateHelper(name string) (*templateHelper, error) {
}
// DeepCopy is a stub to augment the auto-generated code
func (in *templateHelper) DeepCopy() *templateHelper {
if in == nil {
func (h *templateHelper) DeepCopy() *templateHelper {
if h == nil {
return nil
}
out := new(templateHelper)
in.DeepCopyInto(out)
h.DeepCopyInto(out)
return out
}
// DeepCopyInto is a stub to augment the auto-generated code
func (in *templateHelper) DeepCopyInto(out *templateHelper) {
func (h *templateHelper) DeepCopyInto(out *templateHelper) {
// HACK: just re-use the template
out.template = in.template
out.template = h.template
}
func (h *templateHelper) execute(data interface{}) (string, error) {
@ -257,9 +257,8 @@ func (h *templateHelper) expandMap(data interface{}) (map[string]string, error)
split := strings.SplitN(trimmed, "=", 2)
if len(split) == 1 {
return nil, fmt.Errorf("missing value in expanded template line %q, (format must be '<key>=<value>')", trimmed)
} else {
out[split[0]] = split[1]
}
out[split[0]] = split[1]
}
}
return out, nil

View file

@ -156,8 +156,8 @@ const (
// MatchIn returns true if any of the values stored in the expression is
// equal to the input.
MatchIn MatchOp = "In"
// MatchIn returns true if none of the values in the expression are equal
// to the input.
// MatchNotIn returns true if none of the values in the expression are
// equal to the input.
MatchNotIn MatchOp = "NotIn"
// MatchInRegexp treats values of the expression as regular expressions and
// returns true if any of them matches the input.
@ -186,7 +186,7 @@ const (
// MatchIsTrue returns true if the input holds the value "true". The
// expression must not have any values.
MatchIsTrue MatchOp = "IsTrue"
// MatchIsTrue returns true if the input holds the value "false". The
// MatchIsFalse returns true if the input holds the value "false". The
// expression must not have any values.
MatchIsFalse MatchOp = "IsFalse"
)