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 10 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
ccfishk marked this conversation as resolved.
Show resolved Hide resolved
COPY cmd/ cmd/
COPY controllers/ controllers/
COPY main.go main.go
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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
go test ./apis/addon/... ./controllers/... ./pkg/... ./cmd/... -coverprofile cover.out

# Run E2E tests
bdd: fmt vet deploy
Expand Down Expand Up @@ -96,7 +96,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 +130,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.

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 Expand Up @@ -383,3 +382,23 @@ func (a *Addon) CalculateChecksum() string {
func (a *Addon) GetInstallStatus() ApplicationAssemblyPhase {
return a.Status.Lifecycle.Installed
}

// NotTriggered indicate the workflow not triggered
// Pending,Running are triggered
func (p ApplicationAssemblyPhase) NotTriggered() bool {
switch p {
case Succeeded, Failed, Error, "":
return true
default:
return false
}
}

func (p ApplicationAssemblyPhase) Completed() bool {
switch p {
case Succeeded:
return true
default:
return false
}
}
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
}
File renamed without changes.

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
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/v1alpha1"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/apis/addon/v1alpha1"
"github.com/keikoproj/addon-manager/controllers"
"github.com/keikoproj/addon-manager/pkg/common"
"github.com/keikoproj/addon-manager/pkg/version"
Expand Down
2 changes: 1 addition & 1 deletion pkg/addon/addon_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"

addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/v1alpha1"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/apis/addon/v1alpha1"
"github.com/keikoproj/addon-manager/pkg/common"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/addon/addon_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic/fake"

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

var dynClient = fake.NewSimpleDynamicClient(runtime.NewScheme())
Expand Down
5 changes: 3 additions & 2 deletions pkg/addon/addon_version_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package addon

import (
"github.com/Masterminds/semver/v3"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/v1alpha1"
"sync"

"github.com/Masterminds/semver/v3"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/apis/addon/v1alpha1"
)

// VersionCacheClient interface clients must implement for addon version cache.
Expand Down
2 changes: 1 addition & 1 deletion pkg/addon/addon_version_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"reflect"
"testing"

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

func TestNewCachedClient(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/addonctl/addonctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

addonmgrv1alpha1 "github.com/keikoproj/addon-manager/api/v1alpha1"
addonmgrv1alpha1 "github.com/keikoproj/addon-manager/apis/addon/v1alpha1"
"github.com/keikoproj/addon-manager/pkg/common"
"github.com/keikoproj/addon-manager/pkg/version"
"github.com/keikoproj/addon-manager/pkg/workflows"
Expand Down
81 changes: 81 additions & 0 deletions pkg/client/clientset/versioned/clientset.go

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

Loading