externaldnsapi

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTypeAssertionError is thrown when type an interface does not match the asserted type
	ErrTypeAssertionError = errors.New("unable to assert type")
)

Functions

func AssertChangesConstraints

func AssertChangesConstraints(obj Changes) error

AssertChangesConstraints checks if the values respects the defined constraints

func AssertChangesRequired

func AssertChangesRequired(obj Changes) error

AssertChangesRequired checks if the required fields are not zero-ed

func AssertEndpointConstraints

func AssertEndpointConstraints(obj Endpoint) error

AssertEndpointConstraints checks if the values respects the defined constraints

func AssertEndpointRequired

func AssertEndpointRequired(obj Endpoint) error

AssertEndpointRequired checks if the required fields are not zero-ed

func AssertFiltersConstraints

func AssertFiltersConstraints(obj Filters) error

AssertFiltersConstraints checks if the values respects the defined constraints

func AssertFiltersRequired

func AssertFiltersRequired(obj Filters) error

AssertFiltersRequired checks if the required fields are not zero-ed

func AssertProviderSpecificPropertyConstraints

func AssertProviderSpecificPropertyConstraints(obj ProviderSpecificProperty) error

AssertProviderSpecificPropertyConstraints checks if the values respects the defined constraints

func AssertProviderSpecificPropertyRequired

func AssertProviderSpecificPropertyRequired(obj ProviderSpecificProperty) error

AssertProviderSpecificPropertyRequired checks if the required fields are not zero-ed

func AssertRecurseInterfaceRequired

func AssertRecurseInterfaceRequired[T any](obj interface{}, callback func(T) error) error

AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertRecurseValueRequired

func AssertRecurseValueRequired[T any](value reflect.Value, callback func(T) error) error

AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion. ErrTypeAssertionError is thrown if the underlying struct does not match type T.

func DefaultErrorHandler

func DefaultErrorHandler(w http.ResponseWriter, _ *http.Request, err error, result *ImplResponse)

DefaultErrorHandler defines the default logic on how to handle errors from the controller. Any errors from parsing request params will return a StatusBadRequest. Otherwise, the error code originating from the servicer will be used.

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func IsZeroValue

func IsZeroValue(val interface{}) bool

IsZeroValue checks if the val is the zero-ed value.

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func ReadFormFilesToTempFiles

func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)

ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files

Types

type Changes

type Changes struct {

	// This is a list of DNS records.
	Create []Endpoint `json:"create,omitempty"`

	// This is a list of DNS records.
	UpdateOld []Endpoint `json:"updateOld,omitempty"`

	// This is a list of DNS records.
	UpdateNew []Endpoint `json:"updateNew,omitempty"`

	// This is a list of DNS records.
	Delete []Endpoint `json:"delete,omitempty"`
}

Changes - This is the list of changes send by `external-dns` that need to be applied. There are four lists of endpoints. The `create` and `delete` lists are lists of records to create and delete respectively. The `updateOld` and `updateNew` lists are paired. For each entry there's the old version of the record and a new version of the record.

type Constraint

type Constraint[T Number | string | bool] func(actual T) error

func WithMaximum

func WithMaximum[T Number](expected T) Constraint[T]

func WithMinimum

func WithMinimum[T Number](expected T) Constraint[T]

type Endpoint

type Endpoint struct {
	DnsName string `json:"dnsName,omitempty"`

	// This is the list of targets that this DNS record points to. So for an A record it will be a list of IP addresses.
	Targets []string `json:"targets,omitempty"`

	RecordType string `json:"recordType,omitempty"`

	SetIdentifier string `json:"setIdentifier,omitempty"`

	RecordTTL int64 `json:"recordTTL,omitempty"`

	Labels map[string]string `json:"labels,omitempty"`

	ProviderSpecific []ProviderSpecificProperty `json:"providerSpecific,omitempty"`
}

Endpoint - This is a DNS record.

type ErrorHandler

type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)

ErrorHandler defines the required method for handling error. You may implement it and inject this into a controller if you would like errors to be handled differently from the DefaultErrorHandler

type Filters

type Filters struct {
	Filters []string `json:"filters,omitempty"`
}

Filters - external-dns will only create DNS records for host names (specified in ingress objects and services with the external-dns annotation) related to zones that match filters. They can set in external-dns deployment manifest.

type ImplResponse

type ImplResponse struct {
	Code int
	Body interface{}
}

ImplResponse defines an implementation response with error code and the associated body

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type InitializationAPIController

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

InitializationAPIController binds http requests to an api service and writes the service results to the http response

func NewInitializationAPIController

func NewInitializationAPIController(s InitializationAPIServicer, opts ...InitializationAPIOption) *InitializationAPIController

NewInitializationAPIController creates a default api controller

func (*InitializationAPIController) Negotiate

Negotiate - Initialisation and negotiates headers and returns domain filter.

func (*InitializationAPIController) OrderedRoutes added in v0.28.0

func (c *InitializationAPIController) OrderedRoutes() []Route

OrderedRoutes returns all the api routes in a deterministic order for the InitializationAPIController

func (*InitializationAPIController) Routes

func (c *InitializationAPIController) Routes() Routes

Routes returns all the api routes for the InitializationAPIController

type InitializationAPIOption

type InitializationAPIOption func(*InitializationAPIController)

InitializationAPIOption for how the controller is set up.

func WithInitializationAPIErrorHandler

func WithInitializationAPIErrorHandler(h ErrorHandler) InitializationAPIOption

WithInitializationAPIErrorHandler inject ErrorHandler into controller

type InitializationAPIRouter

type InitializationAPIRouter interface {
	Negotiate(http.ResponseWriter, *http.Request)
}

InitializationAPIRouter defines the required methods for binding the api requests to a responses for the InitializationAPI The InitializationAPIRouter implementation should parse necessary information from the http request, pass the data to a InitializationAPIServicer to perform the required actions, then write the service results to the http response.

type InitializationAPIService

type InitializationAPIService struct {
}

InitializationAPIService is a service that implements the logic for the InitializationAPIServicer This service should implement the business logic for every endpoint for the InitializationAPI API. Include any external packages or services that will be required by this service.

func NewInitializationAPIService

func NewInitializationAPIService() *InitializationAPIService

NewInitializationAPIService creates a default api service

func (*InitializationAPIService) Negotiate

Negotiate - Initialisation and negotiates headers and returns domain filter.

type InitializationAPIServicer

type InitializationAPIServicer interface {
	Negotiate(context.Context) (ImplResponse, error)
}

InitializationAPIServicer defines the api actions for the InitializationAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

type ListingAPIController

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

ListingAPIController binds http requests to an api service and writes the service results to the http response

func NewListingAPIController

func NewListingAPIController(s ListingAPIServicer, opts ...ListingAPIOption) *ListingAPIController

NewListingAPIController creates a default api controller

func (*ListingAPIController) GetRecords

func (c *ListingAPIController) GetRecords(w http.ResponseWriter, r *http.Request)

GetRecords - Returns the current records.

func (*ListingAPIController) OrderedRoutes added in v0.28.0

func (c *ListingAPIController) OrderedRoutes() []Route

OrderedRoutes returns all the api routes in a deterministic order for the ListingAPIController

func (*ListingAPIController) Routes

func (c *ListingAPIController) Routes() Routes

Routes returns all the api routes for the ListingAPIController

type ListingAPIOption

type ListingAPIOption func(*ListingAPIController)

ListingAPIOption for how the controller is set up.

func WithListingAPIErrorHandler

func WithListingAPIErrorHandler(h ErrorHandler) ListingAPIOption

WithListingAPIErrorHandler inject ErrorHandler into controller

type ListingAPIRouter

type ListingAPIRouter interface {
	GetRecords(http.ResponseWriter, *http.Request)
}

ListingAPIRouter defines the required methods for binding the api requests to a responses for the ListingAPI The ListingAPIRouter implementation should parse necessary information from the http request, pass the data to a ListingAPIServicer to perform the required actions, then write the service results to the http response.

type ListingAPIService

type ListingAPIService struct {
}

ListingAPIService is a service that implements the logic for the ListingAPIServicer This service should implement the business logic for every endpoint for the ListingAPI API. Include any external packages or services that will be required by this service.

func NewListingAPIService

func NewListingAPIService() *ListingAPIService

NewListingAPIService creates a default api service

func (*ListingAPIService) GetRecords

func (s *ListingAPIService) GetRecords(ctx context.Context) (ImplResponse, error)

GetRecords - Returns the current records.

type ListingAPIServicer

type ListingAPIServicer interface {
	GetRecords(context.Context) (ImplResponse, error)
}

ListingAPIServicer defines the api actions for the ListingAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

type Number

type Number interface {
	~int32 | ~int64 | ~float32 | ~float64
}

type Operation

type Operation[T Number | string | bool] func(actual string) (T, bool, error)

func WithDefaultOrParse

func WithDefaultOrParse[T Number | string | bool](def T, parse ParseString[T]) Operation[T]

func WithParse

func WithParse[T Number | string | bool](parse ParseString[T]) Operation[T]

func WithRequire

func WithRequire[T Number | string | bool](parse ParseString[T]) Operation[T]

type ParseString

type ParseString[T Number | string | bool] func(v string) (T, error)

type ParsingError

type ParsingError struct {
	Param string
	Err   error
}

ParsingError indicates that an error has occurred when parsing request parameters

func (*ParsingError) Error

func (e *ParsingError) Error() string

func (*ParsingError) Unwrap

func (e *ParsingError) Unwrap() error

type ProviderSpecificProperty

type ProviderSpecificProperty struct {
	Name string `json:"name,omitempty"`

	Value string `json:"value,omitempty"`
}

ProviderSpecificProperty - Allows provider to pass property specific to their implementation.

type RequiredError

type RequiredError struct {
	Field string
}

RequiredError indicates that an error has occurred when parsing request parameters

func (*RequiredError) Error

func (e *RequiredError) Error() string

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Router

type Router interface {
	Routes() Routes
	OrderedRoutes() []Route
}

Router defines the required methods for retrieving api routes

type Routes

type Routes map[string]Route

Routes is a map of defined api endpoints

type UpdateAPIController

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

UpdateAPIController binds http requests to an api service and writes the service results to the http response

func NewUpdateAPIController

func NewUpdateAPIController(s UpdateAPIServicer, opts ...UpdateAPIOption) *UpdateAPIController

NewUpdateAPIController creates a default api controller

func (*UpdateAPIController) AdjustRecords

func (c *UpdateAPIController) AdjustRecords(w http.ResponseWriter, r *http.Request)

AdjustRecords - Executes the AdjustEndpoints method.

func (*UpdateAPIController) OrderedRoutes added in v0.28.0

func (c *UpdateAPIController) OrderedRoutes() []Route

OrderedRoutes returns all the api routes in a deterministic order for the UpdateAPIController

func (*UpdateAPIController) Routes

func (c *UpdateAPIController) Routes() Routes

Routes returns all the api routes for the UpdateAPIController

func (*UpdateAPIController) SetRecords

func (c *UpdateAPIController) SetRecords(w http.ResponseWriter, r *http.Request)

SetRecords - Applies the changes.

type UpdateAPIOption

type UpdateAPIOption func(*UpdateAPIController)

UpdateAPIOption for how the controller is set up.

func WithUpdateAPIErrorHandler

func WithUpdateAPIErrorHandler(h ErrorHandler) UpdateAPIOption

WithUpdateAPIErrorHandler inject ErrorHandler into controller

type UpdateAPIRouter

type UpdateAPIRouter interface {
	SetRecords(http.ResponseWriter, *http.Request)
	AdjustRecords(http.ResponseWriter, *http.Request)
}

UpdateAPIRouter defines the required methods for binding the api requests to a responses for the UpdateAPI The UpdateAPIRouter implementation should parse necessary information from the http request, pass the data to a UpdateAPIServicer to perform the required actions, then write the service results to the http response.

type UpdateAPIService

type UpdateAPIService struct {
}

UpdateAPIService is a service that implements the logic for the UpdateAPIServicer This service should implement the business logic for every endpoint for the UpdateAPI API. Include any external packages or services that will be required by this service.

func NewUpdateAPIService

func NewUpdateAPIService() *UpdateAPIService

NewUpdateAPIService creates a default api service

func (*UpdateAPIService) AdjustRecords

func (s *UpdateAPIService) AdjustRecords(ctx context.Context, endpoint []Endpoint) (ImplResponse, error)

AdjustRecords - Executes the AdjustEndpoints method.

func (*UpdateAPIService) SetRecords

func (s *UpdateAPIService) SetRecords(ctx context.Context, changes Changes) (ImplResponse, error)

SetRecords - Applies the changes.

type UpdateAPIServicer

type UpdateAPIServicer interface {
	SetRecords(context.Context, Changes) (ImplResponse, error)
	AdjustRecords(context.Context, []Endpoint) (ImplResponse, error)
}

UpdateAPIServicer defines the api actions for the UpdateAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

Jump to

Keyboard shortcuts

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