Documentation
¶
Overview ¶
Package booksprovider implements the core Books Terraform Provider.
It is intended to be paired with `pkg/providershim`.
Index ¶
- Constants
- func Configure(_ context.Context, d *schema.ResourceData) (booksclient.Client, error)
- type DataSourceAuthor
- func (dsa *DataSourceAuthor) GetBookCount() int
- func (dsa *DataSourceAuthor) GetFirstName() string
- func (dsa *DataSourceAuthor) GetID() uuid.UUID
- func (dsa *DataSourceAuthor) GetLastName() string
- func (dsa *DataSourceAuthor) Persist() error
- func (dsa *DataSourceAuthor) Populate() error
- func (dsa *DataSourceAuthor) Read(ctx context.Context, c booksclient.Client) error
- func (*DataSourceAuthor) Schema() map[string]*schema.Schema
- type Date
- type ResourceAuthor
- func (ra *ResourceAuthor) Changed() bool
- func (ra *ResourceAuthor) Create(ctx context.Context, c booksclient.Client) error
- func (ra *ResourceAuthor) Delete(ctx context.Context, c booksclient.Client) error
- func (ra *ResourceAuthor) GetBookCount() int
- func (ra *ResourceAuthor) GetFirstName() string
- func (ra *ResourceAuthor) GetID() uuid.UUID
- func (ra *ResourceAuthor) GetLastName() string
- func (ra *ResourceAuthor) Persist() error
- func (ra *ResourceAuthor) Populate() error
- func (ra *ResourceAuthor) Read(ctx context.Context, c booksclient.Client) error
- func (*ResourceAuthor) Schema() map[string]*schema.Schema
- func (ra *ResourceAuthor) Update(ctx context.Context, c booksclient.Client) error
- type ResourceBook
- func (rb *ResourceBook) Changed() bool
- func (rb *ResourceBook) Create(ctx context.Context, c booksclient.Client) error
- func (rb *ResourceBook) Delete(ctx context.Context, c booksclient.Client) error
- func (rb *ResourceBook) GetAuthorID() uuid.UUID
- func (rb *ResourceBook) GetID() uuid.UUID
- func (rb *ResourceBook) GetPublishDate() Date
- func (rb *ResourceBook) GetTitle() string
- func (rb *ResourceBook) Persist() error
- func (rb *ResourceBook) Populate() error
- func (rb *ResourceBook) Read(ctx context.Context, c booksclient.Client) error
- func (*ResourceBook) Schema() map[string]*schema.Schema
- func (rb *ResourceBook) Update(ctx context.Context, c booksclient.Client) error
Constants ¶
const ( // EnvVarBooksAPIAddr is the configuration environment variable that can // be used to specify the `addr` for the Books API. For example, this // value could equal `http://localhost:7534`. EnvVarBooksAPIAddr = "BOOKS_API_ADDR" )
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
func Configure(_ context.Context, d *schema.ResourceData) (booksclient.Client, error)
Configure is a function for configuring the provider.
Types ¶
type DataSourceAuthor ¶
type DataSourceAuthor struct { FirstName *string `terraform:"first_name,required"` LastName *string `terraform:"last_name,required"` BookCount *int `terraform:"book_count,computed"` ID *uuid.UUID `terraform:"id,string,computed"` // contains filtered or unexported fields }
DataSourceAuthor represents a `books_api_author` data source and directly interacts with the Terraform plugin SDK to check for new or updated values.
func NewDataSourceAuthor ¶
func NewDataSourceAuthor(d *schema.ResourceData) (*DataSourceAuthor, error)
NewDataSourceAuthor creates a new `DataSourceAuthor` from a Terraform resource data struct.
func (*DataSourceAuthor) GetBookCount ¶
func (dsa *DataSourceAuthor) GetBookCount() int
GetBookCount is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*DataSourceAuthor) GetFirstName ¶
func (dsa *DataSourceAuthor) GetFirstName() string
GetFirstName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*DataSourceAuthor) GetID ¶
func (dsa *DataSourceAuthor) GetID() uuid.UUID
GetID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*DataSourceAuthor) GetLastName ¶
func (dsa *DataSourceAuthor) GetLastName() string
GetLastName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*DataSourceAuthor) Persist ¶
func (dsa *DataSourceAuthor) Persist() error
Persist writes back fields in this struct to the Terraform resource data struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)
NOTE: This method only takes a read lock for the exported fields,
`FirstName`, `LastName`, `BookCount` and `ID`. This method does do some "writes" to `ra.d` but the lock is not intended to make `schema.ResourceData` concurrency-safe (it is already via `MapFieldWriter`).
func (*DataSourceAuthor) Populate ¶
func (dsa *DataSourceAuthor) Populate() error
Populate populates the fields in this struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)
func (*DataSourceAuthor) Read ¶
func (dsa *DataSourceAuthor) Read(ctx context.Context, c booksclient.Client) error
Read is the read (R) component of the CRUD lifecycle for the `books_api_author` data source.
NOTE: This assumes the called has already invoked `dsa.Populate()`, either
directly or indirectly, e.g. via `NewDataSourceAuthor()`.
type Date ¶
func (Date) MarshalJSON ¶
MarshalJSON marshals a `Date` into a JSON string in `YYYY-MM-DD` format.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON unmarshals a string in `YYYY-MM-DD` format into a `Date`.
type ResourceAuthor ¶
type ResourceAuthor struct { FirstName *string `terraform:"first_name,required"` LastName *string `terraform:"last_name,required"` BookCount *int `terraform:"book_count,computed"` ID *uuid.UUID `terraform:"id,string,computed"` // contains filtered or unexported fields }
ResourceAuthor represents a `books_api_author` resource and directly interacts with the Terraform plugin SDK to check for new or updated values.
func NewResourceAuthor ¶
func NewResourceAuthor(d *schema.ResourceData) (*ResourceAuthor, error)
NewResourceAuthor creates a new `ResourceAuthor` from a Terraform resource data struct.
func (*ResourceAuthor) Changed ¶
func (ra *ResourceAuthor) Changed() bool
Changed detects if any of the user input fields have changed. (The goal is to make code that can be autogenerated.)
func (*ResourceAuthor) Create ¶
func (ra *ResourceAuthor) Create(ctx context.Context, c booksclient.Client) error
Create is the create (C) component of the CRUD lifecycle for the `books_api_author` resource.
NOTE: This assumes the called has already invoked `ra.Populate()`, either
directly or indirectly, e.g. via `NewResourceAuthor()`.
func (*ResourceAuthor) Delete ¶
func (ra *ResourceAuthor) Delete(ctx context.Context, c booksclient.Client) error
Delete is the delete (D) component of the CRUD lifecycle for the `books_api_author` resource.
NOTE: This assumes the called has already invoked `ra.Populate()`, either
directly or indirectly, e.g. via `NewResourceAuthor()`.
func (*ResourceAuthor) GetBookCount ¶
func (ra *ResourceAuthor) GetBookCount() int
GetBookCount is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceAuthor) GetFirstName ¶
func (ra *ResourceAuthor) GetFirstName() string
GetFirstName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceAuthor) GetID ¶
func (ra *ResourceAuthor) GetID() uuid.UUID
GetID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceAuthor) GetLastName ¶
func (ra *ResourceAuthor) GetLastName() string
GetLastName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceAuthor) Persist ¶
func (ra *ResourceAuthor) Persist() error
Persist writes back fields in this struct to the Terraform resource data struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)
NOTE: This method only takes a read lock for the exported fields,
`FirstName`, `LastName`, `BookCount` and `ID`. This method does do some "writes" to `ra.d` but the lock is not intended to make `schema.ResourceData` concurrency-safe (it is already via `MapFieldWriter`).
func (*ResourceAuthor) Populate ¶
func (ra *ResourceAuthor) Populate() error
Populate populates the fields in this struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)
func (*ResourceAuthor) Read ¶
func (ra *ResourceAuthor) Read(ctx context.Context, c booksclient.Client) error
Read is the read (R) component of the CRUD lifecycle for the `books_api_author` resource.
NOTE: This assumes the called has already invoked `ra.Populate()`, either
directly or indirectly, e.g. via `NewResourceAuthor()`.
func (*ResourceAuthor) Schema ¶
func (*ResourceAuthor) Schema() map[string]*schema.Schema
Schema produces the Terraform Schema map. (The goal is to make code that can be autogenerated.)
func (*ResourceAuthor) Update ¶
func (ra *ResourceAuthor) Update(ctx context.Context, c booksclient.Client) error
Update is the update (U) component of the CRUD lifecycle for the `books_api_author` resource.
NOTE: This assumes the called has already invoked `ra.Populate()`, either
directly or indirectly, e.g. via `NewResourceAuthor()`.
type ResourceBook ¶
type ResourceBook struct { Title *string `terraform:"title,required"` AuthorID *uuid.UUID `terraform:"author_id,string,required"` PublishDate *Date `terraform:"publish_date,string,required"` ID *uuid.UUID `terraform:"id,string,computed"` // contains filtered or unexported fields }
ResourceBook represents a `books_api_book` resource and directly interacts with the Terraform plugin SDK to check for new or updated values.
func NewResourceBook ¶
func NewResourceBook(d *schema.ResourceData) (*ResourceBook, error)
NewResourceBook creates a new `ResourceBook` from a Terraform resource data struct.
func (*ResourceBook) Changed ¶
func (rb *ResourceBook) Changed() bool
Changed detects if any of the user input fields have changed. (The goal is to make code that can be autogenerated.)
func (*ResourceBook) Create ¶
func (rb *ResourceBook) Create(ctx context.Context, c booksclient.Client) error
Create is the create (C) component of the CRUD lifecycle for the `books_api_book` resource.
NOTE: This assumes the called has already invoked `rb.Populate()`, either
directly or indirectly, e.g. via `NewResourceBook()`.
func (*ResourceBook) Delete ¶
func (rb *ResourceBook) Delete(ctx context.Context, c booksclient.Client) error
Delete is the delete (D) component of the CRUD lifecycle for the `books_api_book` resource.
NOTE: This assumes the called has already invoked `rb.Populate()`, either
directly or indirectly, e.g. via `NewResourceBook()`.
func (*ResourceBook) GetAuthorID ¶
func (rb *ResourceBook) GetAuthorID() uuid.UUID
GetAuthorID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceBook) GetID ¶
func (rb *ResourceBook) GetID() uuid.UUID
GetID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceBook) GetPublishDate ¶
func (rb *ResourceBook) GetPublishDate() Date
GetPublishDate is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceBook) GetTitle ¶
func (rb *ResourceBook) GetTitle() string
GetTitle is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)
func (*ResourceBook) Persist ¶
func (rb *ResourceBook) Persist() error
Persist writes back fields in this struct to the Terraform resource data struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)
NOTE: This method only takes a read lock for the exported fields,
`Title`, `AuthorID`, `PublishDate` and `ID`. This method does do some "writes" to `ra.d` but the lock is not intended to make `schema.ResourceData` concurrency-safe (it is already via `MapFieldWriter`).
func (*ResourceBook) Populate ¶
func (rb *ResourceBook) Populate() error
Populate populates the fields in this struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)
func (*ResourceBook) Read ¶
func (rb *ResourceBook) Read(ctx context.Context, c booksclient.Client) error
Read is the read (R) component of the CRUD lifecycle for the `books_api_book` resource.
NOTE: This assumes the called has already invoked `rb.Populate()`, either
directly or indirectly, e.g. via `NewResourceBook()`.
func (*ResourceBook) Schema ¶
func (*ResourceBook) Schema() map[string]*schema.Schema
Schema produces the Terraform Schema map. (The goal is to make code that can be autogenerated.)
func (*ResourceBook) Update ¶
func (rb *ResourceBook) Update(ctx context.Context, c booksclient.Client) error
Update is the update (U) component of the CRUD lifecycle for the `books_api_book` resource.
NOTE: This assumes the called has already invoked `rb.Populate()`, either
directly or indirectly, e.g. via `NewResourceBook()`.