From b2e7f5ab388d028aa249063b5afbc67ec9877aba Mon Sep 17 00:00:00 2001 From: xchen8421 Date: Fri, 31 May 2024 10:34:51 -0700 Subject: [PATCH] diff-1 --- LICENSE | 2 +- Makefile | 6 +- README.md | 18 +- apis/null/v1alpha1/zz_generated.deepcopy.go | 205 ------------------ apis/null/v1alpha1/zz_generated.managed.go | 68 ------ .../null/v1alpha1/zz_generated.managedlist.go | 17 -- .../null/v1alpha1/zz_generated_terraformed.go | 102 --------- apis/null/v1alpha1/zz_groupversion_info.go | 36 --- apis/null/v1alpha1/zz_resource_types.go | 98 --------- apis/v1alpha1/doc.go | 4 +- apis/v1alpha1/register.go | 2 +- apis/v1alpha1/types.go | 4 +- apis/v1beta1/doc.go | 4 +- apis/v1beta1/register.go | 2 +- apis/v1beta1/types.go | 6 +- apis/zz_register.go | 6 +- .../Dockerfile | 0 .../Makefile | 0 .../terraformrc.hcl | 0 cluster/test/setup.sh | 2 +- cmd/generator/main.go | 2 +- cmd/provider/main.go | 22 +- config/null/config.go | 17 -- config/provider.go | 8 +- examples-generated/null/resource.yaml | 2 +- examples/install.yaml | 4 +- examples/null/resource.yaml | 2 +- examples/providerconfig/providerconfig.yaml | 2 +- examples/storeconfig/vault.yaml | 2 +- go.mod | 2 +- internal/clients/{template.go => github.go} | 4 +- .../controller/null/resource/zz_controller.go | 4 +- internal/controller/providerconfig/config.go | 2 +- internal/controller/zz_setup.go | 4 +- .../null.template.upbound.io_resources.yaml | 6 +- .../template.upbound.io_providerconfigs.yaml | 8 +- ...plate.upbound.io_providerconfigusages.yaml | 6 +- .../template.upbound.io_storeconfigs.yaml | 8 +- package/crossplane.yaml | 2 +- 39 files changed, 73 insertions(+), 616 deletions(-) delete mode 100644 apis/null/v1alpha1/zz_generated.deepcopy.go delete mode 100644 apis/null/v1alpha1/zz_generated.managed.go delete mode 100644 apis/null/v1alpha1/zz_generated.managedlist.go delete mode 100755 apis/null/v1alpha1/zz_generated_terraformed.go delete mode 100755 apis/null/v1alpha1/zz_groupversion_info.go delete mode 100755 apis/null/v1alpha1/zz_resource_types.go rename cluster/images/{upjet-provider-template => provider-github}/Dockerfile (100%) rename cluster/images/{upjet-provider-template => provider-github}/Makefile (100%) rename cluster/images/{upjet-provider-template => provider-github}/terraformrc.hcl (100%) delete mode 100644 config/null/config.go rename internal/clients/{template.go => github.go} (94%) diff --git a/LICENSE b/LICENSE index 5695f4d..9b0d144 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [YEAR] Upbound Inc. All rights reserved. + Copyright 2024 Upbound Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index 9319734..e05ae89 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # ==================================================================================== # Setup Project -PROJECT_NAME ?= upjet-provider-template -PROJECT_REPO ?= github.com/upbound/$(PROJECT_NAME) +PROJECT_NAME ?= provider-github +PROJECT_REPO ?= github.com/test-my-org/$(PROJECT_NAME) export TERRAFORM_VERSION ?= 1.2.1 @@ -89,7 +89,7 @@ fallthrough: submodules # NOTE(hasheddan): we force image building to happen prior to xpkg build so that # we ensure image is present in daemon. -xpkg.build.upjet-provider-template: do.build.images +xpkg.build.provider-github: do.build.images # NOTE(hasheddan): we ensure up is installed prior to running platform-specific # build steps in parallel to avoid encountering an installation race condition. diff --git a/README.md b/README.md index e57c399..f2b3a38 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# Provider Template +# Provider GitHub -`upjet-provider-template` is a [Crossplane](https://crossplane.io/) provider that +`provider-github` is a [Crossplane](https://crossplane.io/) provider that is built using [Upjet](https://github.com/crossplane/upjet) code generation tools and exposes XRM-conformant managed resources for the -Template API. +GitHub API. ## Getting Started Install the provider by using the following command after changing the image tag -to the [latest release](https://marketplace.upbound.io/providers/upbound/upjet-provider-template): +to the [latest release](https://marketplace.upbound.io/providers/test-my-org/provider-github): ``` -up ctp provider install upbound/upjet-provider-template:v0.1.0 +up ctp provider install test-my-org/provider-github:v0.1.0 ``` Alternatively, you can use declarative installation: @@ -19,15 +19,15 @@ cat < -// -// SPDX-License-Identifier: Apache-2.0 - -/* -Copyright 2022 Upbound Inc. -*/ - -// Code generated by upjet. DO NOT EDIT. - -package v1alpha1 - -import ( - "github.com/pkg/errors" - - "github.com/crossplane/upjet/pkg/resource" - "github.com/crossplane/upjet/pkg/resource/json" -) - -// GetTerraformResourceType returns Terraform resource type for this Resource -func (mg *Resource) GetTerraformResourceType() string { - return "null_resource" -} - -// GetConnectionDetailsMapping for this Resource -func (tr *Resource) GetConnectionDetailsMapping() map[string]string { - return nil -} - -// GetObservation of this Resource -func (tr *Resource) GetObservation() (map[string]any, error) { - o, err := json.TFParser.Marshal(tr.Status.AtProvider) - if err != nil { - return nil, err - } - base := map[string]any{} - return base, json.TFParser.Unmarshal(o, &base) -} - -// SetObservation for this Resource -func (tr *Resource) SetObservation(obs map[string]any) error { - p, err := json.TFParser.Marshal(obs) - if err != nil { - return err - } - return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) -} - -// GetID returns ID of underlying Terraform resource of this Resource -func (tr *Resource) GetID() string { - if tr.Status.AtProvider.ID == nil { - return "" - } - return *tr.Status.AtProvider.ID -} - -// GetParameters of this Resource -func (tr *Resource) GetParameters() (map[string]any, error) { - p, err := json.TFParser.Marshal(tr.Spec.ForProvider) - if err != nil { - return nil, err - } - base := map[string]any{} - return base, json.TFParser.Unmarshal(p, &base) -} - -// SetParameters for this Resource -func (tr *Resource) SetParameters(params map[string]any) error { - p, err := json.TFParser.Marshal(params) - if err != nil { - return err - } - return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) -} - -// GetInitParameters of this Resource -func (tr *Resource) GetInitParameters() (map[string]any, error) { - p, err := json.TFParser.Marshal(tr.Spec.InitProvider) - if err != nil { - return nil, err - } - base := map[string]any{} - return base, json.TFParser.Unmarshal(p, &base) -} - -// LateInitialize this Resource using its observed tfState. -// returns True if there are any spec changes for the resource. -func (tr *Resource) LateInitialize(attrs []byte) (bool, error) { - params := &ResourceParameters{} - if err := json.TFParser.Unmarshal(attrs, params); err != nil { - return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") - } - opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} - - li := resource.NewGenericLateInitializer(opts...) - return li.LateInitialize(&tr.Spec.ForProvider, params) -} - -// GetTerraformSchemaVersion returns the associated Terraform schema version -func (tr *Resource) GetTerraformSchemaVersion() int { - return 0 -} diff --git a/apis/null/v1alpha1/zz_groupversion_info.go b/apis/null/v1alpha1/zz_groupversion_info.go deleted file mode 100755 index 3b570c9..0000000 --- a/apis/null/v1alpha1/zz_groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: 2023 The Crossplane Authors -// -// SPDX-License-Identifier: Apache-2.0 - -/* -Copyright 2022 Upbound Inc. -*/ - -// Code generated by upjet. DO NOT EDIT. - -// +kubebuilder:object:generate=true -// +groupName=null.template.upbound.io -// +versionName=v1alpha1 -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -// Package type metadata. -const ( - CRDGroup = "null.template.upbound.io" - CRDVersion = "v1alpha1" -) - -var ( - // CRDGroupVersion is the API Group Version used to register the objects - CRDGroupVersion = schema.GroupVersion{Group: CRDGroup, Version: CRDVersion} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: CRDGroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/apis/null/v1alpha1/zz_resource_types.go b/apis/null/v1alpha1/zz_resource_types.go deleted file mode 100755 index 7801a3b..0000000 --- a/apis/null/v1alpha1/zz_resource_types.go +++ /dev/null @@ -1,98 +0,0 @@ -// SPDX-FileCopyrightText: 2023 The Crossplane Authors -// -// SPDX-License-Identifier: Apache-2.0 - -/* -Copyright 2022 Upbound Inc. -*/ - -// Code generated by upjet. DO NOT EDIT. - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - - v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" -) - -type ResourceInitParameters struct { - - // A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. - Triggers map[string]*string `json:"triggers,omitempty" tf:"triggers,omitempty"` -} - -type ResourceObservation struct { - ID *string `json:"id,omitempty" tf:"id,omitempty"` - - // A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. - Triggers map[string]*string `json:"triggers,omitempty" tf:"triggers,omitempty"` -} - -type ResourceParameters struct { - - // A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners. - // +kubebuilder:validation:Optional - Triggers map[string]*string `json:"triggers,omitempty" tf:"triggers,omitempty"` -} - -// ResourceSpec defines the desired state of Resource -type ResourceSpec struct { - v1.ResourceSpec `json:",inline"` - ForProvider ResourceParameters `json:"forProvider"` - // THIS IS A BETA FIELD. It will be honored - // unless the Management Policies feature flag is disabled. - // InitProvider holds the same fields as ForProvider, with the exception - // of Identifier and other resource reference fields. The fields that are - // in InitProvider are merged into ForProvider when the resource is created. - // The same fields are also added to the terraform ignore_changes hook, to - // avoid updating them after creation. This is useful for fields that are - // required on creation, but we do not desire to update them after creation, - // for example because of an external controller is managing them, like an - // autoscaler. - InitProvider ResourceInitParameters `json:"initProvider,omitempty"` -} - -// ResourceStatus defines the observed state of Resource. -type ResourceStatus struct { - v1.ResourceStatus `json:",inline"` - AtProvider ResourceObservation `json:"atProvider,omitempty"` -} - -// +kubebuilder:object:root=true - -// Resource is the Schema for the Resources API. The null_resource resource implements the standard resource lifecycle but takes no further action. The triggers argument allows specifying an arbitrary set of values that, when changed, will cause the resource to be replaced. -// +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 Resource struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ResourceSpec `json:"spec"` - Status ResourceStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// ResourceList contains a list of Resources -type ResourceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Resource `json:"items"` -} - -// Repository type metadata. -var ( - Resource_Kind = "Resource" - Resource_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: Resource_Kind}.String() - Resource_KindAPIVersion = Resource_Kind + "." + CRDGroupVersion.String() - Resource_GroupVersionKind = CRDGroupVersion.WithKind(Resource_Kind) -) - -func init() { - SchemeBuilder.Register(&Resource{}, &ResourceList{}) -} diff --git a/apis/v1alpha1/doc.go b/apis/v1alpha1/doc.go index 468ffa7..dd192f9 100644 --- a/apis/v1alpha1/doc.go +++ b/apis/v1alpha1/doc.go @@ -2,8 +2,8 @@ Copyright 2021 Upbound Inc. */ -// Package v1alpha1 contains the core resources of the template jet provider. +// Package v1alpha1 contains the core resources of the github jet provider. // +kubebuilder:object:generate=true -// +groupName=template.upbound.io +// +groupName=github.crossplan.io // +versionName=v1alpha1 package v1alpha1 diff --git a/apis/v1alpha1/register.go b/apis/v1alpha1/register.go index 038d8b3..2cc8279 100644 --- a/apis/v1alpha1/register.go +++ b/apis/v1alpha1/register.go @@ -13,7 +13,7 @@ import ( // Package type metadata. const ( - Group = "template.upbound.io" + Group = "github.crossplan.io" Version = "v1alpha1" ) diff --git a/apis/v1alpha1/types.go b/apis/v1alpha1/types.go index 3f8f25a..59c3eef 100644 --- a/apis/v1alpha1/types.go +++ b/apis/v1alpha1/types.go @@ -22,11 +22,11 @@ type StoreConfigStatus struct { // +kubebuilder:object:root=true -// A StoreConfig configures how template controller should store connection details. +// A StoreConfig configures how github controller should store connection details. // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" // +kubebuilder:printcolumn:name="TYPE",type="string",JSONPath=".spec.type" // +kubebuilder:printcolumn:name="DEFAULT-SCOPE",type="string",JSONPath=".spec.defaultScope" -// +kubebuilder:resource:scope=Cluster,categories={crossplane,store,template} +// +kubebuilder:resource:scope=Cluster,categories={crossplane,store,github} // +kubebuilder:subresource:status type StoreConfig struct { metav1.TypeMeta `json:",inline"` diff --git a/apis/v1beta1/doc.go b/apis/v1beta1/doc.go index 71a80b6..6dd5e18 100644 --- a/apis/v1beta1/doc.go +++ b/apis/v1beta1/doc.go @@ -2,8 +2,8 @@ Copyright 2022 Upbound Inc. */ -// Package v1beta1 contains the core resources of the template upjet provider. +// Package v1beta1 contains the core resources of the github upjet provider. // +kubebuilder:object:generate=true -// +groupName=template.upbound.io +// +groupName=github.crossplan.io // +versionName=v1beta1 package v1beta1 diff --git a/apis/v1beta1/register.go b/apis/v1beta1/register.go index a99c36e..5000440 100644 --- a/apis/v1beta1/register.go +++ b/apis/v1beta1/register.go @@ -13,7 +13,7 @@ import ( // Package type metadata. const ( - Group = "template.upbound.io" + Group = "github.crossplan.io" Version = "v1beta1" ) diff --git a/apis/v1beta1/types.go b/apis/v1beta1/types.go index 110474a..30d8686 100644 --- a/apis/v1beta1/types.go +++ b/apis/v1beta1/types.go @@ -32,12 +32,12 @@ type ProviderConfigStatus struct { // +kubebuilder:object:root=true -// A ProviderConfig configures a Template provider. +// A ProviderConfig configures a GitHub provider. // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" // +kubebuilder:printcolumn:name="SECRET-NAME",type="string",JSONPath=".spec.credentials.secretRef.name",priority=1 // +kubebuilder:resource:scope=Cluster -// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,template} +// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,github} type ProviderConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -62,7 +62,7 @@ type ProviderConfigList struct { // +kubebuilder:printcolumn:name="CONFIG-NAME",type="string",JSONPath=".providerConfigRef.name" // +kubebuilder:printcolumn:name="RESOURCE-KIND",type="string",JSONPath=".resourceRef.kind" // +kubebuilder:printcolumn:name="RESOURCE-NAME",type="string",JSONPath=".resourceRef.name" -// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,template} +// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,github} type ProviderConfigUsage struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/apis/zz_register.go b/apis/zz_register.go index 9a6d212..7137cb3 100755 --- a/apis/zz_register.go +++ b/apis/zz_register.go @@ -14,9 +14,9 @@ package apis import ( "k8s.io/apimachinery/pkg/runtime" - v1alpha1 "github.com/upbound/upjet-provider-template/apis/null/v1alpha1" - v1alpha1apis "github.com/upbound/upjet-provider-template/apis/v1alpha1" - v1beta1 "github.com/upbound/upjet-provider-template/apis/v1beta1" + v1alpha1 "github.com/test-my-org/provider-github/apis/null/v1alpha1" + v1alpha1apis "github.com/test-my-org/provider-github/apis/v1alpha1" + v1beta1 "github.com/test-my-org/provider-github/apis/v1beta1" ) func init() { diff --git a/cluster/images/upjet-provider-template/Dockerfile b/cluster/images/provider-github/Dockerfile similarity index 100% rename from cluster/images/upjet-provider-template/Dockerfile rename to cluster/images/provider-github/Dockerfile diff --git a/cluster/images/upjet-provider-template/Makefile b/cluster/images/provider-github/Makefile similarity index 100% rename from cluster/images/upjet-provider-template/Makefile rename to cluster/images/provider-github/Makefile diff --git a/cluster/images/upjet-provider-template/terraformrc.hcl b/cluster/images/provider-github/terraformrc.hcl similarity index 100% rename from cluster/images/upjet-provider-template/terraformrc.hcl rename to cluster/images/provider-github/terraformrc.hcl diff --git a/cluster/test/setup.sh b/cluster/test/setup.sh index f1138cc..716edd2 100755 --- a/cluster/test/setup.sh +++ b/cluster/test/setup.sh @@ -13,7 +13,7 @@ ${KUBECTL} -n upbound-system wait --for=condition=Available deployment --all --t echo "Creating a default provider config..." cat <