Skip to content

Commit

Permalink
Switch cli based architecture
Browse files Browse the repository at this point in the history
Signed-off-by: Fatih Türken <[email protected]>
  • Loading branch information
turkenf committed Oct 17, 2024
1 parent 8821bee commit b117bea
Show file tree
Hide file tree
Showing 61 changed files with 271 additions and 556 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ====================================================================================
# Setup Project

PROJECT_NAME ?= provider-upjet-azapi
PROJECT_NAME ?= provider-azapi
PROJECT_REPO ?= github.com/upbound/$(PROJECT_NAME)

export TERRAFORM_VERSION ?= 1.5.7
Expand All @@ -14,10 +14,11 @@ export TERRAFORM_PROVIDER_SOURCE ?= Azure/azapi
export TERRAFORM_PROVIDER_REPO ?= https://github.com/Azure/terraform-provider-azapi
export TERRAFORM_PROVIDER_VERSION ?= 1.12.1
export TERRAFORM_PROVIDER_DOWNLOAD_NAME ?= terraform-provider-azapi
export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX ?= https://github.com/Azure/$(TERRAFORM_PROVIDER_DOWNLOAD_NAME)/releases/download/$(TERRAFORM_PROVIDER_VERSION)
export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX ?= https://github.com/Azure/$(TERRAFORM_PROVIDER_DOWNLOAD_NAME)/releases/download/v$(TERRAFORM_PROVIDER_VERSION)
export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-azapi_v1.12.1
export TERRAFORM_DOCS_PATH ?= docs/resources


PLATFORMS ?= linux_amd64 linux_arm64

# -include will silently skip missing files, which allows us
Expand Down Expand Up @@ -56,7 +57,7 @@ GO_SUBDIRS += cmd internal apis
KIND_VERSION = v0.15.0
UP_VERSION = v0.28.0
UP_CHANNEL = stable
UPTEST_VERSION = v0.5.0
UPTEST_VERSION = v1.1.2
-include build/makelib/k8s_tools.mk

# ====================================================================================
Expand Down Expand Up @@ -92,7 +93,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.provider-upjet-azapi: do.build.images
xpkg.build.provider-azapi: 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.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Provider AzAPI

`provider-upjet-azapi` is a [Crossplane](https://crossplane.io/) provider that
Provider Upjet-AzAPI 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
AzAPI 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/provider-upjet-azapi):
to the [latest release](https://marketplace.upbound.io/providers/upbound/provider-azapi):
```
up ctp provider install upbound/provider-upjet-azapi:v0.1.0
up ctp provider install upbound/provider-azapi:v0.1.0
```

Alternatively, you can use declarative installation:
Expand All @@ -19,15 +19,15 @@ cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-upjet-azapi
name: provider-azapi
spec:
package: upbound/provider-upjet-azapi:v0.1.0
package: upbound/provider-azapi:v0.1.0
EOF
```

Notice that in this example Provider resource is referencing ControllerConfig with debug enabled.

You can see the API reference [here](https://doc.crds.dev/github.com/upbound/provider-upjet-azapi).
You can see the API reference [here](https://doc.crds.dev/github.com/upbound/provider-azapi).

## Developing

Expand Down Expand Up @@ -57,4 +57,4 @@ make build
## Report a Bug

For filing bugs, suggesting improvements, or requesting new features, please
open an [issue](https://github.com/upbound/provider-upjet-azapi/issues).
open an [issue](https://github.com/upbound/provider-upjet-azapi/issues).

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

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

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

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

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

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

10 changes: 5 additions & 5 deletions apis/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
Copyright 2021 Upbound Inc.
*/
// SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
//
// SPDX-License-Identifier: Apache-2.0

// Package v1alpha1 contains the core resources of the upjet-azapi jet provider.
// Package v1alpha1 contains the core resources of the azapi jet provider.
// +kubebuilder:object:generate=true
// +groupName=upjet-azapi.upbound.io
// +groupName=azapi.upbound.io
// +versionName=v1alpha1
package v1alpha1
8 changes: 4 additions & 4 deletions apis/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2021 Upbound Inc.
*/
// SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
//
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

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

// Package type metadata.
const (
Group = "upjet-azapi.upbound.io"
Group = "azapi.upbound.io"
Version = "v1alpha1"
)

Expand Down
10 changes: 5 additions & 5 deletions apis/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2021 Upbound Inc.
*/
// SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
//
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

Expand All @@ -22,11 +22,11 @@ type StoreConfigStatus struct {

// +kubebuilder:object:root=true

// A StoreConfig configures how upjet-azapi controller should store connection details.
// A StoreConfig configures how azapi 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,upjet-azapi}
// +kubebuilder:resource:scope=Cluster,categories={crossplane,store,azapi}
// +kubebuilder:subresource:status
type StoreConfig struct {
metav1.TypeMeta `json:",inline"`
Expand Down
10 changes: 5 additions & 5 deletions apis/v1beta1/doc.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
Copyright 2022 Upbound Inc.
*/
// SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
//
// SPDX-License-Identifier: Apache-2.0

// Package v1beta1 contains the core resources of the upjet-azapi upjet provider.
// Package v1beta1 contains the core resources of the azapi upjet provider.
// +kubebuilder:object:generate=true
// +groupName=upjet-azapi.upbound.io
// +groupName=azapi.upbound.io
// +versionName=v1beta1
package v1beta1
2 changes: 1 addition & 1 deletion apis/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

// Package type metadata.
const (
Group = "upjet-azapi.upbound.io"
Group = "azapi.upbound.io"
Version = "v1beta1"
)

Expand Down
45 changes: 4 additions & 41 deletions apis/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,12 @@ import (
type ProviderConfigSpec struct {
// Credentials required to authenticate to this provider.
Credentials ProviderCredentials `json:"credentials"`

// ClientID is the user-assigned managed identity's ID
// when Credentials.Source is `InjectedIdentity`. If unset and
// Credentials.Source is `InjectedIdentity`, then a system-assigned
// managed identity is used.
// +optional
ClientID *string `json:"clientID,omitempty"`

// SubscriptionID is the Azure subscription ID to be used.
// If unset, subscription ID from Credentials will be used.
// Required if Credentials.Source is InjectedIdentity.
// +kubebuilder:validation:Optional
SubscriptionID *string `json:"subscriptionID,omitempty"`

// TenantID is the Azure AD tenant ID to be used.
// If unset, tenant ID from Credentials will be used.
// Required if Credentials.Source is InjectedIdentity.
// +kubebuilder:validation:Optional
TenantID *string `json:"tenantID,omitempty"`

// MSIEndpoint is the optional path to a custom endpoint for
// Managed Service Identity.
// +kubebuilder:validation:Optional
MSIEndpoint *string `json:"msiEndpoint,omitempty"`

// The Cloud Environment which should be used. Possible values are "public",
// "usgovernment", "german", and "china". Defaults to "public".
// +kubebuilder:validation:Optional
Environment *string `json:"environment,omitempty"`

// OIDCTokenFilePath is the optional path to a token file
// that allows to access a managed identity.
// +kubebuilder:validation:Optional
OidcTokenFilePath *string `json:"oidcTokenFilePath,omitempty"`
}

// ProviderCredentials required to authenticate.
type ProviderCredentials struct {
// Source of the provider credentials.
// +kubebuilder:validation:Enum=None;Secret;UserAssignedManagedIdentity;SystemAssignedManagedIdentity;OIDCTokenFile;Upbound;Filesystem
// +kubebuilder:validation:Enum=None;Secret;InjectedIdentity;Environment;Filesystem
Source xpv1.CredentialsSource `json:"source"`

xpv1.CommonCredentialSelectors `json:",inline"`
Expand All @@ -66,13 +32,12 @@ type ProviderConfigStatus struct {

// +kubebuilder:object:root=true

// A ProviderConfig configures the Azure provider.
// A ProviderConfig configures a AzAPI 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,providerconfig,azure}
// +kubebuilder:storageversion
// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,azapi}
type ProviderConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -97,9 +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"
// Please replace `PROVIDER-NAME` with your actual provider name, like `aws`, `azure`, `gcp`, `alibaba`
// +kubebuilder:resource:scope=Cluster,categories={crossplane,providerconfig,azure}
// +kubebuilder:storageversion
// +kubebuilder:resource:scope=Cluster,categories={crossplane,provider,azapi}
type ProviderConfigUsage struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
30 changes: 0 additions & 30 deletions apis/v1beta1/zz_generated.deepcopy.go

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

6 changes: 3 additions & 3 deletions apis/zz_register.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
Expand Up @@ -27,15 +27,15 @@ ENV TF_FORK 0
RUN mkdir -p ${PLUGIN_DIR}

ADD https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${TARGETOS}_${TARGETARCH}.zip /tmp
ADD ${TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX}/${TERRAFORM_PROVIDER_DOWNLOAD_NAME}_${TERRAFORM_PROVIDER_VERSION}_${TARGETOS}_${TARGETARCH}.zip /tmp
ADD ${TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX}/${TERRAFORM_PROVIDER_DOWNLOAD_NAME}_v${TERRAFORM_PROVIDER_VERSION}_${TARGETOS}_${TARGETARCH}.zip /tmp
ADD terraformrc.hcl ${TF_CLI_CONFIG_FILE}

RUN unzip /tmp/terraform_${TERRAFORM_VERSION}_${TARGETOS}_${TARGETARCH}.zip -d /usr/local/bin \
&& chmod +x /usr/local/bin/terraform \
&& rm /tmp/terraform_${TERRAFORM_VERSION}_${TARGETOS}_${TARGETARCH}.zip \
&& unzip /tmp/${TERRAFORM_PROVIDER_DOWNLOAD_NAME}_${TERRAFORM_PROVIDER_VERSION}_${TARGETOS}_${TARGETARCH}.zip -d ${PLUGIN_DIR} \
&& unzip /tmp/${TERRAFORM_PROVIDER_DOWNLOAD_NAME}_v${TERRAFORM_PROVIDER_VERSION}_${TARGETOS}_${TARGETARCH}.zip -d ${PLUGIN_DIR} \
&& chmod +x ${PLUGIN_DIR}/* \
&& rm /tmp/${TERRAFORM_PROVIDER_DOWNLOAD_NAME}_${TERRAFORM_PROVIDER_VERSION}_${TARGETOS}_${TARGETARCH}.zip \
&& rm /tmp/${TERRAFORM_PROVIDER_DOWNLOAD_NAME}_v${TERRAFORM_PROVIDER_VERSION}_${TARGETOS}_${TARGETARCH}.zip \
&& chown -R ${USER_ID}:${USER_ID} /terraform
# End of - Setup Terraform environment

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cluster/test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ${KUBECTL} -n upbound-system wait --for=condition=Available deployment --all --t

echo "Creating a default provider config..."
cat <<EOF | ${KUBECTL} apply -f -
apiVersion: upjet-azapi.upbound.io/v1beta1
apiVersion: azapi.upbound.io/v1beta1
kind: ProviderConfig
metadata:
name: default
Expand Down
2 changes: 1 addition & 1 deletion cmd/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/crossplane/upjet/pkg/pipeline"

"github.com/upbound/provider-upjet-azapi/config"
"github.com/upbound/provider-azapi/config"
)

func main() {
Expand Down
Loading

0 comments on commit b117bea

Please sign in to comment.