-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[content-service] add prestop hook to extract git status #9807
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -465,15 +465,27 @@ func contentDescriptorToLayer(cdesc []byte) (*Layer, error) { | |
) | ||
} | ||
|
||
var prestophookScript = `#!/bin/bash | ||
cd ${GITPOD_REPO_ROOT} | ||
git config --global --add safe.directory ${GITPOD_REPO_ROOT} | ||
git status --porcelain=v2 --branch -uall > /.workspace/prestophookdata/git_status.txt | ||
git log --pretty='%h: %s' --branches --not --remotes > /.workspace/prestophookdata/git_log_1.txt | ||
git log --pretty=%H -n 1 > /.workspace/prestophookdata/git_log_2.txt | ||
` | ||
|
||
// version of this function for persistent volume claim feature | ||
// we cannot use /workspace folder as when mounting /workspace folder through PVC | ||
// it will mask anything that was in container layer, hence we are using /.workspace instead here | ||
func contentDescriptorToLayerPVC(cdesc []byte) (*Layer, error) { | ||
return layerFromContent( | ||
fileInLayer{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
fileInLayer{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace/.gitpod", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
fileInLayer{&tar.Header{Typeflag: tar.TypeReg, Name: "/.workspace/.gitpod/content.json", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755, Size: int64(len(cdesc))}, cdesc}, | ||
) | ||
layers := []fileInLayer{ | ||
{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace/.gitpod", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil}, | ||
{&tar.Header{Typeflag: tar.TypeReg, Name: "/.supervisor/prestophook.sh", Uid: 0, Gid: 0, Mode: 0775, Size: int64(len(prestophookScript))}, []byte(prestophookScript)}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please explain why we are setting Uid and Gid to 0 but then permission to 0775? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uid/Gid to 0 to make sure no one else can edit\modify this file from inside the workspace (otherwise you can execute things from ring1). |
||
} | ||
if len(cdesc) > 0 { | ||
layers = append(layers, fileInLayer{&tar.Header{Typeflag: tar.TypeReg, Name: "/.workspace/.gitpod/content.json", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755, Size: int64(len(cdesc))}, cdesc}) | ||
} | ||
return layerFromContent(layers...) | ||
} | ||
|
||
func workspaceReadyLayer(src csapi.WorkspaceInitSource) (*Layer, error) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.