A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/libdns/googleclouddns below:

libdns/googleclouddns: Google Cloud DNS provider implementation for libdns interfaces

Google Cloud DNS for libdns

This package implements the libdns interfaces for Google Cloud.

The googleclouddns package will authenticate using the supported authentication methods found in the google-cloud-go library:

The package also requires the project where the Google Cloud DNS zone exists

This package implements the libdns interfaces for Google Cloud DNS, allowing you to manage DNS records.

Here's a minimal example of how to get all your DNS records using this libdns provider:

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/libdns/googleclouddns"
)

// main shows how libdns works with Google Cloud DNS.
//
// In this example, the project where the Cloud DNS zone exists is passed 
// as an environment variable. Auth data is determined through normal 
// Google Cloud Go API sources.
func main() {
	// Create new provider instance
	googleProvider := googleclouddns.Provider{
		Project: os.Getenv("GCP_PROJECT"),
	}
	zone := `example.localhost`

	// List existing records
	fmt.Printf("List existing records\n")
	currentRecords, err := googleProvider.GetRecords(context.TODO(), zone)
	if err != nil {
		fmt.Printf("%v\n", err)
		return
	}
	for _, record := range currentRecords {
		fmt.Printf("Exists: %v\n", record)
	}
}

Note: The Google Cloud DNS API returns 1-n values for each Google DNS recordset. This is converted to a slice of libdns.Records each with the same name but unique values.

This also applies to AppendRecords and SetRecords. If multiple fields are desired for a Google Cloud DNS entry, pass a slice of libdns.Record entries into those functions and they will be added to the Google DNS record in the order of the slice.

Testing relies on the Google httpreplay package. If an updated request to the Google API servers is required, you can do the following:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4