Skip to content
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

Update documentation / minor cosmetic code change #10

Merged
merged 3 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# AdGuard Home Terraform Provider (terraform-provider-adguard)

**WARNING** under development
[![Release](https://img.shields.io/github/v/release/gmichels/terraform-provider-adguard)](https://github.com/gmichels/terraform-provider-adguard/releases)
[![Installs](https://img.shields.io/badge/dynamic/json?logo=terraform&label=installs&query=$.data.attributes.downloads&url=https%3A%2F%2Fregistry.terraform.io%2Fv2%2Fproviders%2F713)](https://registry.terraform.io/providers/gmichels/adguard)
[![Registry](https://img.shields.io/badge/registry-doc%40latest-lightgrey?logo=terraform)](https://registry.terraform.io/providers/gmichels/adguard/latest/docs)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/gmichels/terraform-provider-adguard/blob/main/LICENSE)
[![Status](https://github.com/gmichels/terraform-provider-adguard/workflows/Release/badge.svg)](https://github.com/gmichels/terraform-provider-adguard/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/gmichels/terraform-provider-adguard)](https://goreportcard.com/report/github.com/gmichels/terraform-provider-adguard)

The AdGuard provider provides resources to interact with an [AdGuard Home](https://github.com/AdguardTeam/AdGuardHome) server.

Functionality first needs to be added to the [adguard-client-go](https://github.com/gmichels/adguard-client-go) SDK.

# Documentation

You can browse documentation under the [docs](docs) folder.
You can browse documentation and examples on the [Terraform provider registry](https://registry.terraform.io/providers/gmichels/adguard/latest/docs).
26 changes: 13 additions & 13 deletions adguard/client_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,45 +182,45 @@ func (r *clientResource) Create(ctx context.Context, req resource.CreateRequest,
}

// instantiate empty client for storing plan data
var clientPlan adguard.Client
var client adguard.Client

// populate client from plan
clientPlan.Name = plan.Name.ValueString()
diags = plan.Ids.ElementsAs(ctx, &clientPlan.Ids, false)
client.Name = plan.Name.ValueString()
diags = plan.Ids.ElementsAs(ctx, &client.Ids, false)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
clientPlan.UseGlobalSettings = plan.UseGlobalSettings.ValueBool()
clientPlan.FilteringEnabled = plan.FilteringEnabled.ValueBool()
clientPlan.ParentalEnabled = plan.ParentalEnabled.ValueBool()
clientPlan.SafebrowsingEnabled = plan.SafebrowsingEnabled.ValueBool()
clientPlan.SafesearchEnabled = plan.SafesearchEnabled.ValueBool()
clientPlan.UseGlobalBlockedServices = plan.UseGlobalBlockedServices.ValueBool()
client.UseGlobalSettings = plan.UseGlobalSettings.ValueBool()
client.FilteringEnabled = plan.FilteringEnabled.ValueBool()
client.ParentalEnabled = plan.ParentalEnabled.ValueBool()
client.SafebrowsingEnabled = plan.SafebrowsingEnabled.ValueBool()
client.SafesearchEnabled = plan.SafesearchEnabled.ValueBool()
client.UseGlobalBlockedServices = plan.UseGlobalBlockedServices.ValueBool()
if len(plan.BlockedServices.Elements()) > 0 {
diags = plan.BlockedServices.ElementsAs(ctx, &clientPlan.BlockedServices, false)
diags = plan.BlockedServices.ElementsAs(ctx, &client.BlockedServices, false)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
}
if len(plan.Upstreams.Elements()) > 0 {
diags = plan.Upstreams.ElementsAs(ctx, &clientPlan.Upstreams, false)
diags = plan.Upstreams.ElementsAs(ctx, &client.Upstreams, false)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
}
if len(plan.Tags.Elements()) > 0 {
diags = plan.Tags.ElementsAs(ctx, &clientPlan.Tags, false)
diags = plan.Tags.ElementsAs(ctx, &client.Tags, false)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
}

// create new clientState using plan
clientState, err := r.adg.CreateClient(clientPlan)
clientState, err := r.adg.CreateClient(client)
if err != nil {
resp.Diagnostics.AddError(
"Error creating client",
Expand Down
1 change: 1 addition & 0 deletions adguard/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (p *adguardProvider) Metadata(_ context.Context, _ provider.MetadataRequest
// Schema defines the provider-level schema for configuration data
func (p *adguardProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "The AdGuard provider provides resources to interact with an [AdGuard Home](https://github.com/AdguardTeam/AdGuardHome) server",
Attributes: map[string]schema.Attribute{
"host": schema.StringAttribute{
Description: "The hostname of the AdGuard Home instance. Include the port if not on a standard HTTP/HTTPS port",
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "adguard Provider"
subcategory: ""
description: |-

The AdGuard provider provides resources to interact with an AdGuard Home https://github.com/AdguardTeam/AdGuardHome server
---

# adguard Provider


The AdGuard provider provides resources to interact with an [AdGuard Home](https://github.com/AdguardTeam/AdGuardHome) server

## Example Usage

Expand Down