Compare commits
13 Commits
ad86804f56
...
8e5b52cdc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e5b52cdc1 | ||
|
|
2182e2a4ea | ||
|
|
ce4d2bfe50 | ||
|
|
1787e44503 | ||
|
|
bc4f7b7309 | ||
|
|
f7d8b42c7b | ||
|
|
1fb3ef1e71 | ||
|
|
3e153f7f44 | ||
|
|
8b30f7bd3d | ||
|
|
d304dafeea | ||
|
|
9271906435 | ||
|
|
7146139ae8 | ||
|
|
ef74ede862 |
@@ -51,10 +51,10 @@ func init() {
|
||||
// CloudflareDNSRes is a resource for managing DNS records in Cloudflare zones.
|
||||
// This resource uses the Cloudflare API to create, update, and delete DNS
|
||||
// records in a specified zone. It supports various record types including A,
|
||||
// AAAA, CNAME, MX, TXT, NS, and PTR records. The resource requires polling to
|
||||
// detect changes, as the Cloudflare API does not provide an event stream. The
|
||||
// Purge functionality allows enforcing that only managed DNS records exist in
|
||||
// the zone, removing any unmanaged records.
|
||||
// AAAA, CNAME, MX, TXT, NS, and PTR records. The resource requires polling
|
||||
// to detect changes, as the Cloudflare API does not provide an event stream.
|
||||
// The Purge functionality allows enforcing that only managed DNS records exist
|
||||
// in the zone, removing any unmanaged records.
|
||||
type CloudflareDNSRes struct {
|
||||
traits.Base
|
||||
traits.GraphQueryable
|
||||
@@ -130,7 +130,7 @@ func (obj *CloudflareDNSRes) Validate() error {
|
||||
}
|
||||
|
||||
if obj.APIToken == "" {
|
||||
return fmt.Errorf("api token is required")
|
||||
return fmt.Errorf("API token is required")
|
||||
}
|
||||
|
||||
if obj.Type == "" {
|
||||
@@ -138,7 +138,7 @@ func (obj *CloudflareDNSRes) Validate() error {
|
||||
}
|
||||
|
||||
if (obj.TTL < 60 || obj.TTL > 86400) && obj.TTL != 1 { // API requirement
|
||||
return fmt.Errorf("ttl must be between 60s and 86400s, or set to 1")
|
||||
return fmt.Errorf("TTL must be between 60s and 86400s, or set to 1")
|
||||
}
|
||||
|
||||
if obj.Zone == "" {
|
||||
@@ -578,7 +578,7 @@ func (obj *CloudflareDNSRes) needsUpdate(record dns.RecordResponse) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//TODO: add more checks?
|
||||
// TODO add more checks?
|
||||
|
||||
return false
|
||||
|
||||
@@ -679,18 +679,16 @@ func (obj *CloudflareDNSRes) GraphQueryAllowed(opts ...engine.GraphQueryableOpti
|
||||
return nil
|
||||
}
|
||||
|
||||
// matchesRecordName checks if a record name from the API matches our desired
|
||||
// record name. Handles both FQDN (www.example.com) and short form (www)
|
||||
// comparisons.
|
||||
// matchesRecordName checks if a record name from the API matches our desired record name.
|
||||
// Handles both FQDN (www.example.com) and short form (www) comparisons.
|
||||
func (obj *CloudflareDNSRes) matchesRecordName(apiRecordName string) bool {
|
||||
desired := obj.normalizeRecordName(obj.RecordName)
|
||||
actual := obj.normalizeRecordName(apiRecordName)
|
||||
return desired == actual
|
||||
}
|
||||
|
||||
// normalizeRecordName converts a record name to a consistent format for
|
||||
// comparison. Converts to FQDN format (e.g., "www" -> "www.example.com", "@" ->
|
||||
// "example.com")
|
||||
// normalizeRecordName converts a record name to a consistent format for comparison.
|
||||
// Converts to FQDN format (e.g., "www" -> "www.example.com", "@" -> "example.com")
|
||||
func (obj *CloudflareDNSRes) normalizeRecordName(name string) string {
|
||||
if name == "@" || name == obj.Zone {
|
||||
return obj.Zone
|
||||
|
||||
@@ -36,7 +36,6 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -622,15 +621,6 @@ func (obj *VirtBuilderRes) CheckApply(ctx context.Context, apply bool) (bool, er
|
||||
|
||||
cmd := exec.CommandContext(ctx, cmdName, cmdArgs...)
|
||||
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
// FIXME: consider building this from an empty environment?
|
||||
cmd.Env = append(os.Environ(),
|
||||
fmt.Sprintf("HOME=%s", usr.HomeDir),
|
||||
)
|
||||
|
||||
// ignore signals sent to parent process (we're in our own group)
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Setpgid: true,
|
||||
@@ -648,7 +638,7 @@ func (obj *VirtBuilderRes) CheckApply(ctx context.Context, apply bool) (bool, er
|
||||
return false, errwrap.Wrapf(err, "error starting cmd")
|
||||
}
|
||||
|
||||
cmderr := cmd.Wait() // we can unblock this with the timeout
|
||||
err := cmd.Wait() // we can unblock this with the timeout
|
||||
out := b.String()
|
||||
|
||||
p := path.Join(obj.varDir, fmt.Sprintf("%d.log", start))
|
||||
@@ -658,7 +648,7 @@ func (obj *VirtBuilderRes) CheckApply(ctx context.Context, apply bool) (bool, er
|
||||
}
|
||||
}
|
||||
|
||||
if cmderr == nil {
|
||||
if err == nil {
|
||||
obj.init.Logf("built image successfully!")
|
||||
return false, nil // success!
|
||||
}
|
||||
@@ -677,7 +667,7 @@ func (obj *VirtBuilderRes) CheckApply(ctx context.Context, apply bool) (bool, er
|
||||
obj.init.Logf("deleted partial output")
|
||||
}
|
||||
|
||||
exitErr, ok := cmderr.(*exec.ExitError) // embeds an os.ProcessState
|
||||
exitErr, ok := err.(*exec.ExitError) // embeds an os.ProcessState
|
||||
if !ok {
|
||||
// command failed in some bad way
|
||||
return false, errwrap.Wrapf(err, "cmd failed in some bad way")
|
||||
|
||||
Reference in New Issue
Block a user