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

Push command #256

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Push command #256

wants to merge 23 commits into from

Conversation

dominik-przybyl-wttech
Copy link
Contributor

No description provided.

opts.PID = fmt.Sprintf("aemc:content-download:%s-SNAPSHOT", timex.FileTimestampForNow())
func (cm *ContentManager) Download(localFile string, packageOpts PackageCreateOpts) error {
if packageOpts.PID == "" {
packageOpts.PID = fmt.Sprintf("aemc:content-pull:%s-SNAPSHOT", timex.FileTimestampForNow())
Copy link
Contributor

Choose a reason for hiding this comment

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

method has a 'download' in its name so package name was accurate; if this should be dynamic then maybe put something (pkg kind or sth) inside PackageCreateOpts

@@ -204,6 +204,35 @@ func (pm *PackageManager) Create(opts PackageCreateOpts) (string, error) {
return "", err
}
}
if opts.PushContent {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm this is rather internal indicator right?

@@ -268,6 +293,9 @@ func (pm *PackageManager) Copy(remotePath string, destInstance *Instance) error
}

func (pm *PackageManager) tmpDir() string {
if !pm.instance.manager.aem.config.TemplateFileExists() {
Copy link
Contributor

Choose a reason for hiding this comment

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

give this expression a name config.TemplateFileExists()

func (a *AEM) Detached() bool {
	return !a.config.TemplateFileExists()
}

"path/filepath"
)

func Archive(sourcePath, targetFile string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

zipper should Zip() :) use single naming consequently; update errors/log messages accordingly

"path/filepath"
"regexp"
"strings"
)

const (
NamespacePattern = "^_([a-z]+)_"
NamespacePattern = "_([a-z]+)_"
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you changing it again and again? :)

@@ -36,14 +37,17 @@ func (cm *ContentManager) pkgMgr() *PackageManager {
}

func (cm *ContentManager) tmpDir() string {
if cm.instance.manager.aem.Detached() {
return os.TempDir()
Copy link
Contributor

Choose a reason for hiding this comment

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

<3

@@ -0,0 +1,133 @@
package content
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be nice to explain why extra zipper/archiver is needed here and why mholt cannot be used here.

return nil
}

func compress(src string, dest string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

zip?

return err
}

func extract(src string, dest string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

unzip?

@@ -204,7 +200,29 @@ func (pm *PackageManager) Create(opts PackageCreateOpts) (string, error) {
return "", err
}
}
if err = filex.Archive(tmpDir, tmpFile); err != nil {
if opts.ContentPath != "" {
contentPath := opts.ContentPath
Copy link
Contributor

Choose a reason for hiding this comment

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

203-224 block should be an extracted method with the name explaining what is done here

if err != nil {
return nil, err
}
if fileStat.Size() > bufio.MaxScanTokenSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

wth ?:D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

buffer size of the scanner is 64 KB, if file is larger than 64K, you can set larger buffer with scanner.Buffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants