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

Modify API and Generate Addon API clientset/lister/informers #111

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ADD go.sum .
RUN go mod download

COPY pkg/ pkg/
COPY api/ api/
COPY apis/ apis/
COPY cmd/ cmd/
COPY controllers/ controllers/
COPY main.go main.go
Expand Down
29 changes: 26 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,24 @@ GO111MODULE=on
all: test manager addonctl

# Run tests
test: generate fmt vet manifests
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
go test ./api/... ./controllers/... ./pkg/... ./cmd/... -coverprofile cover.out
.PHONY: test
test: test.controllers test.e2e test.pkg test.cmd

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

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

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

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

# Run E2E tests
bdd: fmt vet deploy
Expand Down Expand Up @@ -96,7 +112,7 @@ vet:

# Generate code
generate: controller-gen
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./apis/addon/...

# Build the docker image
docker-build: manager
Expand Down Expand Up @@ -130,3 +146,10 @@ CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

code-generator:
bash $(GOPATH)/src/k8s.io/[email protected]/generate-groups.sh \
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
"deepcopy,client,informer,lister" \
github.com/keikoproj/addon-manager/pkg/client github.com/keikoproj/addon-manager/apis\
addon:v1alpha1 \
--go-header-file ./hack/custom.go.txt
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.

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

import "time"

// Addon constants
const (
Group string = "addonmgr.keikoproj.io"
Version string = "v1alpha1"
APIVersion string = Group + "/" + Version
AddonKind string = "Addon"
AddonSingular string = "addon"
AddonPlural string = "addons"
AddonShortName string = "addon"
AddonFullName string = AddonPlural + "." + Group

ManagedNameSpace string = "addon-manager-system"

AddonResyncPeriod = 20 * time.Minute
)
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ const (
Deleting ApplicationAssemblyPhase = "Deleting"
// DeleteFailed Used to indicate that delete failed.
DeleteFailed ApplicationAssemblyPhase = "Delete Failed"
// Error used to indicate system error
Error ApplicationAssemblyPhase = "error"
)

// DeploymentPhase represents the status of observed resources
Expand Down Expand Up @@ -281,8 +283,8 @@ type AddonStatus struct {
StartTime int64 `json:"starttime"`
}

// AddonList contains a list of Addon
// +kubebuilder:object:root=true

// Addon is the Schema for the addons API
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
Expand All @@ -292,6 +294,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 +305,13 @@ type Addon struct {
}

// +kubebuilder:object:root=true

// AddonList contains a list of Addon
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
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 apis/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
42 changes: 42 additions & 0 deletions apis/addon/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"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.

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/apis/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/apis/addon/v1alpha1"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion controllers/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/v1alpha1"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/apis/addon/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/client"

appsv1 "k8s.io/api/apps/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/v1alpha1"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/apis/addon/v1alpha1"
// +kubebuilder:scaffold:imports
)

Expand Down
Loading