From 556a4a2d284509215288182235566c5c60b3bae8 Mon Sep 17 00:00:00 2001 From: Harsh Bhandari Date: Thu, 24 Oct 2024 15:44:15 +0530 Subject: [PATCH] Switch to philips-labs/terraform-provider-unleash --- Makefile | 12 +- apis/api/v1alpha1/zz_generated.deepcopy.go | 61 ++- apis/api/v1alpha1/zz_token_terraformed.go | 2 +- apis/api/v1alpha1/zz_token_types.go | 109 ++-- config/provider-metadata.yaml | 517 ++++++++---------- config/schema.json | 2 +- examples-generated/api/v1alpha1/token.yaml | 15 +- examples/token/token.yaml | 11 +- internal/clients/unleash.go | 4 +- .../api.unleash.crossplane.io_tokens.yaml | 149 +++-- 10 files changed, 441 insertions(+), 441 deletions(-) diff --git a/Makefile b/Makefile index 33d576a..8a82392 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,12 @@ export TERRAFORM_VERSION ?= 1.5.7 # licensed under BSL, which is not permitted. TERRAFORM_VERSION_VALID := $(shell [ "$(TERRAFORM_VERSION)" = "`printf "$(TERRAFORM_VERSION)\n1.6" | sort -V | head -n1`" ] && echo 1 || echo 0) -export TERRAFORM_PROVIDER_SOURCE ?= Unleash/unleash -export TERRAFORM_PROVIDER_REPO ?= https://github.com/Unleash/terraform-provider-unleash -export TERRAFORM_PROVIDER_VERSION ?= 1.3.0 +export TERRAFORM_PROVIDER_SOURCE ?= philips-labs/unleash +export TERRAFORM_PROVIDER_REPO ?= https://github.com/philips-labs/terraform-provider-unleash +export TERRAFORM_PROVIDER_VERSION ?= 0.3.9 export TERRAFORM_PROVIDER_DOWNLOAD_NAME ?= terraform-provider-unleash -export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX ?= https://github.com/Unleash/$(TERRAFORM_PROVIDER_DOWNLOAD_NAME)/releases/download/v$(TERRAFORM_PROVIDER_VERSION) -export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-unleash_1.3.0 +export TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX ?= ${TERRAFORM_PROVIDER_REPO}/releases/download/v$(TERRAFORM_PROVIDER_VERSION) +export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-unleash_0.3.9 export TERRAFORM_DOCS_PATH ?= docs/resources PLATFORMS ?= linux_amd64 linux_arm64 @@ -178,7 +178,7 @@ CROSSPLANE_NAMESPACE = upbound-system # This target requires the following environment variables to be set: # - UPTEST_EXAMPLE_LIST, a comma-separated list of examples to test # To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately. -# You can check the basic implementation here: https://github.com/crossplane/uptest/blob/main/internal/templates/03-delete.yaml.tmpl. +# You can check the basic implementation here: https://github.com/crossplane/uptest/blob/main/internal/unleashs/03-delete.yaml.tmpl. # - UPTEST_CLOUD_CREDENTIALS (optional), multiple sets of AWS IAM User credentials specified as key=value pairs. # The support keys are currently `DEFAULT` and `PEER`. So, an example for the value of this env. variable is: # DEFAULT='[default] diff --git a/apis/api/v1alpha1/zz_generated.deepcopy.go b/apis/api/v1alpha1/zz_generated.deepcopy.go index 22e0346..50c0022 100644 --- a/apis/api/v1alpha1/zz_generated.deepcopy.go +++ b/apis/api/v1alpha1/zz_generated.deepcopy.go @@ -9,6 +9,7 @@ package v1alpha1 import ( + "github.com/crossplane/crossplane-runtime/apis/common/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -42,6 +43,11 @@ func (in *Token) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TokenInitParameters) DeepCopyInto(out *TokenInitParameters) { *out = *in + if in.CreatedAt != nil { + in, out := &in.CreatedAt, &out.CreatedAt + *out = new(string) + **out = **in + } if in.Environment != nil { in, out := &in.Environment, &out.Environment *out = new(string) @@ -52,11 +58,6 @@ func (in *TokenInitParameters) DeepCopyInto(out *TokenInitParameters) { *out = new(string) **out = **in } - if in.Project != nil { - in, out := &in.Project, &out.Project - *out = new(string) - **out = **in - } if in.Projects != nil { in, out := &in.Projects, &out.Projects *out = make([]*string, len(*in)) @@ -68,9 +69,9 @@ func (in *TokenInitParameters) DeepCopyInto(out *TokenInitParameters) { } } } - if in.TokenName != nil { - in, out := &in.TokenName, &out.TokenName - *out = new(string) + if in.SecretSecretRef != nil { + in, out := &in.SecretSecretRef, &out.SecretSecretRef + *out = new(v1.SecretKeySelector) **out = **in } if in.Type != nil { @@ -78,6 +79,11 @@ func (in *TokenInitParameters) DeepCopyInto(out *TokenInitParameters) { *out = new(string) **out = **in } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TokenInitParameters. @@ -125,6 +131,11 @@ func (in *TokenList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TokenObservation) DeepCopyInto(out *TokenObservation) { *out = *in + if in.CreatedAt != nil { + in, out := &in.CreatedAt, &out.CreatedAt + *out = new(string) + **out = **in + } if in.Environment != nil { in, out := &in.Environment, &out.Environment *out = new(string) @@ -140,11 +151,6 @@ func (in *TokenObservation) DeepCopyInto(out *TokenObservation) { *out = new(string) **out = **in } - if in.Project != nil { - in, out := &in.Project, &out.Project - *out = new(string) - **out = **in - } if in.Projects != nil { in, out := &in.Projects, &out.Projects *out = make([]*string, len(*in)) @@ -156,13 +162,13 @@ func (in *TokenObservation) DeepCopyInto(out *TokenObservation) { } } } - if in.TokenName != nil { - in, out := &in.TokenName, &out.TokenName + if in.Type != nil { + in, out := &in.Type, &out.Type *out = new(string) **out = **in } - if in.Type != nil { - in, out := &in.Type, &out.Type + if in.Username != nil { + in, out := &in.Username, &out.Username *out = new(string) **out = **in } @@ -181,6 +187,11 @@ func (in *TokenObservation) DeepCopy() *TokenObservation { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TokenParameters) DeepCopyInto(out *TokenParameters) { *out = *in + if in.CreatedAt != nil { + in, out := &in.CreatedAt, &out.CreatedAt + *out = new(string) + **out = **in + } if in.Environment != nil { in, out := &in.Environment, &out.Environment *out = new(string) @@ -191,11 +202,6 @@ func (in *TokenParameters) DeepCopyInto(out *TokenParameters) { *out = new(string) **out = **in } - if in.Project != nil { - in, out := &in.Project, &out.Project - *out = new(string) - **out = **in - } if in.Projects != nil { in, out := &in.Projects, &out.Projects *out = make([]*string, len(*in)) @@ -207,9 +213,9 @@ func (in *TokenParameters) DeepCopyInto(out *TokenParameters) { } } } - if in.TokenName != nil { - in, out := &in.TokenName, &out.TokenName - *out = new(string) + if in.SecretSecretRef != nil { + in, out := &in.SecretSecretRef, &out.SecretSecretRef + *out = new(v1.SecretKeySelector) **out = **in } if in.Type != nil { @@ -217,6 +223,11 @@ func (in *TokenParameters) DeepCopyInto(out *TokenParameters) { *out = new(string) **out = **in } + if in.Username != nil { + in, out := &in.Username, &out.Username + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TokenParameters. diff --git a/apis/api/v1alpha1/zz_token_terraformed.go b/apis/api/v1alpha1/zz_token_terraformed.go index ca5bf1c..a10c0d7 100755 --- a/apis/api/v1alpha1/zz_token_terraformed.go +++ b/apis/api/v1alpha1/zz_token_terraformed.go @@ -21,7 +21,7 @@ func (mg *Token) GetTerraformResourceType() string { // GetConnectionDetailsMapping for this Token func (tr *Token) GetConnectionDetailsMapping() map[string]string { - return map[string]string{"secret": "status.atProvider.secret"} + return map[string]string{"secret": "secretSecretRef"} } // GetObservation of this Token diff --git a/apis/api/v1alpha1/zz_token_types.go b/apis/api/v1alpha1/zz_token_types.go index 4fd0f4a..eceee74 100755 --- a/apis/api/v1alpha1/zz_token_types.go +++ b/apis/api/v1alpha1/zz_token_types.go @@ -15,94 +15,101 @@ import ( type TokenInitParameters struct { - // (String) An environment the token has access to. - // An environment the token has access to. + // (String) The API token creation date. + // The API token creation date. + CreatedAt *string `json:"createdAt,omitempty" tf:"created_at,omitempty"` + + // (String) The environment the token will have access to. Use "*" for all environments. By default, it will have access to all environments. + // The environment the token will have access to. Use `"*"` for all environments. By default, it will have access to all environments. Environment *string `json:"environment,omitempty" tf:"environment,omitempty"` - // (String) When the token expires - // When the token expires + // (String) The API token expiration date. + // The API token expiration date. ExpiresAt *string `json:"expiresAt,omitempty" tf:"expires_at,omitempty"` - // (String) A project the token belongs to. - // A project the token belongs to. - Project *string `json:"project,omitempty" tf:"project,omitempty"` - - // (Set of String) The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [*]. - // The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as `[*]`. + // (Set of String) The project(s) the token will have access to. Use ["*"] for all projects. By default, it will have access to all projects. + // The project(s) the token will have access to. Use `["*"]` for all projects. By default, it will have access to all projects. // +listType=set Projects []*string `json:"projects,omitempty" tf:"projects,omitempty"` - // (String) The name of the token. - // The name of the token. - TokenName *string `json:"tokenName,omitempty" tf:"token_name,omitempty"` + // (String, Sensitive) The API token secret. + // The API token secret. + SecretSecretRef *v1.SecretKeySelector `json:"secretSecretRef,omitempty" tf:"-"` - // (String) The type of the token. - // The type of the token. + // (String) The type of the API token. Can be client, admin or frontend + // The type of the API token. Can be `client`, `admin` or `frontend` Type *string `json:"type,omitempty" tf:"type,omitempty"` + + // (String) + Username *string `json:"username,omitempty" tf:"username,omitempty"` } type TokenObservation struct { - // (String) An environment the token has access to. - // An environment the token has access to. + // (String) The API token creation date. + // The API token creation date. + CreatedAt *string `json:"createdAt,omitempty" tf:"created_at,omitempty"` + + // (String) The environment the token will have access to. Use "*" for all environments. By default, it will have access to all environments. + // The environment the token will have access to. Use `"*"` for all environments. By default, it will have access to all environments. Environment *string `json:"environment,omitempty" tf:"environment,omitempty"` - // (String) When the token expires - // When the token expires + // (String) The API token expiration date. + // The API token expiration date. ExpiresAt *string `json:"expiresAt,omitempty" tf:"expires_at,omitempty"` + // (String) The ID of this resource. ID *string `json:"id,omitempty" tf:"id,omitempty"` - // (String) A project the token belongs to. - // A project the token belongs to. - Project *string `json:"project,omitempty" tf:"project,omitempty"` - - // (Set of String) The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [*]. - // The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as `[*]`. + // (Set of String) The project(s) the token will have access to. Use ["*"] for all projects. By default, it will have access to all projects. + // The project(s) the token will have access to. Use `["*"]` for all projects. By default, it will have access to all projects. // +listType=set Projects []*string `json:"projects,omitempty" tf:"projects,omitempty"` - // (String) The name of the token. - // The name of the token. - TokenName *string `json:"tokenName,omitempty" tf:"token_name,omitempty"` - - // (String) The type of the token. - // The type of the token. + // (String) The type of the API token. Can be client, admin or frontend + // The type of the API token. Can be `client`, `admin` or `frontend` Type *string `json:"type,omitempty" tf:"type,omitempty"` + + // (String) + Username *string `json:"username,omitempty" tf:"username,omitempty"` } type TokenParameters struct { - // (String) An environment the token has access to. - // An environment the token has access to. + // (String) The API token creation date. + // The API token creation date. // +kubebuilder:validation:Optional - Environment *string `json:"environment,omitempty" tf:"environment,omitempty"` + CreatedAt *string `json:"createdAt,omitempty" tf:"created_at,omitempty"` - // (String) When the token expires - // When the token expires + // (String) The environment the token will have access to. Use "*" for all environments. By default, it will have access to all environments. + // The environment the token will have access to. Use `"*"` for all environments. By default, it will have access to all environments. // +kubebuilder:validation:Optional - ExpiresAt *string `json:"expiresAt,omitempty" tf:"expires_at,omitempty"` + Environment *string `json:"environment,omitempty" tf:"environment,omitempty"` - // (String) A project the token belongs to. - // A project the token belongs to. + // (String) The API token expiration date. + // The API token expiration date. // +kubebuilder:validation:Optional - Project *string `json:"project,omitempty" tf:"project,omitempty"` + ExpiresAt *string `json:"expiresAt,omitempty" tf:"expires_at,omitempty"` - // (Set of String) The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [*]. - // The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as `[*]`. + // (Set of String) The project(s) the token will have access to. Use ["*"] for all projects. By default, it will have access to all projects. + // The project(s) the token will have access to. Use `["*"]` for all projects. By default, it will have access to all projects. // +kubebuilder:validation:Optional // +listType=set Projects []*string `json:"projects,omitempty" tf:"projects,omitempty"` - // (String) The name of the token. - // The name of the token. + // (String, Sensitive) The API token secret. + // The API token secret. // +kubebuilder:validation:Optional - TokenName *string `json:"tokenName,omitempty" tf:"token_name,omitempty"` + SecretSecretRef *v1.SecretKeySelector `json:"secretSecretRef,omitempty" tf:"-"` - // (String) The type of the token. - // The type of the token. + // (String) The type of the API token. Can be client, admin or frontend + // The type of the API token. Can be `client`, `admin` or `frontend` // +kubebuilder:validation:Optional Type *string `json:"type,omitempty" tf:"type,omitempty"` + + // (String) + // +kubebuilder:validation:Optional + Username *string `json:"username,omitempty" tf:"username,omitempty"` } // TokenSpec defines the desired state of Token @@ -132,7 +139,7 @@ type TokenStatus struct { // +kubebuilder:subresource:status // +kubebuilder:storageversion -// Token is the Schema for the Tokens API. ApiToken schema +// Token is the Schema for the Tokens API. Provides a resource for managing unleash api tokens. // +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" // +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" // +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" @@ -141,8 +148,10 @@ type TokenStatus struct { type Token struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec TokenSpec `json:"spec"` - Status TokenStatus `json:"status,omitempty"` + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.type) || (has(self.initProvider) && has(self.initProvider.type))",message="spec.forProvider.type is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.username) || (has(self.initProvider) && has(self.initProvider.username))",message="spec.forProvider.username is a required parameter" + Spec TokenSpec `json:"spec"` + Status TokenStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/config/provider-metadata.yaml b/config/provider-metadata.yaml index 456ad81..0b035f6 100644 --- a/config/provider-metadata.yaml +++ b/config/provider-metadata.yaml @@ -1,369 +1,304 @@ -name: Unleash/unleash +name: philips-labs/unleash resources: unleash_api_token: subCategory: "" - description: ApiToken schema + description: Provides a resource for managing unleash api tokens. name: unleash_api_token title: unleash_api_token Resource - terraform-provider-unleash examples: - - name: client_token - manifest: |- - { - "environment": "development", - "expires_at": "2024-12-31T23:59:59Z", - "project": "default", - "token_name": "client_token", - "type": "client" - } - - name: frontend_token - manifest: |- - { - "environment": "development", - "expires_at": "2024-12-31T23:59:59Z", - "projects": [ - "*" - ], - "token_name": "frontend_token", - "type": "frontend" - } - - name: admin_token + - name: my_token manifest: |- { "environment": "*", - "expires_at": "2024-12-31T23:59:59Z", + "expires_at": "2024-10-19", "projects": [ "*" ], - "token_name": "admin_token", - "type": "admin" + "type": "admin", + "username": "bobjoe" } - - name: admin_no_expire - manifest: |- - { - "token_name": "admin_no_expire", - "type": "admin" - } - argumentDocs: - environment: (String) An environment the token has access to. - expires_at: (String) When the token expires - project: (String) A project the token belongs to. - projects: (Set of String) The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [*]. - secret: (String, Sensitive) Secret token value. - token_name: (String) The name of the token. - type: (String) The type of the token. - importStatements: [] - unleash_oidc Resource - terraform-provider-unleash: - subCategory: "" - description: Manages OIDC configuration. - name: unleash_oidc Resource - terraform-provider-unleash - title: unleash_oidc Resource - terraform-provider-unleash argumentDocs: - auto_create: (Boolean) Whether to auto create users when they login to Unleash for the first time. - client_id: (String) The OIDC public identifier. - default_root_role: (Number) The default root role give to a user when that user is created. Only used if auto_create is set to true. - discover_url: (String) A URL pointing to the .well-known configuration of the OIDC provider. - enabled: (Boolean) Whether or not OIDC is enabled. - secret: (String) The OIDC secret. + created_at: (String) The API token creation date. + environment: (String) The environment the token will have access to. Use "*" for all environments. By default, it will have access to all environments. + expires_at: (String) The API token expiration date. + id: (String) The ID of this resource. + projects: (Set of String) The project(s) the token will have access to. Use ["*"] for all projects. By default, it will have access to all projects. + secret: (String, Sensitive) The API token secret. + type: (String) The type of the API token. Can be client, admin or frontend + username: (String) importStatements: [] - unleash_project: + unleash_feature: subCategory: "" - description: Project schema - name: unleash_project - title: unleash_project Resource - terraform-provider-unleash + description: Provides a resource for managing unleash features. + name: unleash_feature + title: unleash_feature Resource - terraform-provider-unleash examples: - - name: default_project + - name: example manifest: |- { - "description": "Default project now managed by Terraform", - "id": "default", - "name": "Default project" + "name": "toggle", + "project_id": "${data.unleash_project.example.project_id}", + "type": "${data.unleash_feature_type.example.type_id}" } - - name: test_project - manifest: |- - { - "description": "A project created through terraform", - "id": "my_project", - "name": "My Terraform project" - } - argumentDocs: - description: (String) A description of the project's purpose. - id: (String) Identifier for this project. - name: (String) The name of the project. - importStatements: [] - unleash_project_access: - subCategory: "" - description: ProjectAccess schema - name: unleash_project_access - title: unleash_project_access Resource - terraform-provider-unleash - examples: - - name: sample_project_access + references: + project_id: data.unleash_project.example.project_id + type: data.unleash_feature_type.example.type_id + - name: variants_example manifest: |- { - "project": "${unleash_project.sample_project.id}", - "roles": [ + "name": "toggle_variants", + "project_id": "${data.unleash_project.example.project_id}", + "type": "${data.unleash_feature_type.example.type_id}", + "variant": [ { - "groups": [], - "role": "${data.unleash_role.project_owner_role.id}", - "users": [ - "${unleash_user.test_user.id}" - ] + "name": "Variant1" }, { - "groups": [], - "role": "${data.unleash_role.project_member_role.id}", - "users": [ - "${unleash_user.test_user_2.id}" + "name": "Variant2", + "overrides": [ + { + "context_name": "appName", + "values": [ + "bar", + "xyz" + ] + }, + { + "context_name": "environment", + "values": [ + "development" + ] + } + ], + "payload": [ + { + "type": "string", + "value": "foo" + } ] } ] } references: - project: unleash_project.sample_project.id - dependencies: - unleash_project.sample_project: |- - { - "id": "sample", - "name": "sample-project" - } - unleash_user.test_user: |- - { - "email": "test-password@getunleash.io", - "name": "tester", - "password": "you-will-never-guess", - "root_role": "3", - "send_email": false - } - unleash_user.test_user_2: |- - { - "email": "test-2-password@getunleash.io", - "name": "tester-2", - "password": "you-will-never-guess", - "root_role": "3", - "send_email": false - } - - name: default_project_access + project_id: data.unleash_project.example.project_id + type: data.unleash_feature_type.example.type_id + argumentDocs: + archive_on_destroy: (Boolean) Whether to archive the feature toggle on destroy. Default is true. When false, it will permanently delete the feature toggle. + context_name: (String) + description: (String) Feature description + id: (String) The ID of this resource. + name: (String) Feature name + overrides: (Block Set) Overrides existing context field values. Values are comma separated e.g v1, v2, ...) (see below for nested schema) + payload: '(Block Set, Max: 1) Variant payload. The type of the payload can be string, json or csv (see below for nested schema)' + project_id: (String) The feature will be created in the given project + stickiness: (String) Variant stickiness. Default is default. + type: (String) Feature type + value: (String) + values: (List of String) + variant: (Block List) Feature variant (see below for nested schema) + weight: (Number) Variant weight. Only considered when the weight_type is fix. It is calculated automatically if the weight_type is variable. + weight_type: (String) Variant weight type. The weight type can be fix or variable. Default is variable. + importStatements: [] + unleash_feature_enabling: + subCategory: "" + description: Provides a resource for enabling a feature toggle in the given environment. This can be only done after the feature toggle has at least one strategy. + name: unleash_feature_enabling + title: unleash_feature_enabling Resource - terraform-provider-unleash + examples: + - name: example manifest: |- { - "project": "default", - "roles": [ - { - "groups": [], - "role": "${data.unleash_role.project_owner_role.id}", - "users": [ - "${unleash_user.test_user.id}" - ] - } - ] + "depends_on": [ + "${unleash_strategy_assignment.example}" + ], + "enabled": true, + "environment": "development", + "feature_name": "${unleash_feature.example.name}", + "project_id": "${data.unleash_project.example.project_id}" } + references: + feature_name: unleash_feature.example.name + project_id: data.unleash_project.example.project_id dependencies: - unleash_project.sample_project: |- + unleash_feature.example: |- { - "id": "sample", - "name": "sample-project" + "name": "toggle", + "project_id": "${data.unleash_project.example.project_id}", + "type": "${data.unleash_feature_type.example.type_id}" } - unleash_user.test_user: |- + unleash_strategy_assignment.example: |- { - "email": "test-password@getunleash.io", - "name": "tester", - "password": "you-will-never-guess", - "root_role": "3", - "send_email": false - } - unleash_user.test_user_2: |- - { - "email": "test-2-password@getunleash.io", - "name": "tester-2", - "password": "you-will-never-guess", - "root_role": "3", - "send_email": false + "environment": "development", + "feature_name": "${unleash_feature.example.name}", + "parameters": { + "groupId": "toggle", + "rollout": "68", + "stickiness": "random" + }, + "project_id": "${data.unleash_project.example.project_id}", + "strategy_name": "flexibleRollout" } argumentDocs: - groups: (Set of Number) List of projects with this role assigned. - project: (String) Project identifier. - role: (Number) The role identifier. - roles: (Attributes Set) Roles available in this project with their members. (see below for nested schema) - users: (Set of Number) List of users with this role assigned. + enabled: (Boolean) Whether the feature is on/off in the provided environment. Default is true (on). + environment: (String) The environment where the toggle will be enabled + feature_name: (String) Feature name to enabled + id: (String) The ID of this resource. + project_id: (String) The unleash project the feature is in importStatements: [] - unleash_role: + unleash_feature_v2: subCategory: "" - description: Role schema - name: unleash_role - title: unleash_role Resource - terraform-provider-unleash + description: (Experimental) Provides a resource for managing unleash features with variants and environment strategies all in a single resource. + name: unleash_feature_v2 + title: unleash_feature_v2 Resource - terraform-provider-unleash examples: - - name: custom_root_role - manifest: |- - { - "description": "A custom test root role", - "name": "A custom role", - "permissions": [ - { - "name": "CREATE_PROJECT" - }, - { - "name": "UPDATE_PROJECT" - } - ], - "type": "root-custom" - } - - name: custom_root_role + - name: with_env_strategies manifest: |- { - "description": "A custom test root role", - "name": "Renamed custom role", - "permissions": [ + "archive_on_destroy": false, + "description": "manages my nice feature", + "environment": [ { - "name": "CREATE_SEGMENT" + "enabled": false, + "name": "production" }, { - "name": "UPDATE_SEGMENT" + "enabled": true, + "name": "development", + "strategy": [ + { + "constraint": [ + { + "case_insensitive": false, + "context_name": "appName", + "inverted": false, + "operator": "SEMVER_EQ", + "value": "1.0.0" + }, + { + "context_name": "appName", + "operator": "IN", + "values": [ + "foo", + "bar" + ] + } + ], + "name": "remoteAddress", + "parameters": { + "IPs": "189.434.777.123,host.test.com" + } + }, + { + "name": "flexibleRollout", + "parameters": { + "groupId": "toggle", + "rollout": "68", + "stickiness": "random" + } + } + ] } ], - "type": "root-custom" - } - - name: project_role - manifest: |- - { - "description": "A custom test project role", - "name": "Custom project role", - "permissions": [ + "name": "my_nice_feature", + "project_id": "default", + "tag": [ { - "name": "CREATE_FEATURE" + "type": "simple", + "value": "foo" }, { - "name": "DELETE_FEATURE" - }, - { - "environment": "development", - "name": "UPDATE_FEATURE_ENVIRONMENT" + "type": "simple", + "value": "bar" } ], - "type": "custom" - } - argumentDocs: - description: (String) A more detailed description of the role and what use it's intended for. - environment: (String) For which environment this permission applies (note that only environment-type permissions can have an environment). - id: (String) The id of this role. - name: (String) The name of this role. - permissions: (Attributes Set) A more detailed description of the role and what use it's intended for. (see below for nested schema) - type: (String) A role can either be a global root role (applies to all roles) or a role role. - importStatements: [] - unleash_saml Resource - terraform-provider-unleash: - subCategory: "" - description: Manages SAML configuration. - name: unleash_saml Resource - terraform-provider-unleash - title: unleash_saml Resource - terraform-provider-unleash - argumentDocs: - auto_create: (Boolean) Whether to auto create users when they login to Unleash for the first time. - certificate: (String) The x509 certificate used by the SAML provider. - default_root_role: (Number) The default root role give to a user when that user is created. Only used if auto_create is set to true. - enabled: (Boolean) Whether SAML is enabled. - entity_id: (String) The SAML entity ID. - sign_on_url: (String) The SAML sign-on URL. - importStatements: [] - unleash_service_account: - subCategory: "" - description: Service accounts do nothing on their own, they need service account tokens to be created to do anything useful. All tokens bound to a service account will take on the permissions of the root role assigned to the service account. It's strongly recommended to use the unleash_role data source to retrieve one of the built-in roles and use the id from that to set the service account role id. See the - name: unleash_service_account - title: unleash_service_account Resource - terraform-provider-unleash - examples: - - name: admin service account - manifest: |- - { - "name": "something unique", - "root_role": "${admin_role.id}", - "username": "something unique" + "type": "release" } - references: - root_role: admin_role.id argumentDocs: - id: (Number) The ID of the service account. - name: (String) The name of the service account. - root_role: (Number) The root role ID for the service account. - username: (String) The username for the service account. + archive_on_destroy: (Boolean) Whether to archive the feature toggle on destroy. Default is true. When false, it will permanently delete the feature toggle. + case_insensitive: (Boolean) If operator is case-insensitive. + constraint: (Block List) Strategy constraint (see below for nested schema) + context_name: (String) Constraint context. Can be appName, currentTime, environment, sessionId or userId + description: (String) Feature description + enabled: (Boolean) Whether the feature is on/off in the environment. Default is true (on) + environment: (Block List) Use this to enable a feature in an environment and add strategies (see below for nested schema) + id: (String) The ID of this resource. + inverted: (Boolean) If constraint expressions will be negated, meaning that they get their opposite value. + name: (String) Feature name + operator: (String) Constraint operator. Can be IN, NOT_IN, STR_CONTAINS, STR_STARTS_WITH, STR_ENDS_WITH, NUM_EQ, NUM_GT, NUM_GTE, NUM_LT, NUM_LTE, SEMVER_EQ, SEMVER_GT or SEMVER_LT + overrides: (Block Set) Overrides existing context field values. Values are comma separated e.g v1, v2, ...) (see below for nested schema) + parameters: (Map of String) Strategy parameters. All the values need to informed as strings. + payload: '(Block Set, Max: 1) Variant payload. The type of the payload can be string, json or csv (see below for nested schema)' + project_id: (String) The feature will be created in the given project + stickiness: (String) Variant stickiness. Default is default. + strategy: (Block List) Strategy to add in the environment (see below for nested schema) + tag: (Block List) Tag to add to the feature (see below for nested schema) + type: (String) Feature type + value: (String) Value to use in the evaluation of the constraint. Applies only to DATE_, NUM_ and SEMVER_ operators. + values: (List of String) List of values to use in the evaluation of the constraint. Applies to all operators, except DATE_, NUM_ and SEMVER_. + variant: (Block List) Feature variant (see below for nested schema) + weight: (Number) Variant weight. Only considered when the weight_type is fix. It is calculated automatically if the weight_type is variable. + weight_type: (String) Variant weight type. The weight type can be fix or variable. Default is variable. importStatements: [] - unleash_service_account_token: + unleash_strategy_assignment: subCategory: "" - description: Allows for managing the tokens bound to a service account. Note that service account tokens in Unleash are both immutable and cannot be recovered once created. This means you must use them immediately when creating them via terraform. Typically by piping them to an external secret manager or binding them to some other external terraform resource that requires Unleash tokens. Because service account tokens are immutable, any changes to the terraform resource will trigger a deletion and recreation of those tokens, meaning that the secrets will be rotated out. - name: unleash_service_account_token - title: unleash_service_account_token Resource - terraform-provider-unleash + description: Provides a resource for add strategy to a feature toggle in the given environment. + name: unleash_strategy_assignment + title: unleash_strategy_assignment Resource - terraform-provider-unleash examples: - - name: token_for_account_test + - name: example manifest: |- { - "description": "a token for the account", - "expires_at": "2048-01-01T00:00:00Z", - "service_account_id": "${unleash_service_account.account_for_tokens_test.id}" + "environment": "development", + "feature_name": "${unleash_feature.example.name}", + "parameters": { + "groupId": "toggle", + "rollout": "68", + "stickiness": "random" + }, + "project_id": "${data.unleash_project.example.project_id}", + "strategy_name": "flexibleRollout" } references: - service_account_id: unleash_service_account.account_for_tokens_test.id + feature_name: unleash_feature.example.name + project_id: data.unleash_project.example.project_id dependencies: - external_resource.external_unleash_integration: |- - { - "unleash_api_key": "${unleash_service_account_token.token_for_account_test.secret}" - } - null_resource.store_token: |- - { - "provisioner": { - "local-exec": [ - { - "command": " #!/bin/bash\n TOKEN_VALUE=\"${unleash_service_account_token.token_for_account_test.secret}\"\n echo \"Storing token: $TOKEN_VALUE\"\n echo \"$TOKEN_VALUE\" \u003e /secure/location/service_account_token.txt\n" - } - ] - }, - "triggers": { - "token_created": "${unleash_service_account_token.token_for_account_test.secret}" - } - } - unleash_service_account.account_for_tokens_test: |- + unleash_feature.example: |- { - "name": "the service account name", - "root_role": 1, - "username": "some descriptive name" + "name": "toggle", + "project_id": "${data.unleash_project.example.project_id}", + "type": "${data.unleash_feature_type.example.type_id}" } argumentDocs: - description: (String) The description of the service account token. - expires_at: (String) The expiration date of the service account token. - id: (Number) The ID of the service account. - secret: (String, Sensitive) The secret of the service account token. - service_account_id: (Number) The ID of the service account this token is bound to. + environment: (String) The environment where the strategy will take place + feature_name: (String) Feature name to assign the strategy to + id: (String) The ID of this resource. + parameters: (Map of String) Strategy parameters. All the values need to informed as strings. + project_id: (String) The unleash project the feature is in + strategy_id: (String) Strategy id + strategy_name: (String) Strategy unique name importStatements: [] unleash_user: subCategory: "" - description: User schema + description: Provides a resource for managing unleash users. name: unleash_user title: unleash_user Resource - terraform-provider-unleash examples: - - name: admin - manifest: |- - { - "email": "admin@chucknorris.com", - "name": "Chuck Norris", - "root_role": 1, - "send_email": false - } - - name: chuck - manifest: |- - { - "email": "doesnotneedemail@chucknorris.com", - "name": "Chuck Norris", - "root_role": 1, - "send_email": false - } - - name: with_password + - name: my_user manifest: |- { - "email": "visiblepassword@example.com", - "name": "Iam Transparent", - "password": "youcanseeme", - "root_role": 1, - "send_email": false + "email": "bob.joe@gmail.com", + "name": "Bob Joe", + "root_role": "Editor", + "send_email": false, + "username": "bobjoe" } argumentDocs: - email: (String) The email of the user. - id: (String) Identifier for this user. - name: (String) The name of the user. - password: (String, Sensitive) The password of the user. - root_role: (Number) The role id for the user. - send_email: (Boolean) Send a welcome email to the customer or not. Defaults to true - username: (String) The username. + email: (String) The user's email address. + email_sent: (Boolean) Whether the welcome email was successfully sent to the user. + id: (String) The ID of this resource. + invite_link: (String) The link for the login link. + name: (String) The user's name. + root_role: (String) The role to assign to the user. Can be Admin, Editor or Viewer + send_email: (Boolean) Whether to send a welcome email with a login link to the user or not. Defaults to true. + username: (String) The user's username. importStatements: [] diff --git a/config/schema.json b/config/schema.json index 6893cad..3b18b18 100644 --- a/config/schema.json +++ b/config/schema.json @@ -1 +1 @@ -{"format_version":"1.0","provider_schemas":{"registry.terraform.io/unleash/unleash":{"provider":{"version":0,"block":{"attributes":{"authorization":{"type":"string","description":"Authorization token for Unleash API","description_kind":"markdown","optional":true,"sensitive":true},"base_url":{"type":"string","description":"Unleash base URL (everything before `/api`)","description_kind":"markdown","optional":true}},"description":"Interface with [Unleash server API](https://docs.getunleash.io/reference/api/unleash). This provider implements a subset of the operations that can be done with Unleash. The focus is mostly in setting up the instance with projects, roles, permissions, groups, and other typical configuration usually performed by admins.\n\nYou can check a complete example [here](https://github.com/Unleash/terraform-provider-unleash/tree/main/examples/staged) under stage_4 folder.","description_kind":"markdown"}},"resource_schemas":{"unleash_api_token":{"version":0,"block":{"attributes":{"environment":{"type":"string","description":"An environment the token has access to.","description_kind":"plain","optional":true,"computed":true},"expires_at":{"type":"string","description":"When the token expires","description_kind":"plain","optional":true},"project":{"type":"string","description":"A project the token belongs to.","description_kind":"plain","optional":true,"computed":true},"projects":{"type":["set","string"],"description":"The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as `[*]`.","description_kind":"plain","optional":true,"computed":true},"secret":{"type":"string","description":"Secret token value.","description_kind":"plain","computed":true,"sensitive":true},"token_name":{"type":"string","description":"The name of the token.","description_kind":"plain","optional":true},"type":{"type":"string","description":"The type of the token.","description_kind":"plain","optional":true}},"description":"ApiToken schema","description_kind":"plain"}},"unleash_oidc":{"version":0,"block":{"attributes":{"auto_create":{"type":"bool","description":"Whether to auto create users when they login to Unleash for the first time.","description_kind":"plain","optional":true,"computed":true},"client_id":{"type":"string","description":"The OIDC public identifier.","description_kind":"plain","required":true},"default_root_role":{"type":"number","description":"The default root role give to a user when that user is created. Only used if auto_create is set to true.","description_kind":"plain","optional":true,"computed":true},"discover_url":{"type":"string","description":"A URL pointing to the .well-known configuration of the OIDC provider.","description_kind":"plain","required":true},"enabled":{"type":"bool","description":"Whether or not OIDC is enabled.","description_kind":"plain","required":true},"secret":{"type":"string","description":"The OIDC secret.","description_kind":"plain","required":true}},"description":"Manages OIDC configuration.","description_kind":"plain"}},"unleash_project":{"version":0,"block":{"attributes":{"description":{"type":"string","description":"A description of the project's purpose.","description_kind":"plain","optional":true},"id":{"type":"string","description":"Identifier for this project.","description_kind":"plain","required":true},"name":{"type":"string","description":"The name of the project.","description_kind":"plain","required":true}},"description":"Project schema","description_kind":"plain"}},"unleash_project_access":{"version":0,"block":{"attributes":{"project":{"type":"string","description":"Project identifier.","description_kind":"plain","required":true},"roles":{"nested_type":{"attributes":{"groups":{"type":["set","number"],"description":"List of projects with this role assigned.","description_kind":"plain","required":true},"role":{"type":"number","description":"The role identifier.","description_kind":"plain","required":true},"users":{"type":["set","number"],"description":"List of users with this role assigned.","description_kind":"plain","required":true}},"nesting_mode":"set"},"description":"Roles available in this project with their members.","description_kind":"plain","required":true}},"description":"ProjectAccess schema","description_kind":"plain"}},"unleash_role":{"version":0,"block":{"attributes":{"description":{"type":"string","description":"A more detailed description of the role and what use it's intended for.","description_kind":"plain","required":true},"id":{"type":"string","description":"The id of this role.","description_kind":"plain","computed":true},"name":{"type":"string","description":"The name of this role.","description_kind":"plain","required":true},"permissions":{"nested_type":{"attributes":{"environment":{"type":"string","description":"For which environment this permission applies (note that only environment-type permissions can have an environment).","description_kind":"plain","optional":true},"name":{"type":"string","description":"The name of this permission.","description_kind":"plain","required":true}},"nesting_mode":"set"},"description":"A more detailed description of the role and what use it's intended for.","description_kind":"plain","required":true},"type":{"type":"string","description":"A role can either be a global root role (applies to all roles) or a role role.","description_kind":"plain","required":true}},"description":"Role schema","description_kind":"plain"}},"unleash_saml":{"version":0,"block":{"attributes":{"auto_create":{"type":"bool","description":"Whether to auto create users when they login to Unleash for the first time.","description_kind":"plain","optional":true,"computed":true},"certificate":{"type":"string","description":"The x509 certificate used by the SAML provider.","description_kind":"plain","required":true},"default_root_role":{"type":"number","description":"The default root role give to a user when that user is created. Only used if auto_create is set to true.","description_kind":"plain","optional":true,"computed":true},"enabled":{"type":"bool","description":"Whether SAML is enabled.","description_kind":"plain","required":true},"entity_id":{"type":"string","description":"The SAML entity ID.","description_kind":"plain","required":true},"sign_on_url":{"type":"string","description":"The SAML sign-on URL.","description_kind":"plain","required":true}},"description":"Manages SAML configuration.","description_kind":"plain"}},"unleash_service_account":{"version":0,"block":{"attributes":{"id":{"type":"number","description":"The ID of the service account.","description_kind":"plain","computed":true},"name":{"type":"string","description":"The name of the service account.","description_kind":"plain","required":true},"root_role":{"type":"number","description":"The root role ID for the service account.","description_kind":"plain","required":true},"username":{"type":"string","description":"The username for the service account.","description_kind":"plain","required":true}},"description":"Service accounts do nothing on their own, they need service account tokens to be created to do anything useful.\n\t\tAll tokens bound to a service account will take on the permissions of the root role assigned to the service account. It's strongly\n\t\trecommended to use the unleash_role data source to retrieve one of the built-in roles and use the id from that to set the service account\n\t\trole id.\n\n\t\tSee the [Unleash documentation](https://docs.getunleash.io/reference/service-accounts) for more information.","description_kind":"markdown"}},"unleash_service_account_token":{"version":0,"block":{"attributes":{"description":{"type":"string","description":"The description of the service account token.","description_kind":"plain","required":true},"expires_at":{"type":"string","description":"The expiration date of the service account token.","description_kind":"plain","required":true},"id":{"type":"number","description":"The ID of the service account.","description_kind":"plain","computed":true},"secret":{"type":"string","description":"The secret of the service account token.","description_kind":"plain","computed":true,"sensitive":true},"service_account_id":{"type":"number","description":"The ID of the service account this token is bound to.","description_kind":"plain","required":true}},"description":"Allows for managing the tokens bound to a service account. Note that service account tokens in Unleash\n\t\tare both immutable and cannot be recovered once created. This means you must use them immediately when creating them via terraform.\n\t\tTypically by piping them to an external secret manager or binding them to some other external terraform resource that requires Unleash tokens.\n\n\t\tBecause service account tokens are immutable, any changes to the terraform resource will trigger a deletion and recreation of those tokens,\n\t\tmeaning that the secrets will be rotated out.","description_kind":"markdown"}},"unleash_user":{"version":0,"block":{"attributes":{"email":{"type":"string","description":"The email of the user.","description_kind":"plain","optional":true},"id":{"type":"string","description":"Identifier for this user.","description_kind":"plain","computed":true},"name":{"type":"string","description":"The name of the user.","description_kind":"plain","optional":true},"password":{"type":"string","description":"The password of the user.","description_kind":"plain","optional":true,"sensitive":true},"root_role":{"type":"number","description":"The role id for the user.","description_kind":"plain","required":true},"send_email":{"type":"bool","description":"Send a welcome email to the customer or not. Defaults to true","description_kind":"plain","optional":true,"computed":true},"username":{"type":"string","description":"The username.","description_kind":"plain","optional":true}},"description":"User schema","description_kind":"plain"}}},"data_source_schemas":{"unleash_permission":{"version":0,"block":{"attributes":{"display_name":{"type":"string","description":"The name to display in listings of permissions.","description_kind":"plain","computed":true},"environment":{"type":"string","description":"Which environment this permission applies to.","description_kind":"plain","optional":true},"id":{"type":"number","description":"Identifier for this permission.","description_kind":"plain","computed":true},"name":{"type":"string","description":"The name of the permission.","description_kind":"plain","required":true},"type":{"type":"string","description":"What level this permission applies to. Either root, project or the name of the environment it applies to.","description_kind":"plain","computed":true}},"description":"Fetch a permission.","description_kind":"plain"}},"unleash_project":{"version":0,"block":{"attributes":{"description":{"type":"string","description":"A description of the project's purpose.","description_kind":"plain","optional":true},"id":{"type":"string","description":"The id of this project.","description_kind":"plain","required":true},"name":{"type":"string","description":"The name of this project.","description_kind":"plain","computed":true}},"description":"Fetch a project definition.","description_kind":"plain"}},"unleash_role":{"version":0,"block":{"attributes":{"description":{"type":"string","description":"A more detailed description of the role and what use it's intended for.","description_kind":"plain","computed":true},"id":{"type":"number","description":"The id of this role.","description_kind":"plain","computed":true},"name":{"type":"string","description":"The name of this role.","description_kind":"plain","required":true},"type":{"type":"string","description":"A role can either be a global root role (applies to all roles) or a role role.","description_kind":"plain","computed":true}},"description":"Fetch a role definition.","description_kind":"plain"}},"unleash_user":{"version":0,"block":{"attributes":{"email":{"type":"string","description":"The email of the user.","description_kind":"plain","optional":true,"computed":true},"id":{"type":"string","description":"Identifier for this user.","description_kind":"plain","required":true},"name":{"type":"string","description":"The name of the user.","description_kind":"plain","optional":true,"computed":true},"root_role":{"type":"number","description":"The role id for the user.","description_kind":"plain","computed":true},"username":{"type":"string","description":"The username of the user.","description_kind":"plain","optional":true,"computed":true}},"description":"Fetch a user.","description_kind":"plain"}}}}}} +{"format_version":"1.0","provider_schemas":{"registry.terraform.io/philips-labs/unleash":{"provider":{"version":0,"block":{"attributes":{"api_url":{"type":"string","description":"URL of the unleash API","description_kind":"markdown","required":true},"auth_token":{"type":"string","description":"Authentication token to authenticate to the Unleash API","description_kind":"markdown","required":true,"sensitive":true}},"description_kind":"plain"}},"resource_schemas":{"unleash_api_token":{"version":0,"block":{"attributes":{"created_at":{"type":"string","description":"The API token creation date.","description_kind":"markdown","optional":true,"computed":true},"environment":{"type":"string","description":"The environment the token will have access to. Use `\"*\"` for all environments. By default, it will have access to all environments.","description_kind":"markdown","optional":true},"expires_at":{"type":"string","description":"The API token expiration date.","description_kind":"markdown","optional":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"projects":{"type":["set","string"],"description":"The project(s) the token will have access to. Use `[\"*\"]` for all projects. By default, it will have access to all projects.","description_kind":"markdown","optional":true},"secret":{"type":"string","description":"The API token secret.","description_kind":"markdown","optional":true,"computed":true,"sensitive":true},"type":{"type":"string","description":"The type of the API token. Can be `client`, `admin` or `frontend`","description_kind":"markdown","required":true},"username":{"type":"string","description_kind":"plain","required":true}},"description":"Provides a resource for managing unleash api tokens.","description_kind":"markdown"}},"unleash_feature":{"version":0,"block":{"attributes":{"archive_on_destroy":{"type":"bool","description":"Whether to archive the feature toggle on destroy. Default is `true`. When `false`, it will permanently delete the feature toggle.","description_kind":"markdown","optional":true},"description":{"type":"string","description":"Feature description","description_kind":"markdown","optional":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"name":{"type":"string","description":"Feature name","description_kind":"markdown","required":true},"project_id":{"type":"string","description":"The feature will be created in the given project","description_kind":"markdown","required":true},"type":{"type":"string","description":"Feature type","description_kind":"markdown","required":true}},"block_types":{"variant":{"nesting_mode":"list","block":{"attributes":{"name":{"type":"string","description":"Variant name","description_kind":"markdown","required":true},"stickiness":{"type":"string","description":"Variant stickiness. Default is `default`.","description_kind":"markdown","optional":true},"weight":{"type":"number","description":"Variant weight. Only considered when the `weight_type` is `fix`. It is calculated automatically if the `weight_type` is `variable`.","description_kind":"markdown","optional":true,"computed":true},"weight_type":{"type":"string","description":"Variant weight type. The weight type can be `fix` or `variable`. Default is `variable`.","description_kind":"markdown","optional":true}},"block_types":{"overrides":{"nesting_mode":"set","block":{"attributes":{"context_name":{"type":"string","description_kind":"plain","required":true},"values":{"type":["list","string"],"description_kind":"plain","required":true}},"description":"Overrides existing context field values. Values are comma separated e.g `v1, v2, ...`)","description_kind":"markdown"}},"payload":{"nesting_mode":"set","block":{"attributes":{"type":{"type":"string","description_kind":"plain","required":true},"value":{"type":"string","description_kind":"plain","required":true}},"description":"Variant payload. The type of the payload can be `string`, `json` or `csv`","description_kind":"markdown"},"max_items":1}},"description":"Feature variant","description_kind":"markdown"}}},"description":"Provides a resource for managing unleash features.","description_kind":"markdown"}},"unleash_feature_enabling":{"version":0,"block":{"attributes":{"enabled":{"type":"bool","description":"Whether the feature is on/off in the provided environment. Default is `true` (on).","description_kind":"markdown","optional":true},"environment":{"type":"string","description":"The environment where the toggle will be enabled","description_kind":"markdown","required":true},"feature_name":{"type":"string","description":"Feature name to enabled","description_kind":"markdown","required":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"project_id":{"type":"string","description":"The unleash project the feature is in","description_kind":"markdown","required":true}},"description":"Provides a resource for enabling a feature toggle in the given environment. This can be only done after the feature toggle has at least one strategy.","description_kind":"markdown"}},"unleash_feature_v2":{"version":0,"block":{"attributes":{"archive_on_destroy":{"type":"bool","description":"Whether to archive the feature toggle on destroy. Default is `true`. When `false`, it will permanently delete the feature toggle.","description_kind":"markdown","optional":true},"description":{"type":"string","description":"Feature description","description_kind":"markdown","optional":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"name":{"type":"string","description":"Feature name","description_kind":"markdown","required":true},"project_id":{"type":"string","description":"The feature will be created in the given project","description_kind":"markdown","required":true},"type":{"type":"string","description":"Feature type","description_kind":"markdown","required":true}},"block_types":{"environment":{"nesting_mode":"list","block":{"attributes":{"enabled":{"type":"bool","description":"Whether the feature is on/off in the environment. Default is `true` (on)","description_kind":"markdown","optional":true},"name":{"type":"string","description":"Environment name","description_kind":"markdown","required":true}},"block_types":{"strategy":{"nesting_mode":"list","block":{"attributes":{"id":{"type":"string","description":"Strategy ID","description_kind":"markdown","computed":true},"name":{"type":"string","description":"Strategy unique name","description_kind":"markdown","required":true},"parameters":{"type":["map","string"],"description":"Strategy parameters. All the values need to informed as strings.","description_kind":"markdown","optional":true}},"block_types":{"constraint":{"nesting_mode":"list","block":{"attributes":{"case_insensitive":{"type":"bool","description":"If operator is case-insensitive.","description_kind":"markdown","optional":true},"context_name":{"type":"string","description":"Constraint context. Can be `appName`, `currentTime`, `environment`, `sessionId` or `userId`","description_kind":"markdown","required":true},"inverted":{"type":"bool","description":"If constraint expressions will be negated, meaning that they get their opposite value.","description_kind":"markdown","optional":true},"operator":{"type":"string","description":"Constraint operator. Can be `IN`, `NOT_IN`, `STR_CONTAINS`, `STR_STARTS_WITH`, `STR_ENDS_WITH`, `NUM_EQ`, `NUM_GT`, `NUM_GTE`, `NUM_LT`, `NUM_LTE`, `SEMVER_EQ`, `SEMVER_GT` or `SEMVER_LT`","description_kind":"markdown","required":true},"value":{"type":"string","description":"Value to use in the evaluation of the constraint. Applies only to `DATE_`, `NUM_` and `SEMVER_` operators.","description_kind":"markdown","optional":true},"values":{"type":["list","string"],"description":"List of values to use in the evaluation of the constraint. Applies to all operators, except `DATE_`, `NUM_` and `SEMVER_`.","description_kind":"markdown","optional":true}},"description":"Strategy constraint","description_kind":"markdown"}}},"description":"Strategy to add in the environment","description_kind":"markdown"}}},"description":"Use this to enable a feature in an environment and add strategies","description_kind":"markdown"}},"tag":{"nesting_mode":"list","block":{"attributes":{"type":{"type":"string","description":"Tag type. Default is `simple`.","description_kind":"markdown","optional":true},"value":{"type":"string","description":"Tag value.","description_kind":"markdown","required":true}},"description":"Tag to add to the feature","description_kind":"markdown"}},"variant":{"nesting_mode":"list","block":{"attributes":{"name":{"type":"string","description":"Variant name","description_kind":"markdown","required":true},"stickiness":{"type":"string","description":"Variant stickiness. Default is `default`.","description_kind":"markdown","optional":true},"weight":{"type":"number","description":"Variant weight. Only considered when the `weight_type` is `fix`. It is calculated automatically if the `weight_type` is `variable`.","description_kind":"markdown","optional":true,"computed":true},"weight_type":{"type":"string","description":"Variant weight type. The weight type can be `fix` or `variable`. Default is `variable`.","description_kind":"markdown","optional":true}},"block_types":{"overrides":{"nesting_mode":"set","block":{"attributes":{"context_name":{"type":"string","description_kind":"plain","required":true},"values":{"type":["list","string"],"description_kind":"plain","required":true}},"description":"Overrides existing context field values. Values are comma separated e.g `v1, v2, ...`)","description_kind":"markdown"}},"payload":{"nesting_mode":"set","block":{"attributes":{"type":{"type":"string","description_kind":"plain","required":true},"value":{"type":"string","description_kind":"plain","required":true}},"description":"Variant payload. The type of the payload can be `string`, `json` or `csv`","description_kind":"markdown"},"max_items":1}},"description":"Feature variant","description_kind":"markdown"}}},"description":"(Experimental) Provides a resource for managing unleash features with variants and environment strategies all in a single resource.","description_kind":"markdown"}},"unleash_strategy_assignment":{"version":0,"block":{"attributes":{"environment":{"type":"string","description":"The environment where the strategy will take place","description_kind":"markdown","required":true},"feature_name":{"type":"string","description":"Feature name to assign the strategy to","description_kind":"markdown","required":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"parameters":{"type":["map","string"],"description":"Strategy parameters. All the values need to informed as strings.","description_kind":"markdown","optional":true},"project_id":{"type":"string","description":"The unleash project the feature is in","description_kind":"markdown","required":true},"strategy_id":{"type":"string","description":"Strategy id","description_kind":"markdown","computed":true},"strategy_name":{"type":"string","description":"Strategy unique name","description_kind":"markdown","required":true}},"description":"Provides a resource for add strategy to a feature toggle in the given environment.","description_kind":"markdown"}},"unleash_user":{"version":0,"block":{"attributes":{"email":{"type":"string","description":"The user's email address.","description_kind":"markdown","required":true},"email_sent":{"type":"bool","description":"Whether the welcome email was successfully sent to the user.","description_kind":"markdown","computed":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"invite_link":{"type":"string","description":"The link for the login link.","description_kind":"markdown","computed":true},"name":{"type":"string","description":"The user's name.","description_kind":"markdown","required":true},"root_role":{"type":"string","description":"The role to assign to the user. Can be `Admin`, `Editor` or `Viewer`","description_kind":"markdown","required":true},"send_email":{"type":"bool","description":"Whether to send a welcome email with a login link to the user or not. Defaults to `true`.","description_kind":"markdown","optional":true},"username":{"type":"string","description":"The user's username.","description_kind":"markdown","required":true}},"description":"Provides a resource for managing unleash users.","description_kind":"markdown"}}},"data_source_schemas":{"unleash_api_token":{"version":0,"block":{"attributes":{"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"projects":{"type":["set","string"],"description":"Filter token by project(s).","description_kind":"markdown","optional":true},"token":{"type":["list",["object",{"created_at":"string","environment":"string","expires_at":"string","projects":["set","string"],"secret":"string","type":"string","username":"string"}]],"description":"API token","description_kind":"markdown","computed":true},"username":{"type":"string","description":"Filter token by username.","description_kind":"markdown","required":true}},"description":"Retrieves a single api token based on provided filters. It raises an error if more than one token is returned.","description_kind":"markdown"}},"unleash_api_tokens":{"version":0,"block":{"attributes":{"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"projects":{"type":["set","string"],"description":"Filter tokens by project(s).","description_kind":"markdown","optional":true},"tokens":{"type":["list",["object",{"created_at":"string","environment":"string","expires_at":"string","projects":["set","string"],"secret":"string","type":"string","username":"string"}]],"description":"List of api tokens.","description_kind":"markdown","computed":true},"username":{"type":"string","description":"Filter tokens by username.","description_kind":"markdown","optional":true}},"description":"Retrieves existing api tokens. Filters are optional.","description_kind":"markdown"}},"unleash_feature":{"version":0,"block":{"attributes":{"archived":{"type":"bool","description":"Wether the feature toggle is archived or not","description_kind":"markdown","computed":true},"created_at":{"type":"string","description":"The date the feature toggle was created","description_kind":"markdown","computed":true},"description":{"type":"string","description":"The description of the feature toggle","description_kind":"markdown","computed":true},"environments":{"type":["list",["object",{"enabled":"bool","name":"string"}]],"description":"The environments of the feature toggle","description_kind":"markdown","computed":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"name":{"type":"string","description":"Feature name","description_kind":"markdown","required":true},"project_id":{"type":"string","description":"The project id of the feature toggle","description_kind":"markdown","required":true},"stale":{"type":"bool","description":"Wether the feature toggle is stale or not","description_kind":"markdown","computed":true},"type":{"type":"string","description":"The type of the feature toggle","description_kind":"markdown","computed":true}},"description":"Retrieve details of an existing feature","description_kind":"markdown"}},"unleash_feature_type":{"version":0,"block":{"attributes":{"description":{"type":"string","description":"The description of the feature type","description_kind":"markdown","computed":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"lifetime_days":{"type":"number","description":"The lifetime of the feature type in days","description_kind":"markdown","computed":true},"name":{"type":"string","description":"Feature type name","description_kind":"markdown","computed":true},"type_id":{"type":"string","description":"The id of the feature type","description_kind":"markdown","required":true}},"description":"Retrieve details of an existing feature type","description_kind":"markdown"}},"unleash_project":{"version":0,"block":{"attributes":{"description":{"type":"string","description":"The description of the unleash project","description_kind":"markdown","computed":true},"environments":{"type":["list",["object",{"environment":"string"}]],"description":"The list of unleash environments in this project","description_kind":"markdown","computed":true},"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"name":{"type":"string","description":"Project name","description_kind":"markdown","computed":true},"project_id":{"type":"string","description":"The project id of the unleash project","description_kind":"markdown","required":true},"updated_at":{"type":"string","description":"The date the unleash project was last updated","description_kind":"markdown","computed":true}},"description":"Retrieve details of an existing unleash project","description_kind":"markdown"}},"unleash_user":{"version":0,"block":{"attributes":{"created_at":{"type":"string","description":"The date of creation of the user.","description_kind":"markdown","computed":true},"email":{"type":"string","description":"The user's email address.","description_kind":"markdown","computed":true},"id":{"type":"number","description":"Id used to search the user.","description_kind":"markdown","required":true},"image_url":{"type":"string","description":"The user's image URL.","description_kind":"markdown","computed":true},"name":{"type":"string","description":"The user's name.","description_kind":"markdown","computed":true},"root_role":{"type":"string","description":"The user's role.","description_kind":"markdown","computed":true},"username":{"type":"string","description":"The user's username.","description_kind":"markdown","computed":true}},"description":"Retrieve details of an existing user","description_kind":"markdown"}},"unleash_users":{"version":0,"block":{"attributes":{"id":{"type":"string","description_kind":"plain","optional":true,"computed":true},"query":{"type":"string","description":"Query used to search the user. It searches by `email`, `username` and `name` fields of users.","description_kind":"markdown","required":true},"users":{"type":["list",["object",{"created_at":"string","email":"string","id":"number","image_url":"string","name":"string","root_role":"string","username":"string"}]],"description":"Collection of users that match the provided query.","description_kind":"markdown","computed":true}},"description":"Retrieve a collection of users that match the provided query.","description_kind":"markdown"}}}}}} diff --git a/examples-generated/api/v1alpha1/token.yaml b/examples-generated/api/v1alpha1/token.yaml index e617512..7f6f962 100644 --- a/examples-generated/api/v1alpha1/token.yaml +++ b/examples-generated/api/v1alpha1/token.yaml @@ -4,12 +4,13 @@ metadata: annotations: meta.upbound.io/example-id: api/v1alpha1/token labels: - testing.upbound.io/example-name: client_token - name: client-token + testing.upbound.io/example-name: my_token + name: my-token spec: forProvider: - environment: development - expiresAt: "2024-12-31T23:59:59Z" - project: default - tokenName: client_token - type: client + environment: '*' + expiresAt: "2024-10-19" + projects: + - '*' + type: admin + username: bobjoe diff --git a/examples/token/token.yaml b/examples/token/token.yaml index 553f5ca..e7cd766 100644 --- a/examples/token/token.yaml +++ b/examples/token/token.yaml @@ -9,8 +9,9 @@ metadata: namespace: default spec: forProvider: - environment: development - expiresAt: "2024-12-31T23:59:59Z" - project: default - tokenName: client-token-name - type: client + environment: "*" + expiresAt: "2024-10-19" + projects: + - "*" + type: admin + username: bobjoe diff --git a/internal/clients/unleash.go b/internal/clients/unleash.go index 2502d35..9263b8d 100644 --- a/internal/clients/unleash.go +++ b/internal/clients/unleash.go @@ -65,8 +65,8 @@ func TerraformSetupBuilder(version, providerSource, providerVersion string) terr // Set credentials in Terraform provider configuration. // Set credentials in Terraform provider configuration. ps.Configuration = map[string]any{ - "base_url": creds["base_url"], - "authorization": creds["authorization"], + "api_url": creds["api_url"], + "auth_token": creds["auth_token"], } return ps, nil } diff --git a/package/crds/api.unleash.crossplane.io_tokens.yaml b/package/crds/api.unleash.crossplane.io_tokens.yaml index bf2e6fc..c8c27fc 100644 --- a/package/crds/api.unleash.crossplane.io_tokens.yaml +++ b/package/crds/api.unleash.crossplane.io_tokens.yaml @@ -34,7 +34,8 @@ spec: name: v1alpha1 schema: openAPIV3Schema: - description: Token is the Schema for the Tokens API. ApiToken schema + description: Token is the Schema for the Tokens API. Provides a resource for + managing unleash api tokens. properties: apiVersion: description: |- @@ -72,38 +73,55 @@ spec: type: string forProvider: properties: - environment: + createdAt: description: |- - (String) An environment the token has access to. - An environment the token has access to. + (String) The API token creation date. + The API token creation date. type: string - expiresAt: + environment: description: |- - (String) When the token expires - When the token expires + (String) The environment the token will have access to. Use "*" for all environments. By default, it will have access to all environments. + The environment the token will have access to. Use `"*"` for all environments. By default, it will have access to all environments. type: string - project: + expiresAt: description: |- - (String) A project the token belongs to. - A project the token belongs to. + (String) The API token expiration date. + The API token expiration date. type: string projects: description: |- - (Set of String) The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [*]. - The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as `[*]`. + (Set of String) The project(s) the token will have access to. Use ["*"] for all projects. By default, it will have access to all projects. + The project(s) the token will have access to. Use `["*"]` for all projects. By default, it will have access to all projects. items: type: string type: array x-kubernetes-list-type: set - tokenName: + secretSecretRef: description: |- - (String) The name of the token. - The name of the token. - type: string + (String, Sensitive) The API token secret. + The API token secret. + properties: + key: + description: The key to select. + type: string + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - key + - name + - namespace + type: object type: description: |- - (String) The type of the token. - The type of the token. + (String) The type of the API token. Can be client, admin or frontend + The type of the API token. Can be `client`, `admin` or `frontend` + type: string + username: + description: (String) type: string type: object initProvider: @@ -119,38 +137,55 @@ spec: for example because of an external controller is managing them, like an autoscaler. properties: - environment: + createdAt: description: |- - (String) An environment the token has access to. - An environment the token has access to. + (String) The API token creation date. + The API token creation date. type: string - expiresAt: + environment: description: |- - (String) When the token expires - When the token expires + (String) The environment the token will have access to. Use "*" for all environments. By default, it will have access to all environments. + The environment the token will have access to. Use `"*"` for all environments. By default, it will have access to all environments. type: string - project: + expiresAt: description: |- - (String) A project the token belongs to. - A project the token belongs to. + (String) The API token expiration date. + The API token expiration date. type: string projects: description: |- - (Set of String) The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [*]. - The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as `[*]`. + (Set of String) The project(s) the token will have access to. Use ["*"] for all projects. By default, it will have access to all projects. + The project(s) the token will have access to. Use `["*"]` for all projects. By default, it will have access to all projects. items: type: string type: array x-kubernetes-list-type: set - tokenName: + secretSecretRef: description: |- - (String) The name of the token. - The name of the token. - type: string + (String, Sensitive) The API token secret. + The API token secret. + properties: + key: + description: The key to select. + type: string + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - key + - name + - namespace + type: object type: description: |- - (String) The type of the token. - The type of the token. + (String) The type of the API token. Can be client, admin or frontend + The type of the API token. Can be `client`, `admin` or `frontend` + type: string + username: + description: (String) type: string type: object managementPolicies: @@ -320,45 +355,53 @@ spec: required: - forProvider type: object + x-kubernetes-validations: + - message: spec.forProvider.type is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.type) + || (has(self.initProvider) && has(self.initProvider.type))' + - message: spec.forProvider.username is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.username) + || (has(self.initProvider) && has(self.initProvider.username))' status: description: TokenStatus defines the observed state of Token. properties: atProvider: properties: + createdAt: + description: |- + (String) The API token creation date. + The API token creation date. + type: string environment: description: |- - (String) An environment the token has access to. - An environment the token has access to. + (String) The environment the token will have access to. Use "*" for all environments. By default, it will have access to all environments. + The environment the token will have access to. Use `"*"` for all environments. By default, it will have access to all environments. type: string expiresAt: description: |- - (String) When the token expires - When the token expires + (String) The API token expiration date. + The API token expiration date. type: string id: - type: string - project: - description: |- - (String) A project the token belongs to. - A project the token belongs to. + description: (String) The ID of this resource. type: string projects: description: |- - (Set of String) The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as [*]. - The list of projects this token has access to. If the token has access to specific projects they will be listed here. If the token has access to all projects it will be represented as `[*]`. + (Set of String) The project(s) the token will have access to. Use ["*"] for all projects. By default, it will have access to all projects. + The project(s) the token will have access to. Use `["*"]` for all projects. By default, it will have access to all projects. items: type: string type: array x-kubernetes-list-type: set - tokenName: - description: |- - (String) The name of the token. - The name of the token. - type: string type: description: |- - (String) The type of the token. - The type of the token. + (String) The type of the API token. Can be client, admin or frontend + The type of the API token. Can be `client`, `admin` or `frontend` + type: string + username: + description: (String) type: string type: object conditions: