Skip to content

Commit 16839e8

Browse files
committed
third party config support
# Conflicts: # internal/config/config.go # internal/config/types.go # internal/file/file_manager_service.go
1 parent 0171367 commit 16839e8

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

internal/file/file_manager_service.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,12 @@ func (fms *FileManagerService) DetermineFileActions(
410410
// If it's external, we DON'T care about disk state or hashes here.
411411
// We tag it as ExternalFile and let the downloader handle the rest.
412412
if modifiedFile.File.GetExternalDataSource() != nil || (ok && currentFile.GetExternalDataSource() != nil) {
413-
slog.DebugContext(ctx, "External file URI detected - flagging for fetch", "file_name", fileName)
413+
slog.DebugContext(ctx, "External file detected - flagging for fetch", "file_name", fileName)
414414
modifiedFile.Action = model.ExternalFile
415415
fileDiff[fileName] = modifiedFile
416416
continue
417417
}
418-
418+
419419
// If file currently exists on disk, is being tracked in manifest and file hash is different.
420420
// Treat it as a file update.
421421
if ok && modifiedFile.File.GetFileMeta().GetHash() != currentFile.GetFileMeta().GetHash() {
@@ -468,7 +468,6 @@ func (fms *FileManagerService) DetermineFileActions(
468468
return fileDiff, nil
469469
}
470470

471-
472471
// UpdateCurrentFilesOnDisk updates the FileManagerService currentFilesOnDisk slice which contains the files
473472
// currently on disk
474473
func (fms *FileManagerService) UpdateCurrentFilesOnDisk(

internal/file/file_service_operator.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,23 @@ func (fso *FileServiceOperator) UpdateFile(
285285
return fso.sendUpdateFileStream(ctx, fileToUpdate, fso.agentConfig.Client.Grpc.FileChunkSize)
286286
}
287287

288+
func (fso *FileServiceOperator) RenameExternalFile(
289+
ctx context.Context, source, desination string,
290+
) error {
291+
slog.DebugContext(ctx, fmt.Sprintf("Moving file %s to %s (no hash validation)", source, desination))
292+
293+
if err := os.MkdirAll(filepath.Dir(desination), dirPerm); err != nil {
294+
return fmt.Errorf("failed to create directories for %s: %w", desination, err)
295+
}
296+
297+
moveErr := os.Rename(source, desination)
298+
if moveErr != nil {
299+
return fmt.Errorf("failed to move file: %w", moveErr)
300+
}
301+
302+
return nil
303+
}
304+
288305
// renameFile, renames (moves) file from tempDir to new location to update file.
289306
func (fso *FileServiceOperator) RenameFile(
290307
ctx context.Context, source, desination string,

internal/model/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ type ManifestFileMeta struct {
5252
Referenced bool `json:"referenced"`
5353
// File is not managed by the agent
5454
Unmanaged bool `json:"unmanaged"`
55+
// ETag of the 3rd Party external file
56+
ETag string `json:"etag"`
57+
// Last modified time of the 3rd Party external file
58+
LastModified string `json:"last_modified"`
5559
}
5660
type ConfigApplyMessage struct {
5761
Error error

0 commit comments

Comments
 (0)