Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APP-2115 - cloud_package_manager improvements #2663

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ func getAgentInfo() (*apppb.AgentInfo, error) {
if err != nil {
return nil, err
}
platform := fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)

return &apppb.AgentInfo{
Host: hostname,
Ips: ips,
Os: runtime.GOOS,
Version: Version,
GitRevision: GitRevision,
Platform: &platform,
Comment on lines 44 to +50
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rdk does not have tests for AgentInfo.

Happy to add some if others think it is worthwhile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please add a ticket in our project epic. Doesn't have to be in this PR, unless you feel you can take it on now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}, nil
}

Expand Down
9 changes: 8 additions & 1 deletion robot/packages/cloud_package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,15 @@ func (m *cloudManager) unpackFile(ctx context.Context, fromFile, toDir string) e
}

case tar.TypeReg:
// This is required because it is possible create tarballs without a directory entry
// but whose files names start with a new directory prefix
// Ex: tar -czf package.tar.gz ./bin/module.exe
parent := filepath.Dir(path)
if err := os.MkdirAll(parent, info.Mode()); err != nil {
return errors.Wrapf(err, "failed to create directory %q", parent)
}
//nolint:gosec // path sanitized with safeJoin
outFile, err := os.Create(path)
outFile, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, info.Mode().Perm())
if err != nil {
return errors.Wrapf(err, "failed to create file %s", path)
}
Expand Down
14 changes: 8 additions & 6 deletions robot/packages/testutils/fake_package_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,16 @@ func ValidateContentsOfPPackage(t *testing.T, dir string) {
isLink bool
linkTarget string
isDir bool
perms os.FileMode
}

expected := []content{
{path: "some-link.txt", isLink: true, linkTarget: "sub-dir/sub-file.txt"},
{path: "some-text.txt", checksum: "p/E54w=="},
{path: "some-text2.txt", checksum: "p/E54w=="},
{path: "sub-dir", isDir: true},
{path: "sub-dir/sub-file.txt", checksum: "p/E54w=="},
{path: "sub-dir-link", isLink: true, linkTarget: "sub-dir"},
{path: "some-link.txt", isLink: true, linkTarget: "sub-dir/sub-file.txt", perms: 0o777},
{path: "some-text.txt", checksum: "p/E54w==", perms: 0o644},
{path: "some-text2.txt", checksum: "p/E54w==", perms: 0o644},
{path: "sub-dir", isDir: true, perms: 0o755},
{path: "sub-dir/sub-file.txt", checksum: "p/E54w==", perms: 0o644},
{path: "sub-dir-link", isLink: true, linkTarget: "sub-dir", perms: 0o777},
}

out := make([]content, 0, len(expected))
Expand Down Expand Up @@ -371,6 +372,7 @@ func ValidateContentsOfPPackage(t *testing.T, dir string) {
isDir: info.IsDir(),
isLink: isSymLink,
linkTarget: symTarget,
perms: info.Mode().Perm(),
})

return nil
Expand Down