Skip to content

Commit 34c3424

Browse files
Merge pull request #223 from cynepco3hahue/machineHealth_clientset
Generate clientset for machine health check API
2 parents 8779eb5 + 3f7f4cc commit 34c3424

File tree

196 files changed

+13272
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+13272
-65
lines changed

Gopkg.lock

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ required = [
8585

8686
[[prune.project]]
8787
name = "k8s.io/code-generator"
88+
unused-packages = false
8889
non-go = false
8990

9091
[[constraint]]

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ else
2121
endif
2222

2323
.PHONY: check
24-
check: lint fmt vet test ## Run code validations
24+
check: lint fmt vet verify-codegen test ## Run code validations
2525

2626
.PHONY: build
2727
build: machine-api-operator nodelink-controller machine-healthcheck ## Build binaries
@@ -36,7 +36,15 @@ nodelink-controller:
3636

3737
.PHONY: machine-healthcheck
3838
machine-healthcheck:
39-
$(DOCKER_CMD) ./hack/go-build.sh machine-healthcheck
39+
$(DOCKER_CMD) ./hack/go-build.sh machine-healthcheck
40+
41+
.PHONY: update-codegen
42+
update-codegen:
43+
$(DOCKER_CMD) ./hack/update-codegen.sh
44+
45+
.PHONY: verify-codegen
46+
verify-codegen:
47+
$(DOCKER_CMD) ./hack/verify-codegen.sh
4048

4149
.PHONY: build-integration
4250
build-integration: ## Build integration test binary

cmd/machine-healthcheck/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/golang/glog"
88
mapiv1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
9-
"github.com/openshift/machine-api-operator/pkg/apis"
9+
"github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1"
1010
"github.com/openshift/machine-api-operator/pkg/controller"
1111
sdkVersion "github.com/operator-framework/operator-sdk/version"
1212
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
@@ -40,7 +40,7 @@ func main() {
4040
glog.Infof("Registering Components.")
4141

4242
// Setup Scheme for all resources
43-
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
43+
if err := v1alpha1.AddToScheme(mgr.GetScheme()); err != nil {
4444
glog.Fatal(err)
4545
}
4646
if err := mapiv1.AddToScheme(mgr.GetScheme()); err != nil {

hack/boilerplate.go.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*
14+
* Copyright 2019 Red Hat, Inc.
15+
*
16+
*/

hack/update-codegen.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22+
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
23+
24+
# generate the code with:
25+
# --output-base because this script should also be able to run inside the vendor dir of
26+
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
27+
# instead of the $GOPATH directly. For normal projects this can be dropped.
28+
"${CODEGEN_PKG}"/generate-groups.sh "deepcopy,client" \
29+
github.com/openshift/machine-api-operator/pkg/generated \
30+
github.com/openshift/machine-api-operator/pkg/apis \
31+
healthchecking:v1alpha1 \
32+
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \
33+
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt

hack/verify-codegen.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22+
23+
DIFFROOT="${SCRIPT_ROOT}/pkg"
24+
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg"
25+
_tmp="${SCRIPT_ROOT}/_tmp"
26+
27+
cleanup() {
28+
rm -rf "${_tmp}"
29+
}
30+
trap "cleanup" EXIT SIGINT
31+
32+
cleanup
33+
34+
mkdir -p "${TMP_DIFFROOT}"
35+
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
36+
37+
"${SCRIPT_ROOT}/hack/update-codegen.sh"
38+
echo "diffing ${DIFFROOT} against freshly generated codegen"
39+
ret=0
40+
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
41+
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
42+
if [[ $ret -eq 0 ]]
43+
then
44+
echo "${DIFFROOT} up to date."
45+
else
46+
echo "${DIFFROOT} is out of date. Please run `make generate`"
47+
exit 1
48+
fi

pkg/apis/addtoscheme_healthchecking_v1alpha1.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

pkg/apis/apis.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

pkg/apis/healthchecking/register.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package healthchecking
2+
3+
const GroupName = "healthchecking.openshift.io"

pkg/apis/healthchecking/v1alpha1/machinehealthcheck_types.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,7 @@ import (
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
55
)
66

7-
// MachineHealthCheckSpec defines the desired state of MachineHealthCheck
8-
type MachineHealthCheckSpec struct {
9-
Selector metav1.LabelSelector `json:"selector"`
10-
}
11-
12-
// MachineHealthCheckStatus defines the observed state of MachineHealthCheck
13-
type MachineHealthCheckStatus struct {
14-
// TODO(alberto)
15-
}
16-
7+
// +genclient
178
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
189

1910
// MachineHealthCheck is the Schema for the machinehealthchecks API
@@ -35,6 +26,12 @@ type MachineHealthCheckList struct {
3526
Items []MachineHealthCheck `json:"items"`
3627
}
3728

38-
func init() {
39-
SchemeBuilder.Register(&MachineHealthCheck{}, &MachineHealthCheckList{})
29+
// MachineHealthCheckSpec defines the desired state of MachineHealthCheck
30+
type MachineHealthCheckSpec struct {
31+
Selector metav1.LabelSelector `json:"selector"`
32+
}
33+
34+
// MachineHealthCheckStatus defines the observed state of MachineHealthCheck
35+
type MachineHealthCheckStatus struct {
36+
// TODO(alberto)
4037
}

pkg/apis/healthchecking/v1alpha1/register.go

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,37 @@
66
package v1alpha1
77

88
import (
9+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10+
"k8s.io/apimachinery/pkg/runtime"
911
"k8s.io/apimachinery/pkg/runtime/schema"
10-
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
12+
13+
"github.com/openshift/machine-api-operator/pkg/apis/healthchecking"
1114
)
1215

13-
var (
14-
// SchemeGroupVersion is group version used to register these objects
15-
SchemeGroupVersion = schema.GroupVersion{Group: "healthchecking.openshift.io", Version: "v1alpha1"}
16+
// SchemeGroupVersion is group version used to register these objects
17+
var SchemeGroupVersion = schema.GroupVersion{Group: healthchecking.GroupName, Version: "v1alpha1"}
18+
19+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
20+
func Kind(kind string) schema.GroupKind {
21+
return SchemeGroupVersion.WithKind(kind).GroupKind()
22+
}
1623

17-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
18-
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
24+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
25+
func Resource(resource string) schema.GroupResource {
26+
return SchemeGroupVersion.WithResource(resource).GroupResource()
27+
}
28+
29+
var (
30+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
31+
AddToScheme = SchemeBuilder.AddToScheme
1932
)
33+
34+
// Adds the list of known types to Scheme.
35+
func addKnownTypes(scheme *runtime.Scheme) error {
36+
scheme.AddKnownTypes(SchemeGroupVersion,
37+
&MachineHealthCheck{},
38+
&MachineHealthCheckList{},
39+
)
40+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
41+
return nil
42+
}

pkg/apis/healthchecking/v1alpha1/zz_generated.deepcopy.go

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/machinehealthcheck/machinehealthcheck_controller_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"time"
88

99
mapiv1alpha1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
10-
healthcheckingapis "github.com/openshift/machine-api-operator/pkg/apis"
1110
healthcheckingv1alpha1 "github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1"
1211
corev1 "k8s.io/api/core/v1"
1312
v1 "k8s.io/api/core/v1"
@@ -30,7 +29,7 @@ var (
3029
func init() {
3130
// Add types to scheme
3231
mapiv1alpha1.AddToScheme(scheme.Scheme)
33-
healthcheckingapis.AddToScheme(scheme.Scheme)
32+
healthcheckingv1alpha1.AddToScheme(scheme.Scheme)
3433
}
3534

3635
func node(name string, ready bool) *v1.Node {

0 commit comments

Comments
 (0)