Skip to content

feat: Add API boilerplate #25

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

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ repos:
hooks:
- id: golangci-lint
name: golangci-lint
entry: make lint
entry: make go-generate lint
language: system
files: "(.*\\.go|go.mod|go.sum)$"
files: "(.*\\.go|go.mod|go.sum|go.mk)$"
pass_filenames: false
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
Expand Down Expand Up @@ -85,7 +85,7 @@ repos:
args:
- --license-filepath
- header.txt
exclude: ^pkg/addons/templates/.+\.yaml$
exclude: ^(pkg/addons/templates/.+\.yaml|charts/.+/templates/role\.yaml||charts/.+/crds/.+\.yaml)$
- id: insert-license
name: License headers - Markdown
stages: [commit]
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ helm 3.11.1
helm-docs 1.11.0
kind 0.17.0
kube-controller-tools 0.11.3
kubebuilder 3.9.0
kubectl 1.26.1
kustomize 5.0.0
pre-commit 3.0.4
Expand Down
20 changes: 20 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: labs.d2iq.io
layout:
- go.kubebuilder.io/v4-alpha
projectName: capi-runtime-extensions
repo: github.com/d2iq-labs/capi-runtime-extensions
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: labs.d2iq.io
group: clusteraddons
kind: ClusterAddon
path: github.com/d2iq-labs/capi-runtime-extensions/api/v1alpha1
version: v1alpha1
version: "3"
52 changes: 52 additions & 0 deletions api/v1alpha1/clusteraddon_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2023 D2iQ, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ClusterAddonSpec defines the desired state of ClusterAddon.
type ClusterAddonSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of ClusterAddon. Edit clusteraddon_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// ClusterAddonStatus defines the observed state of ClusterAddon.
type ClusterAddonStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// ClusterAddon is the Schema for the clusteraddons API.
type ClusterAddon struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClusterAddonSpec `json:"spec,omitempty"`
Status ClusterAddonStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ClusterAddonList contains a list of ClusterAddon.
type ClusterAddonList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterAddon `json:"items"`
}

//nolint:gochecknoinits // Idiomatic way to register k8s API kinds.
func init() {
SchemeBuilder.Register(&ClusterAddon{}, &ClusterAddonList{})
}
23 changes: 23 additions & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2023 D2iQ, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

// Package v1alpha1 contains API Schema definitions for the clusteraddons v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=clusteraddons.labs.d2iq.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "clusteraddons.labs.d2iq.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
101 changes: 101 additions & 0 deletions api/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
@@ -0,0 +1,50 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
name: clusteraddons.clusteraddons.labs.d2iq.io
spec:
group: clusteraddons.labs.d2iq.io
names:
kind: ClusterAddon
listKind: ClusterAddonList
plural: clusteraddons
singular: clusteraddon
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ClusterAddon is the Schema for the clusteraddons API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ClusterAddonSpec defines the desired state of ClusterAddon.
properties:
foo:
description: Foo is an example field of ClusterAddon. Edit clusteraddon_types.go
to remove/update
type: string
type: object
status:
description: ClusterAddonStatus defines the observed state of ClusterAddon.
type: object
type: object
served: true
storage: true
subresources:
status: {}
33 changes: 33 additions & 0 deletions charts/capi-runtime-extensions/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: capi-runtime-extensions-manager-role
rules:
- apiGroups:
- clusteraddons.labs.d2iq.io
resources:
- clusteraddons
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- clusteraddons.labs.d2iq.io
resources:
- clusteraddons/finalizers
verbs:
- update
- apiGroups:
- clusteraddons.labs.d2iq.io
resources:
- clusteraddons/status
verbs:
- get
- patch
- update
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ require (
github.com/fluxcd/helm-controller/api v0.28.1
github.com/fluxcd/pkg/apis/meta v0.18.0
github.com/fluxcd/source-controller/api v0.33.0
github.com/onsi/ginkgo/v2 v2.6.0
github.com/onsi/gomega v1.24.1
github.com/spf13/pflag v1.0.5
k8s.io/apimachinery v0.25.6
k8s.io/component-base v0.25.6
Expand All @@ -20,7 +22,10 @@ require (
require (
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
github.com/fluxcd/pkg/apis/kustomize v0.7.0 // indirect
github.com/onsi/gomega v1.24.1 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.21.0 // indirect
k8s.io/cluster-bootstrap v0.25.6 // indirect
)

Expand Down Expand Up @@ -91,7 +96,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.25.6
k8s.io/apiextensions-apiserver v0.25.6
k8s.io/client-go v0.25.6 // indirect
k8s.io/client-go v0.25.6
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
Loading