deploy

package
v0.0.0-...-059d9f2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 47 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ManifestFile = ".edge/manifest.json"

ManifestFile is where the bundler writes the manifest the deploy applies.

View Source
const PathStatic = ".edge/storage"

Variables

This section is empty.

Functions

func CreateBucketCredentials

func CreateBucketCredentials(ctx context.Context, bucketName string, f *cmdutil.Factory, subdir string) (token.S3Credentials, error)

CreateBucketCredentials creates S3 credentials for a specific bucket and saves them to the credentials file

func CreateBucketCredentialsV6

func CreateBucketCredentialsV6(ctx context.Context, bucketName string, f *cmdutil.Factory, subdir string) (token.S3Credentials, error)

CreateBucketCredentialsV6 is CreateBucketCredentials for the v6 deploy: it creates the credentials through the v6 storage API.

func HandleDeployTimingCallback

func HandleDeployTimingCallback(name string, duration time.Duration)

HandleDeployTimingCallback records how long each v4 deploy step took.

It is the deploy counterpart of HandleManifestTimingCallback: the pipeline runner reports (step name, duration) and this maps the name onto the field the summary prints. Steps no longer time themselves.

The two manifest-read steps both accumulate onto ReadManifestTime, which reproduces the "= then +=" of the sequence this replaces: InitTimingSummary allocates a fresh summary, so the field starts at zero and the first += is equivalent to an assignment.

A name with no field here is ignored, exactly as the manifest handler does — steps that were never timed, such as the application or the workload, stay untimed.

func HandleManifestTimingCallback

func HandleManifestTimingCallback(name string, duration time.Duration)

HandleManifestTimingCallback handles timing callbacks from the manifest package

func IgnoreSkipsOnFirstRun

func IgnoreSkipsOnFirstRun(notFirstRun bool, skips ...*bool) bool

IgnoreSkipsOnFirstRun clears the skip flags on a first run, which has to build and upload the static files. It reports whether any flag was set.

func InitTimingSummary

func InitTimingSummary()

InitTimingSummary initializes the global timing summary

func ManifestMissing

func ManifestMissing() bool

ManifestMissing reports whether .edge/manifest.json is absent.

func NewCmd

func NewCmd(f *cmdutil.Factory) *cobra.Command

func NewCobraCmd

func NewCobraCmd(deploy *DeployCmd) *cobra.Command

func PurgeForUpdatedFiles

func PurgeForUpdatedFiles(cmd *DeployCmd, workload apiworkload.WorkloadResponse, confPath string, msgs *[]string) (err error)

func ReadSettings

func ReadSettings(path string) (token.Settings, error)

ReadSettings reads the settings file for S3 credentials

func StorageClient

func StorageClient(cmd *DeployCmd) *storage.Client

StorageClient is the client EnsureBucket takes.

func TimeAPICall

func TimeAPICall(name string, fn func() error) error

TimeAPICall is a helper function to time an API call and record it

func TimeAPICallWithResult

func TimeAPICallWithResult[T any](name string, fn func() (T, error)) (T, error)

TimeAPICallWithResult is a helper function to time an API call that returns a result and record it

func UploadFiles

func UploadFiles(f *cmdutil.Factory, conf *contracts.AzionApplicationOptions, msgs *[]string, dir string, bucket string, settings token.Settings, cmd *DeployCmd) error

UploadFiles is the package-level function that calls the method

func ValidateStorageDirs

func ValidateStorageDirs(storages []contracts.StorageManifest) error

ValidateStorageDirs fails when a storage entry of the manifest names a dir that does not exist or holds no file to upload. Entries without a dir are not checked: they declare a bucket and nothing to upload.

func Worker

func Worker(jobs <-chan contracts.FileOps, results chan<- error, currentFile *int64, cfg aws.Config, bucket, prefix string)

Worker reads the range of jobs and uploads the file, if there is an error during upload, we return it through the results channel

func WriteManifest

func WriteManifest(manifest *contracts.ManifestV4, pathMan string) error

Types

type APICallTiming

type APICallTiming struct {
	Name     string
	Duration time.Duration
}

APICallTiming holds timing information for individual API calls

type Clients

type Clients struct {
	Function    *apiFunction.Client
	Application *apiApplications.Client
	Workload    *apiWorkload.Client
	Origin      *apiOrigin.Client
	Bucket      *apiStorage.Client
	Storage     *apiStorage.Client
}

func NewClients

func NewClients(f *cmdutil.Factory) *Clients

type Data

type Data struct {
	Name string `json:"name"`
	Hash string `json:"hash"`
}

func ReadFilesEdgeStorage

func ReadFilesEdgeStorage() ([]Data, error)

func ReadFilesJSONL

func ReadFilesJSONL() ([]Data, error)

type DeployCmd

type DeployCmd struct {
	Io                    *iostreams.IOStreams
	GetWorkDir            func() (string, error)
	FileReader            func(path string) ([]byte, error)
	WriteFile             func(filename string, data []byte, perm fs.FileMode) error
	GetAzionJsonContent   func(pathConfig string) (*contracts.AzionApplicationOptions, error)
	WriteAzionJsonContent func(conf *contracts.AzionApplicationOptions, confConf string) error

	WriteManifest            func(manifest *contracts.ManifestV4, pathMan string) error
	EnvLoader                func(path string) ([]string, error)
	BuildCmd                 func(f *cmdutil.Factory) *build.BuildCmd
	Open                     func(name string) (*os.File, error)
	FilepathWalk             func(root string, fn filepath.WalkFunc) error
	F                        *cmdutil.Factory
	Unmarshal                func(data []byte, v interface{}) error
	Interpreter              func() *manifestInt.ManifestInterpreter
	VersionID                func() string
	ReadSettings             func(path string) (token.Settings, error)
	GetCredentialsForBucket  func(path string, bucketName string) (token.S3Credentials, bool, error)
	SaveCredentialsForBucket func(path string, bucketName string, creds token.S3Credentials) error
	CreateBucketCredentials  func(ctx context.Context, bucketName string, f *cmdutil.Factory, subdir string) (token.S3Credentials, error)
	Auto                     bool
	Env                      string
	NoPrompt                 bool
	Path                     string
	ProjectConf              string
	Sync                     bool
	SkipBuild                bool
	SkipFramework            bool
	WriteBucket              bool
	Workers                  int
	AliasEnv                 bool
	ConfigFile               string
	// NewVulcan picks the bundler. Nil means the one for the account's API
	// generation (vulcan.For).
	NewVulcan func() *vulcanPkg.VulcanPkg
	// ExtraReplacements are placeholders the first run replaces in
	// azion.config on top of the v4 ones (the v6 presets add
	// $ENVIRONMENT_NAME).
	ExtraReplacements map[string]string
	// contains filtered or unexported fields
}

func NewDeployCmd

func NewDeployCmd(f *cmdutil.Factory) *DeployCmd

func (*DeployCmd) Build

func (cmd *DeployCmd) Build(p *Project, oldPrefix, newPrefix string, msgs *[]string) error

Build rotates the prefix and builds a project that was deployed before.

func (*DeployCmd) BundlerInit

func (cmd *DeployCmd) BundlerInit(p *Project, newPrefix string, msgs *[]string) error

BundlerInit initialises the bundler on a first run and builds.

func (*DeployCmd) DryRun

func (cmd *DeployCmd) DryRun(f *cmdutil.Factory) error

DryRun describes what `azion deploy` would do, without doing any of it.

It asks the real pipeline which steps apply — the same table Run executes — so the description cannot drift from the deploy. pipeline.Run in dry-run mode evaluates the predicates and never calls a step's Run, and nothing here issues an API request.

The simulation this replaces kept its own copy of the conditions and had drifted: it announced a single origin and a default-rule update, which do not exist in the v4 flow, and gated the bucket on the project preset rather than on the manifest declaring storage.

func (*DeployCmd) EnsureBucket

func (cmd *DeployCmd) EnsureBucket(ctx context.Context, client *storage.Client, p *Project, msgs *[]string, manifest []contracts.StorageManifest) error

EnsureBucket creates the project's bucket when it has none.

func (*DeployCmd) ExternalRun

func (cmd *DeployCmd) ExternalRun(f *cmdutil.Factory, configPath string, env string, shouldSync, auto, skipBuild, writeBucket, skipFramework, aliasEnv bool, workers int) error

func (*DeployCmd) ForV6

func (cmd *DeployCmd) ForV6() *DeployCmd

ForV6 prepares a DeployCmd for use by the v6 deploy. The shared helpers save azion.json in the v4 format when they finish; for a v6 project that would overwrite its own file, so the v6 deploy, which saves after each step, turns that off here.

It also runs the bundler with --config-version 6 (vulcan.NewVulcanV6), so the manifest comes out in the v6 format.

func (*DeployCmd) GenerateManifest

func (cmd *DeployCmd) GenerateManifest(p *Project, msgs *[]string) error

GenerateManifest writes the manifest without building, like init does.

func (*DeployCmd) GetOrCreateCredentials

func (cmd *DeployCmd) GetOrCreateCredentials(ctx context.Context, bucketName string, profile string) (token.S3Credentials, error)

GetOrCreateCredentials retrieves existing credentials for a bucket or creates new ones if they don't exist

func (*DeployCmd) PurgeUrls

func (cmd *DeployCmd) PurgeUrls(domain []string, path string) error

func (*DeployCmd) PurgeWildcard

func (cmd *DeployCmd) PurgeWildcard(domain []string, path string) error

func (*DeployCmd) Run

func (cmd *DeployCmd) Run(f *cmdutil.Factory) error

func (*DeployCmd) ShouldUpload

func (cmd *DeployCmd) ShouldUpload(msgs *[]string) bool

ShouldUpload reports whether this run uploads static files, with the same rules as the v4 deploy.

func (*DeployCmd) UploadStatic

func (cmd *DeployCmd) UploadStatic(p *Project, msgs *[]string, dirs []contracts.StorageManifest, creds token.S3Credentials) error

UploadStatic uploads each storage directory of the manifest to the bucket.

type DeployState

type DeployState struct {
	Cmd  *DeployCmd
	F    *cmdutil.Factory
	Ctx  context.Context
	Conf *contracts.AzionApplicationOptions
	Msgs *[]string

	Clients     *Clients
	Interpreter *manifestInt.ManifestInterpreter

	// PathManifest is set by the manifest-path step and read by both reads.
	PathManifest string
	// Manifest is set by the first read and replaced by the second, after the
	// build has had a chance to regenerate it.
	Manifest *contracts.ManifestV4

	// Creds is obtained by the credentials step and used by the upload step.
	Creds token.S3Credentials

	// OldPrefix and NewPrefix are computed once, before the pipeline runs, and
	// consumed by the build and bundler-init steps.
	OldPrefix, NewPrefix string
	// contains filtered or unexported fields
}

DeployState is what the v4 deploy steps read and write.

The sequence this replaces threaded all of it through locals in one ~160-line function. Two fields are written by one step and read by later ones — PathManifest and Manifest — which is the dependency the step order encodes.

type Project

type Project struct {
	Name         string
	Bucket       string
	Prefix       string
	Preset       string
	RotatePrefix *bool
	NotFirstRun  bool
}

Project is what the shared steps read and write about the project.

type Timer

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

Timer is a simple utility for timing operations

func NewTimer

func NewTimer(name string) *Timer

NewTimer creates a new timer and starts it

func (*Timer) Elapsed

func (t *Timer) Elapsed() time.Duration

Elapsed returns the time elapsed since the timer was started

func (*Timer) Stop

func (t *Timer) Stop() time.Duration

Stop stops the timer and returns the elapsed time

type TimingSummary

type TimingSummary struct {
	TotalDeployTime       time.Duration
	UploadStaticFilesTime time.Duration
	BucketCreateTime      time.Duration
	CredentialsTime       time.Duration
	ManifestCreateTime    time.Duration
	ReadManifestTime      time.Duration
	// Manifest resource timings
	ManifestFunctionsTime           time.Duration
	ManifestFunctionInstancesTime   time.Duration
	ManifestEdgeApplicationTime     time.Duration
	ManifestCacheSettingsTime       time.Duration
	ManifestConnectorsTime          time.Duration
	ManifestRulesEngineTime         time.Duration
	ManifestWorkloadsTime           time.Duration
	ManifestWorkloadDeploymentsTime time.Duration
	ManifestFirewallsTime           time.Duration
	ManifestPurgeTime               time.Duration
	APICallTimes                    []APICallTiming
	// contains filtered or unexported fields
}

TimingSummary holds the timing information for each phase of the deploy process

var GlobalTimingSummary *TimingSummary

GlobalTimingSummary is the global timing summary for the deploy process

func (*TimingSummary) AddAPICallTime

func (ts *TimingSummary) AddAPICallTime(name string, duration time.Duration)

AddAPICallTime adds an API call timing to the summary

func (*TimingSummary) GetTotalTime

func (ts *TimingSummary) GetTotalTime() time.Duration

GetTotalTime returns the total deploy time

func (*TimingSummary) PrintSummary

func (ts *TimingSummary) PrintSummary()

PrintSummary prints the timing summary in debug format

type V4DeployPipeline

type V4DeployPipeline struct{}

V4DeployPipeline is the deploy flow for the v4 API.

Steps do not time themselves: the runner reports each step's duration to HandleDeployTimingCallback, which maps the step name onto the field the summary prints.

func (V4DeployPipeline) Name

func (V4DeployPipeline) Name() string

func (V4DeployPipeline) Steps

Directories

Path Synopsis
Package v6 is the deploy for API v6 accounts, as planned in doc/V6-DEPLOY-PLAN.md.
Package v6 is the deploy for API v6 accounts, as planned in doc/V6-DEPLOY-PLAN.md.

Jump to

Keyboard shortcuts

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