// Extract will extract the contents of the job archive to destination // It creates a directory with the name of the job // Returns the full path of the extracted archive func (j *Job) Extract(destination string) (string, error) { targetDir := filepath.Join(destination, j.Name) if err := os.MkdirAll(targetDir, 0755); err != nil { return "", err } if err := extractor.NewTgz().Extract(j.Path, targetDir); err != nil { return "", err } return targetDir, nil }
func (g *Github) DownloadAndExtractRelease(owner, repo, name, tag string) (*string, error) { filename, err := g.downloadRelease(owner, repo, name, tag) if err != nil { return nil, err } if filename == nil { return nil, errors.New("Filename came back nil. This is a bug.") } outdir := path.Join(os.TempDir(), name) log.Println("extracting asset") err = extractor.NewTgz().Extract(*filename, outdir) if err != nil { return nil, err } return &outdir, nil }