Skip to content

Commit

Permalink
feat: add group
Browse files Browse the repository at this point in the history
  • Loading branch information
mariatsji committed Nov 18, 2024
1 parent 031eb4c commit e7b7a31
Show file tree
Hide file tree
Showing 32 changed files with 122 additions and 400 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ====================================================================================
# Setup Project
PROJECT_NAME := provider-template
PROJECT_REPO := github.com/crossplane/$(PROJECT_NAME)
PROJECT_NAME := provider-cloudian
PROJECT_REPO := github.com/statnett/$(PROJECT_NAME)

PLATFORMS ?= linux_amd64 linux_arm64
-include build/makelib/common.mk
Expand Down Expand Up @@ -30,7 +30,7 @@ GO111MODULE = on
# ====================================================================================
# Setup Images

IMAGES = provider-template
IMAGES = provider-cloudian
-include build/makelib/imagelight.mk

# ====================================================================================
Expand All @@ -40,12 +40,12 @@ XPKG_REG_ORGS ?= xpkg.upbound.io/crossplane
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
# inferred.
XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/crossplane
XPKGS = provider-template
XPKGS = provider-cloudian
-include build/makelib/xpkg.mk

# NOTE(hasheddan): we force image building to happen prior to xpkg build so that
# we ensure image is present in daemon.
xpkg.build.provider-template: do.build.images
xpkg.build.provider-cloudian: do.build.images

fallthrough: submodules
@echo Initial setup complete. Running make again . . .
Expand Down Expand Up @@ -93,9 +93,9 @@ dev: $(KIND) $(KUBECTL)
@$(KUBECTL) cluster-info --context kind-$(PROJECT_NAME)-dev
@$(INFO) Installing Crossplane CRDs
@$(KUBECTL) apply --server-side -k https://github.com/crossplane/crossplane//cluster?ref=master
@$(INFO) Installing Provider Template CRDs
@$(INFO) Installing Provider Cloudian CRDs
@$(KUBECTL) apply -R -f package/crds
@$(INFO) Starting Provider Template controllers
@$(INFO) Starting Provider Cloudian controllers
@$(GO) run cmd/provider/main.go --debug

dev-clean: $(KIND) $(KUBECTL)
Expand All @@ -120,7 +120,7 @@ $(GOMPLATE):

export GOMPLATE

# This target prepares repo for your provider by replacing all "template"
# This target prepares repo for your provider by replacing all "cloudian"
# occurrences with your provider name.
# This target can only be run once, if you want to rerun for some reason,
# consider stashing/resetting your git state.
Expand Down
24 changes: 12 additions & 12 deletions PROVIDER_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Generally projects are named `provider-<name>`, with `name` being the API being
managed. Example project names are `provider-aws`, `provider-kubernetes`,
and `provider-github`.

The [provider-template](https://github.com/crossplane/provider-template) repository can be
The [provider-cloudian](https://github.com/statnett/provider-cloudian) repository can be
used as a starting point for new providers. For [terrajet](https://github.com/crossplane/terrajet)-based providers, the
[provider-jet-template](https://github.com/crossplane-contrib/provider-jet-template) is
[provider-jet-cloudian](https://github.com/crossplane-contrib/provider-jet-cloudian) is
available.

## Files
Expand All @@ -43,17 +43,17 @@ Most Crossplane providers include the following files:
[provider-gcp/README.md](https://github.com/crossplane/provider-gcp/blob/master/README.md)
as an example)
- [ ] Code is licensed under the [Apache 2.0
License](https://github.com/crossplane/provider-template/blob/main/LICENSE)
License](https://github.com/statnett/provider-cloudian/blob/main/LICENSE)
- [ ] Include a “Developer Certificate of Origin”. Example:
[DCO](https://github.com/upbound/build/blob/master/DCO)
- [ ] Include the CNCF [Code of
Conduct](https://github.com/crossplane/crossplane/blob/master/CODE_OF_CONDUCT.md)
- [ ] Update
[OWNERS.md](https://github.com/crossplane/provider-template/blob/main/OWNERS.md)
[OWNERS.md](https://github.com/statnett/provider-cloudian/blob/main/OWNERS.md)
with contacts for project Owners
- [ ] Ensure `hack/boilerplate.go.txt` (used in Code generation) includes
Crossplane Authors, Apache license and any other Copyright statements:
[https://github.com/crossplane/provider-template/blob/main/hack/boilerplate.go.txt](https://github.com/crossplane/provider-template/blob/main/hack/boilerplate.go.txt)
[https://github.com/statnett/provider-cloudian/blob/main/hack/boilerplate.go.txt](https://github.com/statnett/provider-cloudian/blob/main/hack/boilerplate.go.txt)
- [ ] Include Documentation on how to:
- [ ] Install Provider
- [ ] Contribute to Development
Expand All @@ -68,7 +68,7 @@ There are a number of build tools and processes that are common across the
Crossplane ecosystem. Using these ensures a consistent development environment
across projects.

The [provider-template](https://github.com/crossplane/provider-template)
The [provider-cloudian](https://github.com/statnett/provider-cloudian)
repository contains most of these settings.

- [ ] Use the [Upbound build](https://github.com/upbound/build) submodule. (see
Expand All @@ -81,7 +81,7 @@ repository contains most of these settings.
- [ ] Create a [Crossplane
Package](https://crossplane.io/docs/master/concepts/packages.html)
configuration (see
[package/crossplane.yaml)](https://github.com/crossplane/provider-template/blob/main/package/crossplane.yaml)
[package/crossplane.yaml)](https://github.com/statnett/provider-cloudian/blob/main/package/crossplane.yaml)

## Deployment of Artifacts

Expand All @@ -96,7 +96,7 @@ the publish and promotion workflows.
In general, providers should:

- [ ] Utilize GitHub workflows from
<https://github.com/crossplane/provider-template/tree/main/.github/workflows>
<https://github.com/statnett/provider-cloudian/tree/main/.github/workflows>
- [ ] Create OCI image repos to push Package and Controller images.
- [ ] Automatically push Provider images and packages via CI
- [ ] Add GitHub Secrets to push to Docker repository. (To be performed by
Expand All @@ -112,7 +112,7 @@ to grant your project access to the GitHub org scoped secrets.

- [ ] Follow recommendations at
[https://github.com/crossplane/crossplane/blob/master/GOVERNANCE.md#repository-governance](https://github.com/crossplane/crossplane/blob/master/GOVERNANCE.md#repository-governance)
- [ ] Enable Issues on your project and configure Issue templates (examples at:
[.github/ISSUE_TEMPLATE](https://github.com/crossplane/provider-template/tree/master/.github/ISSUE_TEMPLATE))
- [ ] Create Pull Request Templates: (example:
[PULL_REQUEST_TEMPLATE.md](https://github.com/crossplane/provider-template/blob/master/.github/PULL_REQUEST_TEMPLATE.md))
- [ ] Enable Issues on your project and configure Issue cloudians (examples at:
[.github/ISSUE_TEMPLATE](https://github.com/statnett/provider-cloudian/tree/master/.github/ISSUE_TEMPLATE))
- [ ] Create Pull Request Cloudians: (example:
[PULL_REQUEST_TEMPLATE.md](https://github.com/statnett/provider-cloudian/blob/master/.github/PULL_REQUEST_TEMPLATE.md))
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# provider-template
# provider-cloudian

`provider-template` is a minimal [Crossplane](https://crossplane.io/) Provider
that is meant to be used as a template for implementing new Providers. It comes
`provider-cloudian` is a minimal [Crossplane](https://crossplane.io/) Provider
that is meant to be used as a cloudian for implementing new Providers. It comes
with the following features that are meant to be refactored:

- A `ProviderConfig` type that only points to a credentials `Secret`.
Expand All @@ -11,7 +11,7 @@ with the following features that are meant to be refactored:

## Developing

1. Use this repository as a template to create a new one.
1. Use this repository as a cloudian to create a new one.
1. Run `make submodules` to initialize the "build" Make submodule we use for CI/CD.
1. Rename the provider by running the following command:
```shell
Expand Down
8 changes: 3 additions & 5 deletions apis/template.go → apis/cloudian.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package apis contains Kubernetes API for the Template provider.
// Package apis contains Kubernetes API for the Cloudian provider.
package apis

import (
"k8s.io/apimachinery/pkg/runtime"

samplev1alpha1 "github.com/crossplane/provider-template/apis/sample/v1alpha1"
templatev1alpha1 "github.com/crossplane/provider-template/apis/v1alpha1"
cloudianv1alpha1 "github.com/statnett/provider-cloudian/apis/v1alpha1"
)

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes,
templatev1alpha1.SchemeBuilder.AddToScheme,
samplev1alpha1.SchemeBuilder.AddToScheme,
cloudianv1alpha1.SchemeBuilder.AddToScheme,
)
}

Expand Down
6 changes: 3 additions & 3 deletions apis/sample/sample.go → apis/group/group.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Crossplane Authors.
Copyright 2022 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package sample contains group Sample API versions
package sample
// Package group contains group group API versions
package group
2 changes: 1 addition & 1 deletion apis/sample/v1alpha1/doc.go → apis/group/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Crossplane Authors.
Copyright 2022 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Crossplane Authors.
Copyright 2022 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -25,63 +25,62 @@ import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
)

// MyTypeParameters are the configurable fields of a MyType.
type MyTypeParameters struct {
// GroupParameters are the configurable fields of a Group.
type GroupParameters struct {
ConfigurableField string `json:"configurableField"`
}

// MyTypeObservation are the observable fields of a MyType.
type MyTypeObservation struct {
ConfigurableField string `json:"configurableField"`
ObservableField string `json:"observableField,omitempty"`
// GroupObservation are the observable fields of a Group.
type GroupObservation struct {
ObservableField string `json:"observableField,omitempty"`
}

// A MyTypeSpec defines the desired state of a MyType.
type MyTypeSpec struct {
// A GroupSpec defines the desired state of a Group.
type GroupSpec struct {
xpv1.ResourceSpec `json:",inline"`
ForProvider MyTypeParameters `json:"forProvider"`
ForProvider GroupParameters `json:"forProvider"`
}

// A MyTypeStatus represents the observed state of a MyType.
type MyTypeStatus struct {
// A GroupStatus represents the observed state of a Group.
type GroupStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider MyTypeObservation `json:"atProvider,omitempty"`
AtProvider GroupObservation `json:"atProvider,omitempty"`
}

// +kubebuilder:object:root=true

// A MyType is an example API type.
// A Group is an example API type.
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,template}
type MyType struct {
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,cloudian}
type Group struct {

Check failure on line 59 in apis/group/v1alpha1/group_types.go

View workflow job for this annotation

GitHub Actions / unit-tests

other declaration of Group
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MyTypeSpec `json:"spec"`
Status MyTypeStatus `json:"status,omitempty"`
Spec GroupSpec `json:"spec"`
Status GroupStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

// MyType type metadata.
// Group type metadata.
var (
MyTypeKind = reflect.TypeOf(MyType{}).Name()
MyTypeGroupKind = schema.GroupKind{Group: Group, Kind: MyTypeKind}.String()
MyTypeKindAPIVersion = MyTypeKind + "." + SchemeGroupVersion.String()
MyTypeGroupVersionKind = SchemeGroupVersion.WithKind(MyTypeKind)
GroupKind = reflect.TypeOf(Group{}).Name()
GroupGroupKind = schema.GroupKind{Group: Group, Kind: GroupKind}.String()

Check failure on line 79 in apis/group/v1alpha1/group_types.go

View workflow job for this annotation

GitHub Actions / unit-tests

Group (type) is not an expression
GroupKindAPIVersion = GroupKind + "." + SchemeGroupVersion.String()
GroupGroupVersionKind = SchemeGroupVersion.WithKind(GroupKind)
)

func init() {
SchemeBuilder.Register(&MyType{}, &MyTypeList{})
SchemeBuilder.Register(&Group{}, &GroupList{})

Check failure on line 85 in apis/group/v1alpha1/group_types.go

View workflow job for this annotation

GitHub Actions / unit-tests

cannot use &Group{} (value of type *Group) as "k8s.io/apimachinery/pkg/runtime".Object value in argument to SchemeBuilder.Register: *Group does not implement "k8s.io/apimachinery/pkg/runtime".Object (missing method DeepCopyObject)

Check failure on line 85 in apis/group/v1alpha1/group_types.go

View workflow job for this annotation

GitHub Actions / unit-tests

cannot use &GroupList{} (value of type *GroupList) as "k8s.io/apimachinery/pkg/runtime".Object value in argument to SchemeBuilder.Register: *GroupList does not implement "k8s.io/apimachinery/pkg/runtime".Object (missing method DeepCopyObject)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains the v1alpha1 group Sample resources of the Template provider.
// Package v1alpha1 contains the v1alpha1 group Sample resources of the Cloudian provider.
// +kubebuilder:object:generate=true
// +groupName=sample.template.crossplane.io
// +groupName=group.cloudian.crossplane.io
// +versionName=v1alpha1
package v1alpha1

Expand All @@ -27,7 +27,7 @@ import (

// Package type metadata.
const (
Group = "sample.template.crossplane.io"
Group = "group.cloudian.crossplane.io"

Check failure on line 30 in apis/group/v1alpha1/groupversion_info.go

View workflow job for this annotation

GitHub Actions / unit-tests

Group redeclared in this block
Version = "v1alpha1"
)

Expand Down
Loading

0 comments on commit e7b7a31

Please sign in to comment.