cmd

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VersionContextKey is the context key under which the app version string is stored.
	VersionContextKey ctxKey = iota

	// SkipTokenContextKey is the context key on if the API token permission should be checked.
	SkipTokenContextKey
)

Variables

View Source
var (
	APIClient *cloudflare.API
)
View Source
var (
	ErrAPIPermissionError = errors.New("API Token does not have the required permissions")
)

Functions

func BuildApp

func BuildApp(args BuildArgs) *cli.Command

func CacheCleaner

func CacheCleaner(ctx context.Context, c *cli.Command) error

func CheckAPITokenPermission

func CheckAPITokenPermission(ctx context.Context, permission ...APIPermissionName) error

func DNSCleaner

func DNSCleaner(ctx context.Context, c *cli.Command) error

DNSCleaner is the main action function for the dns-cleaner command. It checks if a DNS file exists. If there isn't a DNS file, then it downloads records, if there is a file there, then it uploads records.

func DNSPurge

func DNSPurge(ctx context.Context, c *cli.Command) error

DNSPurge is a command to delete all dns records without downloading.

func DeploymentsPaginate

DeploymentsPaginate is a helper function to paginate through all deployments. This is necessary because we need to be able to adjust the per_page parameter for large projects.

func DownloadDNS

func DownloadDNS(ctx context.Context, c *cli.Command) error

DownloadDNS downloads current DNS records from Cloudflare.

func GetLatestTunnelVersion

func GetLatestTunnelVersion(ctx context.Context, token string) (string, error)

func GetWebOauthToken

func GetWebOauthToken(ctx context.Context) (*oauth2.Token, error)

func GetZoneID

func GetZoneID(ctx context.Context, c *cli.Command) error

GetZoneID gets the zone ID from the CLI flags either by name or ID.

func PollForToken

func PollForToken(ctx context.Context, registrationID string) (*oauth2.Token, error)

func PollListBulkOperation

func PollListBulkOperation(ctx context.Context, rc *cloudflare.ResourceContainer, ID string) error

func PruneBranchDeployments

func PruneBranchDeployments(branch string, options pruneDeploymentOptions) []cloudflare.PagesProjectDeployment

PruneBranchDeployments will return a list of deployments to delete based on the branch name.

func PruneDeploymentsRoot

func PruneDeploymentsRoot(ctx context.Context, c *cli.Command) error

PruneDeploymentsRoot is the main function for pruning and purging deployments.

func PruneDeploymentsScreen

func PruneDeploymentsScreen(ctx context.Context, c *cli.Command) error

PruneDeploymentsScreen is the entry point for the prune-deployments command. It handles parsing the CLI arguments and then calls PruneDeploymentsRoot.

func PruneTimeDeployments

func PruneTimeDeployments(options pruneDeploymentOptions) (toDelete []cloudflare.PagesProjectDeployment)

PruneTimeDeployments will return a list of deployments to delete based on the time range.

func PurgeDeploymentsScreen

func PurgeDeploymentsScreen(ctx context.Context, c *cli.Command) error

PurgeDeploymentsScreen is the entry point for the purge-deployments command It just calls PruneDeploymentsRoot.

func RapidDNSDelete

func RapidDNSDelete(rc *cloudflare.ResourceContainer, dnsRecords []cloudflare.DNSRecord) map[string]error

RapidDNSDelete is a helper function to delete DNS records quickly. Uses a pool of goroutines to delete records in parallel.

func RapidPagesDeploymentDelete

func RapidPagesDeploymentDelete(options pruneDeploymentOptions) map[string]error

RapidPagesDeploymentDelete is a helper function to delete Pages deployments quickly. Uses a pool of goroutines to delete deployments in parallel.

func SetLogLevel

func SetLogLevel(c *cli.Command, logger *logrus.Logger)

SetLogLevel sets the log level based on the CLI flags.

func SyncList

func SyncList(ctx context.Context, c *cli.Command) error

func TunnelVersionAction

func TunnelVersionAction(ctx context.Context, c *cli.Command) error

func UploadDNS

func UploadDNS(_ context.Context, c *cli.Command) error

UploadDNS makes the changes to DNS records based on the dns file.

func VerifyAPIToken

func VerifyAPIToken(ctx context.Context) (cloudflare.APIToken, error)

Types

type APIPermissionName

type APIPermissionName string
const (
	DNSWrite    APIPermissionName = "DNSWrite"
	PagesWrite  APIPermissionName = "PagesWrite"
	TunnelRead  APIPermissionName = "TunnelRead"
	TunnelWrite APIPermissionName = "TunnelWrite"
	ListsWrites APIPermissionName = "ListsWrite"
	CachePurge  APIPermissionName = "CachePurge"
)

type BuildArgs

type BuildArgs struct {
	StartTime time.Time
	Version   string
	Date      string
	Logger    *logrus.Logger
}

type DNSRecord

type DNSRecord struct {
	ID      string `yaml:"id"`
	Keep    bool   `yaml:"keep"`
	Name    string `yaml:"name"`
	Type    string `yaml:"type"`
	Content string `yaml:"content"`
}

type OAuthV1RegistrationResponse

type OAuthV1RegistrationResponse struct {
	RegistrationID string `json:"registration_id"`
	URL            string `json:"url"`
	ExpiresIN      int    `json:"expires_in"`
}

type OAuthV1Response

type OAuthV1Response struct {
	Status      OauthStatus `json:"status"`
	AccessToken string      `json:"access_token,omitempty"`
	ExpiresAt   int64       `json:"expires_at,omitempty"`
}

type OauthStatus

type OauthStatus string
const (
	OauthPending OauthStatus = "pending"
	OauthSuccess OauthStatus = "success"
)

type PagesDeploymentPaginationOptions

type PagesDeploymentPaginationOptions struct {
	CLIContext *cli.Command

	ProjectName string
	// contains filtered or unexported fields
}

type RecordFile

type RecordFile struct {
	ZoneName string      `yaml:"zone_name"`
	ZoneID   string      `yaml:"zone_id"`
	Records  []DNSRecord `yaml:"records"`
}

RecordFile is the struct of the YAML DNS file.

Jump to

Keyboard shortcuts

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