lighthouse

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema = schema.Schema{
	MarkdownDescription: resourceDescription,
	Attributes: map[string]schema.Attribute{
		"name": schema.StringAttribute{
			Description: "Lighthouse's name",
			Required:    true,
			Validators: []validator.String{
				stringvalidator.LengthAtMost(255),
			},
		},
		"network_id": schema.StringAttribute{
			Description: "Enrolled Network ID",
			Required:    true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.RequiresReplace(),
			},
		},
		"role_id": schema.StringAttribute{
			Description: "Lighthouse's role ID on Defined.net",
			Optional:    true,
		},
		"static_addresses": schema.ListAttribute{
			Description: "Lighthouse's static IP addresses",
			ElementType: types.StringType,
			Required:    true,
			Validators: []validator.List{
				listvalidator.UniqueValues(),
				listvalidator.ValueStringsAre(validation.IPAddress()),
			},
		},
		"listen_port": schema.Int32Attribute{
			Description: "Lighthouse's listen port",
			Required:    true,
		},
		"tags": schema.ListAttribute{
			Description: "Lighthouse's tags on Defined.net",
			ElementType: types.StringType,
			Optional:    true,
			Validators: []validator.List{
				listvalidator.UniqueValues(),
				listvalidator.ValueStringsAre(validation.HostTag()),
			},
		},
		"id": schema.StringAttribute{
			Description: "Lighthouse's ID",
			Computed:    true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
		"ip_address": schema.StringAttribute{
			Description: "Lighthouse's IP address on Defined.net overlay network",
			Computed:    true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
		"enrollment_code": schema.StringAttribute{
			Description: "Lighthouse's enrollment code",
			Sensitive:   true,
			Computed:    true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
	},
	Blocks: map[string]schema.Block{
		"metrics": schema.SingleNestedBlock{
			Description: "Host's metrics exporter configuration",
			Attributes: map[string]schema.Attribute{
				"enabled": schema.BoolAttribute{
					Description: "Enable metrics exporter",
					Optional:    true,
				},
				"listen": schema.StringAttribute{
					Description: "Host-port for Prometheus metrics exporter listener",
					Optional:    true,
					Computed:    true,
					Default:     stringdefault.StaticString("127.0.0.1:8080"),
					PlanModifiers: []planmodifier.String{
						stringplanmodifier.UseStateForUnknown(),
					},
				},
				"path": schema.StringAttribute{
					Description: "Prometheus metrics exporter's HTTP path",
					Optional:    true,
					Computed:    true,
					Default:     stringdefault.StaticString("/metrics"),
					PlanModifiers: []planmodifier.String{
						stringplanmodifier.UseStateForUnknown(),
					},
				},
				"namespace": schema.StringAttribute{
					Description: "Prometheus metrics' namespace",
					Optional:    true,
					Computed:    true,
					Default:     stringdefault.StaticString("nebula"),
					PlanModifiers: []planmodifier.String{
						stringplanmodifier.UseStateForUnknown(),
					},
				},
				"subsystem": schema.StringAttribute{
					Description: "Prometheus metrics' subsystem",
					Optional:    true,
					Computed:    true,
					Default:     stringdefault.StaticString("lighthouse"),
					PlanModifiers: []planmodifier.String{
						stringplanmodifier.UseStateForUnknown(),
					},
				},
				"enable_extra_metrics": schema.BoolAttribute{
					Description: "Enable extra metrics",
					Optional:    true,
					Computed:    true,
					PlanModifiers: []planmodifier.Bool{
						boolplanmodifier.UseStateForUnknown(),
					},
				},
			},
		},
	},
}

Schema is the lighthouse resource's schema.

Functions

func NewResource

func NewResource() resource.Resource

NewResource creates a Defined.net Nebula lighthouse resource.

Types

type Metrics added in v0.2.0

type Metrics struct {
	Enabled            types.Bool   `tfsdk:"enabled"`
	Listen             types.String `tfsdk:"listen"`
	Path               types.String `tfsdk:"path"`
	Namespace          types.String `tfsdk:"namespace"`
	Subsystem          types.String `tfsdk:"subsystem"`
	EnableExtraMetrics types.Bool   `tfsdk:"enable_extra_metrics"`
}

Metrics is the host metrics exporter's state.

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

Resource is Defined.net Nebula lighthouse resource.

func (*Resource) Configure

Configure configures the resource.

func (*Resource) Create

Create creates Nebula lighthouses on Defined.net control plane.

func (*Resource) Delete

Delete deletes Nebula lighthouses from Defined.net control plane.

func (*Resource) ImportState

ImportState imports Nebula lighthouses from Defined.net control plane.

func (*Resource) Metadata

Metadata returns the resource's metadata.

func (*Resource) Read

Read reads Nebula lighthouses from Defined.net control plane.

func (*Resource) Schema

Schema returns the resource's configuration schema.

func (*Resource) Update

Update updates Nebula lighthouses on Defined.net control plane.

type State

type State struct {
	ID              types.String `tfsdk:"id"`
	NetworkID       types.String `tfsdk:"network_id"`
	RoleID          types.String `tfsdk:"role_id"`
	StaticAddresses types.List   `tfsdk:"static_addresses"`
	ListenPort      types.Int32  `tfsdk:"listen_port"`
	Name            types.String `tfsdk:"name"`
	IPAddress       types.String `tfsdk:"ip_address"`
	Tags            types.List   `tfsdk:"tags"`
	EnrollmentCode  types.String `tfsdk:"enrollment_code"`
	Metrics         *Metrics     `tfsdk:"metrics"`
}

State is the lighthouse resource's state.

func (*State) ApplyEnrollment

func (s *State) ApplyEnrollment(ctx context.Context, enrollment *definednet.Enrollment) (diags diag.Diagnostics)

ApplyEnrollment applies Defined.net host enrollment information to the state.

func (*State) ApplyHost

func (s *State) ApplyHost(ctx context.Context, lighthouse *definednet.Host) (diags diag.Diagnostics)

ApplyHost applies Defined.net lighthouse information to the state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL