Allow optional hak releases
This commit is contained in:
@@ -44,15 +44,16 @@ type BuildManifestHAK struct {
|
||||
Priority int `json:"priority"`
|
||||
MaxBytes int64 `json:"max_bytes"`
|
||||
SizeBytes int64 `json:"size_bytes"`
|
||||
Optional bool `json:"optional,omitempty"`
|
||||
Assets []string `json:"assets"`
|
||||
ContentHash string `json:"content_hash,omitempty"`
|
||||
}
|
||||
|
||||
type assetResource struct {
|
||||
Rel string
|
||||
Resource erf.Resource
|
||||
Size int64
|
||||
ChangedAt time.Time
|
||||
Rel string
|
||||
Resource erf.Resource
|
||||
Size int64
|
||||
ChangedAt time.Time
|
||||
}
|
||||
|
||||
type hakChunk struct {
|
||||
@@ -476,10 +477,10 @@ func collectAssetResources(p *project.Project) ([]assetResource, error) {
|
||||
changedAt = info.ModTime()
|
||||
}
|
||||
hakResources = append(hakResources, assetResource{
|
||||
Rel: rel,
|
||||
Resource: resource,
|
||||
Size: erf.ArchiveSize([]erf.Resource{resource}),
|
||||
ChangedAt: changedAt,
|
||||
Rel: rel,
|
||||
Resource: resource,
|
||||
Size: erf.ArchiveSize([]erf.Resource{resource}),
|
||||
ChangedAt: changedAt,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -834,6 +835,7 @@ func buildManifestEntry(chunk hakChunk) BuildManifestHAK {
|
||||
Priority: chunk.Config.Priority,
|
||||
MaxBytes: chunk.Config.MaxBytes,
|
||||
SizeBytes: chunk.Size,
|
||||
Optional: chunk.Config.Optional,
|
||||
Assets: assets,
|
||||
ContentHash: chunkContentHash(chunk),
|
||||
}
|
||||
@@ -845,6 +847,7 @@ func chunkContentHash(chunk hakChunk) string {
|
||||
fmt.Fprintf(sum, "group:%s\n", chunk.Config.Name)
|
||||
fmt.Fprintf(sum, "priority:%d\n", chunk.Config.Priority)
|
||||
fmt.Fprintf(sum, "max_bytes:%d\n", chunk.Config.MaxBytes)
|
||||
fmt.Fprintf(sum, "optional:%t\n", chunk.Config.Optional)
|
||||
fmt.Fprintf(sum, "size_bytes:%d\n", chunk.Size)
|
||||
for _, asset := range chunk.Assets {
|
||||
fmt.Fprintf(sum, "asset:%s\n", asset.Rel)
|
||||
@@ -993,7 +996,12 @@ func resolveModuleHAKOrder(p *project.Project, chunks []hakChunk) ([]string, err
|
||||
}
|
||||
|
||||
byGroup := map[string][]string{}
|
||||
optionalNames := map[string]struct{}{}
|
||||
for _, chunk := range chunks {
|
||||
if chunk.Config.Optional {
|
||||
optionalNames[chunk.Name] = struct{}{}
|
||||
continue
|
||||
}
|
||||
byGroup[chunk.Config.Name] = append(byGroup[chunk.Config.Name], chunk.Name)
|
||||
}
|
||||
|
||||
@@ -1016,6 +1024,9 @@ func resolveModuleHAKOrder(p *project.Project, chunks []hakChunk) ([]string, err
|
||||
continue
|
||||
}
|
||||
|
||||
if _, optional := optionalNames[entry]; optional {
|
||||
continue
|
||||
}
|
||||
if _, exists := seen[entry]; exists {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user