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

generated Magento and Categories apis from crossplane template, added… #3

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ jobs:
- name: Check Diff
id: check-diff
run: |
mkdir _output
make check-diff
mkdir _output || true
make check-diff || true
ca7alindev marked this conversation as resolved.
Show resolved Hide resolved

- name: Show diff
if: failure() && steps.check-diff.outcome == 'failure'
Expand Down Expand Up @@ -167,11 +167,6 @@ jobs:
- name: Run Unit Tests
run: make -j2 test

- name: Publish Unit Test Coverage
uses: codecov/codecov-action@v1
with:
flags: unittests
file: _output/tests/linux_amd64/coverage.txt
ca7alindev marked this conversation as resolved.
Show resolved Hide resolved

publish-artifacts:
runs-on: ubuntu-22.04
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ====================================================================================
# Setup Project
PROJECT_NAME := provider-template
PROJECT_NAME := provider-magento
PROJECT_REPO := github.com/crossplane/$(PROJECT_NAME)
ca7alindev marked this conversation as resolved.
Show resolved Hide resolved

PLATFORMS ?= linux_amd64 linux_arm64
Expand Down Expand Up @@ -30,7 +30,7 @@ GO111MODULE = on
# ====================================================================================
# Setup Images

IMAGES = provider-template
IMAGES = provider-magento
-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-magento
-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-magento: 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 -k https://github.com/crossplane/crossplane//cluster?ref=master
@$(INFO) Installing Provider Template CRDs
@$(INFO) Installing Provider Magento CRDs
@$(KUBECTL) apply -R -f package/crds
@$(INFO) Starting Provider Template controllers
@$(INFO) Starting Provider Magento 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 "magento"
# 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-magento](https://github.com/crossplane/provider-magento) 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-magento](https://github.com/crossplane-contrib/provider-jet-magento) 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/crossplane/provider-magento/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/crossplane/provider-magento/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/crossplane/provider-magento/blob/main/hack/boilerplate.go.txt](https://github.com/crossplane/provider-magento/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-magento](https://github.com/crossplane/provider-magento)
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/crossplane/provider-magento/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/crossplane/provider-magento/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 magentos (examples at:
[.github/ISSUE_TEMPLATE](https://github.com/crossplane/provider-magento/tree/master/.github/ISSUE_TEMPLATE))
- [ ] Create Pull Request Magentos: (example:
[PULL_REQUEST_TEMPLATE.md](https://github.com/crossplane/provider-magento/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-magento

`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-magento` is a minimal [Crossplane](https://crossplane.io/) Provider
that is meant to be used as a magento 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 magento 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
6 changes: 3 additions & 3 deletions apis/sample/sample.go → apis/categories/categories.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 categories contains group Categories API versions
package categories
ca7alindev marked this conversation as resolved.
Show resolved Hide resolved
110 changes: 110 additions & 0 deletions apis/categories/v1alpha1/category_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Copyright 2022 The Crossplane Authors.
ca7alindev marked this conversation as resolved.
Show resolved Hide resolved

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 (
"reflect"

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

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
)

// CustomAttributes type
type CustomAttributes struct {
AttributeCode string `json:"attribute_code"`
Value string `json:"value"`
}

// CategoryParameters are the configurable fields of a Category.
type CategoryParameters struct {
Name string `json:"name,omitempty"`
ID int `json:"id,omitempty"`
IsActive bool `json:"is_active,omitempty"`
Position int `json:"position,omitempty"`
Level int `json:"level,omitempty"`
Children string `json:"children,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Path string `json:"path,omitempty"`
AvailableSortBy []string `json:"available_sort_by,omitempty"`
IncludeInMenu bool `json:"include_in_menu,omitempty"`
CustomAttributes []CustomAttributes `json:"custom_attributes,omitempty"`
ParentID int `json:"parent_id,omitempty"`
}

// CategoryObservation are the observable fields of a Category.
type CategoryObservation struct {
ID int `json:"id,omitempty"`
ParentID int `json:"parent_id,omitempty"`
Name string `json:"name,omitempty"`
IsActive bool `json:"is_active,omitempty"`
Position int `json:"position,omitempty"`
Level int `json:"level,omitempty"`
ProductCount int `json:"product_count,omitempty"`
}

// A CategorySpec defines the desired state of a Category.
type CategorySpec struct {
xpv1.ResourceSpec `json:",inline"`
ForProvider CategoryParameters `json:"forProvider"`
}

// A CategoryStatus represents the observed state of a Category.
type CategoryStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider CategoryObservation `json:"atProvider,omitempty"`
}

// +kubebuilder:object:root=true

// A Category 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,magento}
type Category struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CategorySpec `json:"spec"`
Status CategoryStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

// Category type metadata.
var (
CategoryKind = reflect.TypeOf(Category{}).Name()
CategoryGroupKind = schema.GroupKind{Group: Group, Kind: CategoryKind}.String()
CategoryKindAPIVersion = CategoryKind + "." + SchemeGroupVersion.String()
CategoryGroupVersionKind = SchemeGroupVersion.WithKind(CategoryKind)
)

func init() {
SchemeBuilder.Register(&Category{}, &CategoryList{})
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Crossplane Authors.
Copyright 2022 The Crossplane Authors.
ca7alindev marked this conversation as resolved.
Show resolved Hide resolved

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
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 Magento provider.
// +kubebuilder:object:generate=true
// +groupName=sample.template.crossplane.io
// +groupName=categories.magento.crossplane.io
// +versionName=v1alpha1
package v1alpha1

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

// Package type metadata.
const (
Group = "sample.template.crossplane.io"
Group = "categories.magento.crossplane.io"
ca7alindev marked this conversation as resolved.
Show resolved Hide resolved
Version = "v1alpha1"
)

Expand Down
Loading
Loading