diff --git a/src/catalog/main.go b/src/catalog/main.go index 6ffbda6..7f037b6 100644 --- a/src/catalog/main.go +++ b/src/catalog/main.go @@ -123,6 +123,7 @@ func (s *CatalogManifestService) GenerateManifestContent(ctx basecontext.ApiCont } manifest.Size = fileInfo.Size() + manifest.PackSize = fileInfo.Size() ctx.LogInfof("Getting manifest package checksum for %v", r.CatalogId) checksum, err := helpers.GetFileMD5Checksum(packFilePath) diff --git a/src/catalog/models/pull_catalog_manifest.go b/src/catalog/models/pull_catalog_manifest.go index eac708b..7767aae 100644 --- a/src/catalog/models/pull_catalog_manifest.go +++ b/src/catalog/models/pull_catalog_manifest.go @@ -88,6 +88,7 @@ type PullCatalogManifestResponse struct { LocalPath string `json:"local_path,omitempty"` MachineName string `json:"machine_name,omitempty"` Manifest *VirtualMachineCatalogManifest `json:"manifest,omitempty"` + LocalCachePath string `json:"local_cache_path,omitempty"` CleanupRequest *cleanupservice.CleanupRequest `json:"-"` Errors []error `json:"-"` } diff --git a/src/catalog/models/push_catalog_manifest.go b/src/catalog/models/push_catalog_manifest.go index bcda9e8..f26c322 100644 --- a/src/catalog/models/push_catalog_manifest.go +++ b/src/catalog/models/push_catalog_manifest.go @@ -28,6 +28,7 @@ type PushCatalogManifestRequest struct { RequiredClaims []string `json:"required_claims,omitempty"` Tags []string `json:"tags,omitempty"` MinimumSpecRequirements MinimumSpecRequirement `json:"minimum_requirements,omitempty"` + PackSize int64 `json:"pack_size,omitempty"` ProgressChannel chan int `json:"-"` FileNameChannel chan string `json:"-"` StepChannel chan string `json:"-"` diff --git a/src/catalog/models/virtual_machine_manifest.go b/src/catalog/models/virtual_machine_manifest.go index 981238d..a879215 100644 --- a/src/catalog/models/virtual_machine_manifest.go +++ b/src/catalog/models/virtual_machine_manifest.go @@ -34,6 +34,7 @@ type VirtualMachineCatalogManifest struct { CompressedChecksum string `json:"compressed_checksum"` VirtualMachineContents []VirtualMachineManifestContentItem `json:"virtual_machine_contents"` PackContents []VirtualMachineManifestContentItem `json:"pack_contents"` + PackSize int64 `json:"pack_size,omitempty"` Tainted bool `json:"tainted"` TaintedBy string `json:"tainted_by"` TaintedAt string `json:"tainted_at"` diff --git a/src/catalog/pull.go b/src/catalog/pull.go index f64cc98..a26b775 100644 --- a/src/catalog/pull.go +++ b/src/catalog/pull.go @@ -324,6 +324,10 @@ func (s *CatalogManifestService) Pull(ctx basecontext.ApiContext, r *models.Pull } } + if cfg.IsCatalogCachingEnable() { + response.LocalCachePath = filepath.Join(destinationFolder, cacheMachineName) + } + systemSrv := serviceProvider.System if r.Owner != "" && r.Owner != "root" { if err := systemSrv.ChangeFileUserOwner(ctx, r.Owner, r.LocalMachineFolder); err != nil { diff --git a/src/data/models/catalog_manifest.go b/src/data/models/catalog_manifest.go index f3b8198..32b69d1 100644 --- a/src/data/models/catalog_manifest.go +++ b/src/data/models/catalog_manifest.go @@ -25,6 +25,7 @@ type CatalogManifest struct { DownloadCount int `json:"download_count"` VirtualMachineContents []CatalogManifestContentItem `json:"virtual_machine_contents"` PackContents []CatalogManifestContentItem `json:"pack_contents"` + PackSize int64 `json:"pack_size,omitempty"` MinimumSpecRequirements *MinimumSpecRequirement `json:"minimum_requirements,omitempty"` Tainted bool `json:"tainted"` TaintedBy string `json:"tainted_by"` diff --git a/src/mappers/catalog.go b/src/mappers/catalog.go index 01775bd..adbed6d 100644 --- a/src/mappers/catalog.go +++ b/src/mappers/catalog.go @@ -27,6 +27,7 @@ func CatalogManifestToDto(m catalog_models.VirtualMachineCatalogManifest) data_m LastDownloadedUser: m.LastDownloadedUser, VirtualMachineContents: CatalogManifestContentItemsToDto(m.VirtualMachineContents), PackContents: CatalogManifestContentItemsToDto(m.PackContents), + PackSize: m.PackSize, Size: m.Size, Tainted: m.Tainted, TaintedBy: m.TaintedBy, @@ -96,6 +97,7 @@ func DtoCatalogManifestToBase(m data_models.CatalogManifest) catalog_models.Virt Size: m.Size, VirtualMachineContents: DtoCatalogManifestContentItemsToBase(m.VirtualMachineContents), PackContents: DtoCatalogManifestContentItemsToBase(m.PackContents), + PackSize: m.PackSize, Tainted: m.Tainted, TaintedBy: m.TaintedBy, TaintedAt: m.TaintedAt, @@ -224,6 +226,7 @@ func ApiCatalogManifestToDto(m models.CatalogManifest) data_models.CatalogManife Revoked: m.Revoked, RevokedAt: m.RevokedAt, RevokedBy: m.RevokedBy, + PackSize: m.PackSize, DownloadCount: m.DownloadCount, } @@ -271,6 +274,7 @@ func DtoCatalogManifestToApi(m data_models.CatalogManifest) models.CatalogManife Revoked: m.Revoked, RevokedAt: m.RevokedAt, RevokedBy: m.RevokedBy, + PackSize: m.PackSize, DownloadCount: m.DownloadCount, } @@ -364,6 +368,7 @@ func ApiCatalogManifestToCatalogManifest(m models.CatalogManifest) catalog_model RevokedAt: m.RevokedAt, RevokedBy: m.RevokedBy, DownloadCount: m.DownloadCount, + PackSize: m.PackSize, } if m.Provider != nil { diff --git a/src/models/catalog.go b/src/models/catalog.go index 9beb1b1..2a87f57 100644 --- a/src/models/catalog.go +++ b/src/models/catalog.go @@ -29,6 +29,7 @@ type CatalogManifest struct { RevokedAt string `json:"revoked_at,omitempty" yaml:"revoked_at,omitempty"` RevokedBy string `json:"revoked_by,omitempty" yaml:"revoked_by,omitempty"` PackContents []CatalogManifestPackItem `json:"pack_contents,omitempty" yaml:"pack_contents,omitempty"` + PackSize int64 `json:"pack_size,omitempty" yaml:"pack_size,omitempty"` MinimumSpecRequirements *MinimumSpecRequirement `json:"minimum_requirements,omitempty" yaml:"minimum_requirements,omitempty"` } diff --git a/src/pdfile/models/pull_response.go b/src/pdfile/models/pull_response.go index 54f2f85..f50bf1f 100644 --- a/src/pdfile/models/pull_response.go +++ b/src/pdfile/models/pull_response.go @@ -1,10 +1,11 @@ package models type PullResponse struct { - MachineId string `json:"machine_id,omitempty" yaml:"machine_id,omitempty"` - MachineName string `json:"machine_name,omitempty" yaml:"machine_name,omitempty"` - CatalogId string `json:"catalog_id,omitempty" yaml:"catalog_id,omitempty"` - Version string `json:"version,omitempty" yaml:"version,omitempty"` - Architecture string `json:"architecture,omitempty" yaml:"architecture,omitempty"` - Type string `json:"type,omitempty" yaml:"type,omitempty"` + MachineId string `json:"machine_id,omitempty" yaml:"machine_id,omitempty"` + MachineName string `json:"machine_name,omitempty" yaml:"machine_name,omitempty"` + CatalogId string `json:"catalog_id,omitempty" yaml:"catalog_id,omitempty"` + Version string `json:"version,omitempty" yaml:"version,omitempty"` + Architecture string `json:"architecture,omitempty" yaml:"architecture,omitempty"` + LocalCachePath string `json:"local_cache_path,omitempty" yaml:"local_cache_path,omitempty"` + Type string `json:"type,omitempty" yaml:"type,omitempty"` } diff --git a/src/pdfile/pull.go b/src/pdfile/pull.go index 4ac13c9..c45c368 100644 --- a/src/pdfile/pull.go +++ b/src/pdfile/pull.go @@ -272,12 +272,13 @@ func (p *PDFileService) runPull(ctx basecontext.ApiContext) (interface{}, *diagn fmt.Printf("\rFinished pulling manifest\n") response := models.PullResponse{ - MachineId: resultManifest.ID, - MachineName: resultManifest.MachineName, - CatalogId: resultManifest.Manifest.CatalogId, - Version: resultManifest.Manifest.Version, - Architecture: resultManifest.Manifest.Architecture, - Type: resultManifest.Manifest.Type, + MachineId: resultManifest.ID, + MachineName: resultManifest.MachineName, + CatalogId: resultManifest.Manifest.CatalogId, + Version: resultManifest.Manifest.Version, + Architecture: resultManifest.Manifest.Architecture, + LocalCachePath: resultManifest.LocalCachePath, + Type: resultManifest.Manifest.Type, } if p.pdfile.Clone {