From 08c94e0616d8406e1d8afe864efae3852a2c5725 Mon Sep 17 00:00:00 2001 From: Michael Taufen Date: Mon, 25 Jun 2018 16:30:16 -0700 Subject: [PATCH] add nodestatus package with Setter abstraction for composable node constructors --- pkg/kubelet/BUILD | 1 + pkg/kubelet/nodestatus/BUILD | 23 +++++++++++++++++++++++ pkg/kubelet/nodestatus/setters.go | 25 +++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 pkg/kubelet/nodestatus/BUILD create mode 100644 pkg/kubelet/nodestatus/setters.go diff --git a/pkg/kubelet/BUILD b/pkg/kubelet/BUILD index 914fccb036f..f0fd5b421c8 100644 --- a/pkg/kubelet/BUILD +++ b/pkg/kubelet/BUILD @@ -273,6 +273,7 @@ filegroup( "//pkg/kubelet/metrics:all-srcs", "//pkg/kubelet/mountpod:all-srcs", "//pkg/kubelet/network:all-srcs", + "//pkg/kubelet/nodestatus:all-srcs", "//pkg/kubelet/pleg:all-srcs", "//pkg/kubelet/pod:all-srcs", "//pkg/kubelet/preemption:all-srcs", diff --git a/pkg/kubelet/nodestatus/BUILD b/pkg/kubelet/nodestatus/BUILD new file mode 100644 index 00000000000..fd239ccd3cf --- /dev/null +++ b/pkg/kubelet/nodestatus/BUILD @@ -0,0 +1,23 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["setters.go"], + importpath = "k8s.io/kubernetes/pkg/kubelet/nodestatus", + visibility = ["//visibility:public"], + deps = ["//vendor/k8s.io/api/core/v1:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/kubelet/nodestatus/setters.go b/pkg/kubelet/nodestatus/setters.go new file mode 100644 index 00000000000..432853a5059 --- /dev/null +++ b/pkg/kubelet/nodestatus/setters.go @@ -0,0 +1,25 @@ +/* +Copyright 2018 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 nodestatus + +import ( + "k8s.io/api/core/v1" +) + +// Setter modifies the node in-place, and returns an error if the modification failed. +// Setters may partially mutate the node before returning an error. +type Setter func(node *v1.Node) error