Skip to content

Commit

Permalink
Generate clientset for machine health check API
Browse files Browse the repository at this point in the history
  • Loading branch information
Artyom Lukianov committed Feb 24, 2019
1 parent b71f84f commit 3eb9dbb
Show file tree
Hide file tree
Showing 197 changed files with 13,405 additions and 67 deletions.
15 changes: 10 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ required = [

[[prune.project]]
name = "k8s.io/code-generator"
unused-packages = false
non-go = false

[[constraint]]
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ else
endif

.PHONY: check
check: lint fmt vet test ## Run code validations
check: lint fmt vet verify-codegen test ## Run code validations

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

.PHONY: machine-healthcheck
machine-healthcheck:
$(DOCKER_CMD) ./hack/go-build.sh machine-healthcheck
$(DOCKER_CMD) ./hack/go-build.sh machine-healthcheck

.PHONY: update-codegen
update-codegen:
$(DOCKER_CMD) ./hack/update-codegen.sh

.PHONY: verify-codegen
verify-codegen:
$(DOCKER_CMD) ./hack/verify-codegen.sh

.PHONY: build-integration
build-integration: ## Build integration test binary
Expand Down
4 changes: 2 additions & 2 deletions cmd/machine-healthcheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

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

// Setup Scheme for all resources
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
if err := v1alpha1.AddToScheme(mgr.GetScheme()); err != nil {
glog.Fatal(err)
}
if err := mapiv1.AddToScheme(mgr.GetScheme()); err != nil {
Expand Down
16 changes: 16 additions & 0 deletions hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.
*
* Copyright 2019 Red Hat, Inc.
*
*/
33 changes: 33 additions & 0 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Copyright 2017 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.

set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}

# generate the code with:
# --output-base because this script should also be able to run inside the vendor dir of
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
# instead of the $GOPATH directly. For normal projects this can be dropped.
"${CODEGEN_PKG}"/generate-groups.sh "deepcopy,client" \
github.com/openshift/machine-api-operator/pkg/generated \
github.com/openshift/machine-api-operator/pkg/apis \
healthchecking:v1alpha1 \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt
48 changes: 48 additions & 0 deletions hack/verify-codegen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

# Copyright 2017 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.

set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

DIFFROOT="${SCRIPT_ROOT}/pkg"
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg"
_tmp="${SCRIPT_ROOT}/_tmp"

cleanup() {
rm -rf "${_tmp}"
}
trap "cleanup" EXIT SIGINT

cleanup

mkdir -p "${TMP_DIFFROOT}"
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"

"${SCRIPT_ROOT}/hack/update-codegen.sh"
echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
if [[ $ret -eq 0 ]]
then
echo "${DIFFROOT} up to date."
else
echo "${DIFFROOT} is out of date. Please run `make generate`"
exit 1
fi
10 changes: 0 additions & 10 deletions pkg/apis/addtoscheme_healthchecking_v1alpha1.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/apis/apis.go

This file was deleted.

3 changes: 3 additions & 0 deletions pkg/apis/healthchecking/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package healthchecking

const GroupName = "healthchecking.openshift.io"
21 changes: 9 additions & 12 deletions pkg/apis/healthchecking/v1alpha1/machinehealthcheck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// MachineHealthCheckSpec defines the desired state of MachineHealthCheck
type MachineHealthCheckSpec struct {
Selector metav1.LabelSelector `json:"selector"`
}

// MachineHealthCheckStatus defines the observed state of MachineHealthCheck
type MachineHealthCheckStatus struct {
// TODO(alberto)
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

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

func init() {
SchemeBuilder.Register(&MachineHealthCheck{}, &MachineHealthCheckList{})
// MachineHealthCheckSpec defines the desired state of MachineHealthCheck
type MachineHealthCheckSpec struct {
Selector metav1.LabelSelector `json:"selector"`
}

// MachineHealthCheckStatus defines the observed state of MachineHealthCheck
type MachineHealthCheckStatus struct {
// TODO(alberto)
}
35 changes: 29 additions & 6 deletions pkg/apis/healthchecking/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,37 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"

"github.com/openshift/machine-api-operator/pkg/apis/healthchecking"
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "healthchecking.openshift.io", Version: "v1alpha1"}
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: healthchecking.GroupName, Version: "v1alpha1"}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&MachineHealthCheck{},
&MachineHealthCheckList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
30 changes: 15 additions & 15 deletions pkg/apis/healthchecking/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

mapiv1alpha1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
healthcheckingapis "github.com/openshift/machine-api-operator/pkg/apis"
healthcheckingv1alpha1 "github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Expand All @@ -30,7 +29,7 @@ var (
func init() {
// Add types to scheme
mapiv1alpha1.AddToScheme(scheme.Scheme)
healthcheckingapis.AddToScheme(scheme.Scheme)
healthcheckingv1alpha1.AddToScheme(scheme.Scheme)
}

func node(name string, ready bool) *v1.Node {
Expand Down
Loading

0 comments on commit 3eb9dbb

Please sign in to comment.