搜索

PythonReactSEOPDF
GitHub Skill

new-resource

Create a new Terraform resource for the DataRobot provider

datarobot-community☆ 4 仓库 Stars3 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Create New Terraform Resource

This skill helps you create a new Terraform resource for the DataRobot provider following established patterns.

Steps

  1. Create the resource file at pkg/provider/{resource_name}_resource.go:

    • Define the resource struct with provider *Provider
    • Implement resource.Resource interface (Metadata, Schema, Configure, Create, Read, Update, Delete)
    • Implement resource.ResourceWithImportState for import support
    • Add proper MarkdownDescription for all schema attributes
  2. Create the model file at pkg/provider/{resource_name}_model.go:

    • Define the ResourceModel struct with types.* fields
    • Match field names to API response/request structures
  3. Add client service methods in internal/client/:

    • Add interface methods to service.go
    • Implement methods in appropriate *_service.go file
  4. Create tests at pkg/provider/{resource_name}_resource_test.go:

    • Add TestAcc{ResourceName}Resource for acceptance tests
    • Add Test{ResourceName}ResourceSchema for schema validation
  5. Add example in examples/resources/{resource_name}/:

    • Create resource.tf with usage example
  6. Update documentation:

    • Run make generate to create docs
    • Update CHANGELOG.md

Template

package provider

import (
    "context"
    "fmt"

    "github.com/datarobot-community/terraform-provider-datarobot/internal/client"
    "github.com/hashicorp/terraform-plugin-framework/resource"
    "github.com/hashicorp/terraform-plugin-framework/resource/schema"
    "github.com/hashicorp/terraform-plugin-framework/types"
)

var _ resource.Resource = &{ResourceName}Resource{}
var _ resource.ResourceWithImportState = &{ResourceName}Resource{}

func New{ResourceName}Resource() resource.Resource {
    return &{ResourceName}Resource{}
}

type {ResourceName}Resource struct {
    provider *Provider
}

func (r *{ResourceName}Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
    resp.TypeName = req.ProviderTypeName + "_{resource_name}"
}

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!