Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add comment marker into api; generate addon clientset/lister/informers #116

Merged
merged 7 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ all: test manager addonctl

# Run tests
test: generate fmt vet manifests
go test ./api/... ./controllers/... ./pkg/... ./cmd/... -coverprofile cover.out
go test ./api/... ./controllers/... ./pkg/... ./cmd/... -v -coverprofile cover.out

# tests both controllers and api
.PHONY: test.controllers
test.controllers:
go test -v -race ./controllers/... -coverprofile cover.out

.PHONY: test.pkg
test.pkg:
go test -v -race ./pkg/... -coverprofile cover.out

.PHONY: test.cmd
test.cmd:
go test -v -race ./cmd/... -coverprofile cover.out

# Run E2E tests
bdd: fmt vet deploy
Expand Down Expand Up @@ -95,9 +108,22 @@ vet:
go vet ./...

# Generate code
generate: controller-gen
generate: controller-gen types
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...

# generates many other files (listers, informers, client etc).
api/addon/v1alpha1/zz_generated.deepcopy.go: $(TYPES)
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
ln -s v1
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
$(CODE_GENERATOR_GEN)/generate-groups.sh \
"deepcopy,client,informer,lister" \
github.com/keikoproj/addon-manager/pkg/client github.com/keikoproj/addon-manager/api\
addon:v1alpha1 \
--go-header-file ./hack/custom-boilerplate.go.txt
rm -rf v1

.PHONY: types
types: api/addon/v1alpha1/zz_generated.deepcopy.go

# Build the docker image
docker-build: manager
docker build --build-arg COMMIT=${GIT_COMMIT} --build-arg DATE=${BUILD_DATE} -t ${IMG} .
Expand Down Expand Up @@ -130,3 +156,16 @@ CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

code-generator:
ifeq (, $(shell which code-generator))
@{ \
cd $(GOBIN) ;\
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
curl -L -o code-generator.zip https://github.com/kubernetes/code-generator/archive/refs/tags/v0.21.5.zip ;\
unzip code-generator.zip ;\
rm -rf code-generator.zip ;\
}
CODE_GENERATOR_GEN=$(GOBIN)/code-generator-0.21.5
else
CODE_GENERATOR_GEN=$(shell which code-generator)
endif
1 change: 1 addition & 0 deletions api/addon/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package addon
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ type AddonStatus struct {
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.lifecycle.installed"
// +kubebuilder:printcolumn:name="REASON",type="string",JSONPath=".status.reason"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Addon struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -301,18 +303,14 @@ type Addon struct {
}

// +kubebuilder:object:root=true

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// AddonList contains a list of Addon
type AddonList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Addon `json:"items"`
}

func init() {
SchemeBuilder.Register(&Addon{}, &AddonList{})
}

// GetPackageSpec returns the addon package details from addon spec
func (a *Addon) GetPackageSpec() PackageSpec {
return PackageSpec{
Expand Down
3 changes: 3 additions & 0 deletions api/addon/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// +k8s:deepcopy-gen=package
// +groupName=addonmgr.keikoproj.io
package v1alpha1
56 changes: 56 additions & 0 deletions api/addon/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// SchemeGroupVersion is group version used to register these objects
var (
SchemeGroupVersion = schema.GroupVersion{Group: "addonmgr.keikoproj.io", Version: "v1alpha1"}
AddonSchemaGroupVersionKind = schema.GroupVersionKind{Group: "addonmgr.keikoproj.io", Version: "v1alpha1", Kind: "Addon"}
)

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

// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// addKnownTypes adds the set of types defined in this package to the supplied scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Addon{},
&AddonList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

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

34 changes: 0 additions & 34 deletions api/v1alpha1/groupversion_info.go

This file was deleted.

74 changes: 0 additions & 74 deletions api/v1alpha1/suite_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion controllers/addon_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/v1alpha1"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/addon/v1alpha1"
"github.com/keikoproj/addon-manager/pkg/addon"
"github.com/keikoproj/addon-manager/pkg/common"
"github.com/keikoproj/addon-manager/pkg/workflows"
Expand Down
2 changes: 1 addition & 1 deletion controllers/addon_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"

"github.com/keikoproj/addon-manager/api/v1alpha1"
"github.com/keikoproj/addon-manager/api/addon/v1alpha1"
)

var (
Expand Down
Loading