diff --git a/pkg/api/feature/feature.go b/pkg/api/feature/feature.go index 72340ee58..15eacef44 100644 --- a/pkg/api/feature/feature.go +++ b/pkg/api/feature/feature.go @@ -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) diff --git a/pkg/apis/nfd/v1alpha1/doc.go b/pkg/apis/nfd/v1alpha1/doc.go index ff1057c29..32b425965 100644 --- a/pkg/apis/nfd/v1alpha1/doc.go +++ b/pkg/apis/nfd/v1alpha1/doc.go @@ -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 diff --git a/pkg/apis/nfd/v1alpha1/expression.go b/pkg/apis/nfd/v1alpha1/expression.go index 0eaf49c0d..303b9b239 100644 --- a/pkg/apis/nfd/v1alpha1/expression.go +++ b/pkg/apis/nfd/v1alpha1/expression.go @@ -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) } } } diff --git a/pkg/apis/nfd/v1alpha1/register.go b/pkg/apis/nfd/v1alpha1/register.go index be60c451c..c87a4852a 100644 --- a/pkg/apis/nfd/v1alpha1/register.go +++ b/pkg/apis/nfd/v1alpha1/register.go @@ -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() } diff --git a/pkg/apis/nfd/v1alpha1/rule.go b/pkg/apis/nfd/v1alpha1/rule.go index 0f6f81cd7..3a4350fc2 100644 --- a/pkg/apis/nfd/v1alpha1/rule.go +++ b/pkg/apis/nfd/v1alpha1/rule.go @@ -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 '=')", trimmed) - } else { - out[split[0]] = split[1] } + out[split[0]] = split[1] } } return out, nil diff --git a/pkg/apis/nfd/v1alpha1/types.go b/pkg/apis/nfd/v1alpha1/types.go index d7bf89e7d..b8982b49e 100644 --- a/pkg/apis/nfd/v1alpha1/types.go +++ b/pkg/apis/nfd/v1alpha1/types.go @@ -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" )