Documentation
¶
Index ¶
- Constants
- func CreateBucketCredentials(ctx context.Context, bucketName string, f *cmdutil.Factory, subdir string) (token.S3Credentials, error)
- func CreateBucketCredentialsV6(ctx context.Context, bucketName string, f *cmdutil.Factory, subdir string) (token.S3Credentials, error)
- func HandleDeployTimingCallback(name string, duration time.Duration)
- func HandleManifestTimingCallback(name string, duration time.Duration)
- func IgnoreSkipsOnFirstRun(notFirstRun bool, skips ...*bool) bool
- func InitTimingSummary()
- func ManifestMissing() bool
- func NewCmd(f *cmdutil.Factory) *cobra.Command
- func NewCobraCmd(deploy *DeployCmd) *cobra.Command
- func PurgeForUpdatedFiles(cmd *DeployCmd, workload apiworkload.WorkloadResponse, confPath string, ...) (err error)
- func ReadSettings(path string) (token.Settings, error)
- func StorageClient(cmd *DeployCmd) *storage.Client
- func TimeAPICall(name string, fn func() error) error
- func TimeAPICallWithResult[T any](name string, fn func() (T, error)) (T, error)
- func UploadFiles(f *cmdutil.Factory, conf *contracts.AzionApplicationOptions, msgs *[]string, ...) error
- func ValidateStorageDirs(storages []contracts.StorageManifest) error
- func Worker(jobs <-chan contracts.FileOps, results chan<- error, currentFile *int64, ...)
- func WriteManifest(manifest *contracts.ManifestV4, pathMan string) error
- type APICallTiming
- type Clients
- type Data
- type DeployCmd
- func (cmd *DeployCmd) Build(p *Project, oldPrefix, newPrefix string, msgs *[]string) error
- func (cmd *DeployCmd) BundlerInit(p *Project, newPrefix string, msgs *[]string) error
- func (cmd *DeployCmd) DryRun(f *cmdutil.Factory) error
- func (cmd *DeployCmd) EnsureBucket(ctx context.Context, client *storage.Client, p *Project, msgs *[]string, ...) error
- func (cmd *DeployCmd) ExternalRun(f *cmdutil.Factory, configPath string, env string, ...) error
- func (cmd *DeployCmd) ForV6() *DeployCmd
- func (cmd *DeployCmd) GenerateManifest(p *Project, msgs *[]string) error
- func (cmd *DeployCmd) GetOrCreateCredentials(ctx context.Context, bucketName string, profile string) (token.S3Credentials, error)
- func (cmd *DeployCmd) PurgeUrls(domain []string, path string) error
- func (cmd *DeployCmd) PurgeWildcard(domain []string, path string) error
- func (cmd *DeployCmd) Run(f *cmdutil.Factory) error
- func (cmd *DeployCmd) ShouldUpload(msgs *[]string) bool
- func (cmd *DeployCmd) UploadStatic(p *Project, msgs *[]string, dirs []contracts.StorageManifest, ...) error
- type DeployState
- type Project
- type Timer
- type TimingSummary
- type V4DeployPipeline
Constants ¶
const ManifestFile = ".edge/manifest.json"
ManifestFile is where the bundler writes the manifest the deploy applies.
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 ¶
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 ¶
HandleManifestTimingCallback handles timing callbacks from the manifest package
func IgnoreSkipsOnFirstRun ¶
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 NewCobraCmd ¶
func PurgeForUpdatedFiles ¶
func PurgeForUpdatedFiles(cmd *DeployCmd, workload apiworkload.WorkloadResponse, confPath string, msgs *[]string) (err error)
func ReadSettings ¶
ReadSettings reads the settings file for S3 credentials
func StorageClient ¶
StorageClient is the client EnsureBucket takes.
func TimeAPICall ¶
TimeAPICall is a helper function to time an API call and record it
func TimeAPICallWithResult ¶
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 ¶
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 ¶
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 (*DeployCmd) BundlerInit ¶
BundlerInit initialises the bundler on a first run and builds.
func (*DeployCmd) DryRun ¶
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 (*DeployCmd) ForV6 ¶
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 ¶
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) PurgeWildcard ¶
func (*DeployCmd) ShouldUpload ¶
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
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 ¶
func (V4DeployPipeline) Steps() []pipeline.Step[DeployState]