Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Add missing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
onwsk8r committed Mar 27, 2020
1 parent d11ef6d commit 6e213c8
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 6 deletions.
1 change: 1 addition & 0 deletions internal/provider/data_rack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/gmaw"
)

// DataRackController provides a lookup for MaaS Rack Controllers
func DataRackController() *schema.Resource {
return &schema.Resource{
Read: dataRackControllerRead,
Expand Down
1 change: 1 addition & 0 deletions internal/provider/data_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/maas/entity"
)

// DataSubnet provides a lookup for a MaaS Subnet
func DataSubnet() *schema.Resource {
return &schema.Resource{
Read: dataSubnetRead,
Expand Down
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)

// Provider exports a Terraform resource provider and is meant to be called from main().
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/maas"
)

// resourceInstance provides a resource that correlates to the MaaS Machine endpoint
func resourceInstance() *schema.Resource {
return &schema.Resource{
Create: resourceInstanceCreate,
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resource_maas_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/gmaw"
)

// ResourceServer manages global MaaS configuration options ala the MaaS Server endpoint
func ResourceServer() *schema.Resource {
return &schema.Resource{
Create: resourceServerCreate,
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resource_network_interface_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/roblox/terraform-provider-maas/internal/tfschema"
)

// ResourceNetworkInterfaceLink provides a resource that can be used to manage links between interfaces
func ResourceNetworkInterfaceLink() *schema.Resource {
return &schema.Resource{
Create: resourceNetworkInterfaceLinkCreate,
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resource_network_interface_physical.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/roblox/terraform-provider-maas/internal/tfschema"
)

// ResourceNetworkInterfacePhysical provides a resource to manage physical interfaces
func ResourceNetworkInterfacePhysical() *schema.Resource {
return &schema.Resource{
Create: resourceNetworkInterfacePhysicalCreate,
Expand Down
13 changes: 13 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*package api defines an interface to each MaaS API endpoint.
Each interface correlates to one endpoint, such as Subnets for the Subnets
endpoint (ie /subnets) and Subnet for the Subnet endpoint (eg subnets/<subnet_id>).
API clients are expected to implement these interfaces to provide a normalized way
of accessing the MaaS API with normalized results (eg the types defined in the
entity package).
Some endpoint operations require multiple parameters, such as the Rack Controllers
GET operation, which takes a number of QSP that can be used to filter results. These
parameters are encapsulated in the params subpackage, providing a quick reference
for performing API operations.*/
package api
1 change: 1 addition & 0 deletions pkg/api/maas_server.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package api

// MAASServer represents the MaaS Server endpoint for changing global configuration settings
type MAASServer interface {
Get(name string) (value string, err error)
Post(name, value string) error
Expand Down
1 change: 1 addition & 0 deletions pkg/api/rack_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/maas/entity"
)

// RackControllers represents the MaaS Rack Controllers endpoint
type RackControllers interface {
Get(*params.RackControllerSearch) ([]entity.RackController, error)
}
1 change: 1 addition & 0 deletions pkg/api/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/maas/entity/subnet"
)

// Subnet represents the MaaS Subnet endpoint
type Subnet interface {
Delete(id int) error
Get(id int) (*entity.Subnet, error)
Expand Down
1 change: 1 addition & 0 deletions pkg/api/subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/maas/entity"
)

// Subnets represents the MaaS Subnets endpoint
type Subnets interface {
Get() ([]entity.Subnet, error)
Post(*params.Subnet) (*entity.Subnet, error)
Expand Down
1 change: 1 addition & 0 deletions pkg/api/vlans.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/roblox/terraform-provider-maas/pkg/maas/entity"
)

// VLANs represents the MaaS Vlans endpoint
type VLANs interface {
Get(fabricID int) ([]entity.VLAN, error)
Post(fabricID int, params *params.VLAN) (*entity.VLAN, error)
Expand Down
11 changes: 11 additions & 0 deletions pkg/maas/entity/entity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*package entity defines types for the MaaS API endpoints' return types.
Each endpoint returns JSON that describes the object it represents. For example,
GETting the Subnets endpoint will return an array of Subnet, while GETting the
Subnet endpoint (ie subnets/<subnet_id>) will return one Subnet.
Some endpoints expose operations that return metadata about the object, such as as
Subnet's GetStatistics(), which contains statistics about the subnet, but does not
actually describe the subnet: these alternative types can be found in subpackages
named after the endpoint.*/
package entity
3 changes: 3 additions & 0 deletions pkg/maas/entity/subnet/ip_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net"
)

// IPAddress represents an IP address from a Subnet's GetIPAddresses()
type IPAddress struct {
IP net.IP `json:"ip,omitempty"`
AllocType int `json:"alloc_type,omitempty"`
Expand All @@ -13,6 +14,8 @@ type IPAddress struct {
User string `json:"user,omitempty"`
}

// NodeSummary represents the optional node_summary from GetIPAddresses().
// This type should not be used directly.
type NodeSummary struct {
SystemID string `json:"system_id,omitempty"`
NodeType int `json:"node_type,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/maas/entity/subnet/ip_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package subnet

import "net"

// IPRange represents an IP range from a Subnet's GetUnreservedIPRanges()
type IPRange struct {
Start net.IP `json:"start,omitempty"`
End net.IP `json:"end,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/maas/entity/subnet/reserved_ip_range.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package subnet

// ReservedIPRange represents an IP range from a Subnet's GetReservedIPRanges()
type ReservedIPRange struct {
IPRange
Purpose []string `json:"purpose,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/maas/entity/subnet/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package subnet

import "net"

// Statistics represents a Subnet's GetStatistics()
type Statistics struct {
NumAvailable int `json:"num_available,omitempty"`
LargestAvailable int `json:"largest_available,omitempty"`
Expand Down
4 changes: 0 additions & 4 deletions pkg/maas/maas.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,3 @@ func ToQSP(t interface{}) url.Values {
}
return qsp
}

func ToSnakeCase(s string) string {
return s
}
4 changes: 2 additions & 2 deletions pkg/maas/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package maas
// Machines represents the Machines endpoint
type Machines []Machine

// MachinesManager
// MachinesManager provides locking and management capabilities for Machines
type MachinesManager struct {
client MachinesFetcher
}

// NewMachineManager
// NewMachineManager creates a new MachinesManager
func NewMachinesManager(client MachinesFetcher) *MachinesManager {
return &MachinesManager{client: client}
}
Expand Down

0 comments on commit 6e213c8

Please sign in to comment.