dttung2905 commented on code in PR #16: URL: https://github.com/apache/iceberg-terraform/pull/16#discussion_r2885165473
########## internal/provider/resource_polaris_principal.go: ########## @@ -0,0 +1,353 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package provider + +import ( + "context" + "errors" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &polarisPrincipalResource{} + _ resource.ResourceWithImportState = &polarisPrincipalResource{} +) + +func NewPolarisPrincipalResource() resource.Resource { + return &polarisPrincipalResource{} +} + +type polarisPrincipalResource struct { + provider *icebergProvider + client *polarisClient +} + +type polarisPrincipalResourceModel struct { + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Properties types.Map `tfsdk:"properties"` + CredentialRotationRequired types.Bool `tfsdk:"credential_rotation_required"` + ClientID types.String `tfsdk:"client_id"` + ClientSecret types.String `tfsdk:"client_secret"` + EntityVersion types.Int64 `tfsdk:"entity_version"` +} + +func (r *polarisPrincipalResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_polaris_principal" +} + +func (r *polarisPrincipalResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "A resource for managing Polaris principals and their client credentials.", + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "name": schema.StringAttribute{ + Description: "The name of the Polaris principal.", + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "properties": schema.MapAttribute{ + Description: "Arbitrary metadata properties for the principal.", + Optional: true, + ElementType: types.StringType, + }, + "credential_rotation_required": schema.BoolAttribute{ + Description: "If true, the initial credentials can only be used to call rotateCredentials.", + Optional: true, + Computed: true, + Default: booldefault.StaticBool(false), + }, + "client_id": schema.StringAttribute{ + Description: "The client ID associated with this principal.", + Computed: true, + Sensitive: true, + }, + "client_secret": schema.StringAttribute{ + Description: "The client secret associated with this principal.", + Computed: true, + Sensitive: true, + }, + "entity_version": schema.Int64Attribute{ + Description: "The entity version used for optimistic concurrency control when updating the principal.", Review Comment: Yes I will delete it and let terraform manage it -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
