-
Notifications
You must be signed in to change notification settings - Fork 12
feat: rename attribute agent skill #582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sudomateo
wants to merge
1
commit into
main
Choose a base branch
from
sudomateo/uxunvmpoxkxn
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+169
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added a `rename-attribute` AI agent skill to, hopefully, allow an AI agent to do future renames of Terraform attributes. Amp-Thread: https://ampcode.com/threads/T-019b4ea0-eacf-759c-8f7e-0746094eea36
Collaborator
Author
|
Currently testing this on a commit that does not already have the changes in #578. See the attached Amp thread for more information. Here's the diff it produced so far. diff --git a/internal/provider/resource_instance.go b/internal/provider/resource_instance.go
index d9c344db26..6ad726f282 100644
--- a/internal/provider/resource_instance.go
+++ b/internal/provider/resource_instance.go
@@ -54,7 +54,8 @@
Description types.String `tfsdk:"description"`
DiskAttachments types.Set `tfsdk:"disk_attachments"`
ExternalIPs []instanceResourceExternalIPModel `tfsdk:"external_ips"`
- HostName types.String `tfsdk:"host_name"`
+ Hostname types.String `tfsdk:"hostname"`
+ HostNameDeprecated types.String `tfsdk:"host_name"`
ID types.String `tfsdk:"id"`
Memory types.Int64 `tfsdk:"memory"`
Name types.String `tfsdk:"name"`
@@ -137,12 +138,32 @@
stringplanmodifier.RequiresReplace(),
},
},
+ "hostname": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "Host name of the instance.",
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifier.RequiresReplace(),
+ },
+ Validators: []validator.String{
+ stringvalidator.ExactlyOneOf(
+ path.MatchRoot("host_name"),
+ ),
+ },
+ },
"host_name": schema.StringAttribute{
- Required: true,
- Description: "Host name of the instance.",
+ Optional: true,
+ Computed: true,
+ Description: "Deprecated: Use hostname instead.",
+ DeprecationMessage: "Use hostname instead.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
+ Validators: []validator.String{
+ stringvalidator.ExactlyOneOf(
+ path.MatchRoot("hostname"),
+ ),
+ },
},
"memory": schema.Int64Attribute{
Required: true,
@@ -362,12 +383,19 @@
ctx, cancel := context.WithTimeout(ctx, createTimeout)
defer cancel()
+ var hostname string
+ if !plan.Hostname.IsNull() && !plan.Hostname.IsUnknown() {
+ hostname = plan.Hostname.ValueString()
+ } else {
+ hostname = plan.HostNameDeprecated.ValueString()
+ }
+
params := oxide.InstanceCreateParams{
Project: oxide.NameOrId(plan.ProjectID.ValueString()),
Body: &oxide.InstanceCreate{
Description: plan.Description.ValueString(),
Name: oxide.Name(plan.Name.ValueString()),
- Hostname: oxide.Hostname(plan.HostName.ValueString()),
+ Hostname: oxide.Hostname(hostname),
Memory: oxide.ByteCount(plan.Memory.ValueInt64()),
Ncpus: oxide.InstanceCpuCount(plan.NCPUs.ValueInt64()),
Start: plan.StartOnCreate.ValueBoolPointer(),
@@ -468,6 +496,8 @@
plan.ID = types.StringValue(instance.Id)
plan.TimeCreated = types.StringValue(instance.TimeCreated.String())
plan.TimeModified = types.StringValue(instance.TimeModified.String())
+ plan.Hostname = types.StringValue(string(instance.Hostname))
+ plan.HostNameDeprecated = types.StringValue(string(instance.Hostname))
// Populate NIC information
for i := range plan.NetworkInterfaces {
@@ -548,7 +578,8 @@
state.AutoRestartPolicy = types.StringValue(string(instance.AutoRestartPolicy))
}
state.Description = types.StringValue(instance.Description)
- state.HostName = types.StringValue(string(instance.Hostname))
+ state.Hostname = types.StringValue(string(instance.Hostname))
+ state.HostNameDeprecated = types.StringValue(string(instance.Hostname))
state.ID = types.StringValue(instance.Id)
state.Memory = types.Int64Value(int64(instance.Memory))
state.Name = types.StringValue(string(instance.Name))
@@ -809,6 +840,8 @@
plan.ProjectID = types.StringValue(instance.ProjectId)
plan.TimeCreated = types.StringValue(instance.TimeCreated.String())
plan.TimeModified = types.StringValue(instance.TimeModified.String())
+ plan.Hostname = types.StringValue(string(instance.Hostname))
+ plan.HostNameDeprecated = types.StringValue(string(instance.Hostname))
// We use the plan here instead of the state to capture the desired IP pool ID
// value for the ephemeral external IP rather than the previous value. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a
rename-attributeAI agent skill to, hopefully, allow an AI agent to do future renames of Terraform attributes.Amp-Thread: https://ampcode.com/threads/T-019b4ea0-eacf-759c-8f7e-0746094eea36