-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into becca/tuf-rollout-internal
- Loading branch information
Showing
31 changed files
with
2,373 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
"time" | ||
|
||
"github.com/kolide/kit/fsutil" | ||
"github.com/kolide/launcher/pkg/packaging" | ||
) | ||
|
||
// runDownloadOsquery downloads the stable osquery to the provided path. It's meant for use in out CI pipeline. | ||
func runDownloadOsquery(args []string) error { | ||
fs := flag.NewFlagSet("launcher download-osquery", flag.ExitOnError) | ||
|
||
var ( | ||
flChannel = fs.String("channel", "stable", "What channel to download from") | ||
flDir = fs.String("directory", ".", "Where to download osquery to") | ||
) | ||
|
||
if err := fs.Parse(args); err != nil { | ||
return err | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*2) | ||
defer cancel() | ||
|
||
target := packaging.Target{} | ||
if err := target.PlatformFromString(runtime.GOOS); err != nil { | ||
return fmt.Errorf("error parsing platform: %w, %s", err, runtime.GOOS) | ||
} | ||
|
||
// We're reusing packaging code, which is based around having a persistent cache directory. It's not quite what | ||
// we want but it'll do | ||
cacheDir, err := os.MkdirTemp("", "osquery-download") | ||
if err != nil { | ||
return fmt.Errorf("creating temp cache dir: %w", err) | ||
} | ||
defer os.RemoveAll(cacheDir) | ||
|
||
dlpath, err := packaging.FetchBinary(ctx, cacheDir, "osqueryd", target.PlatformBinaryName("osqueryd"), *flChannel, target) | ||
if err != nil { | ||
return fmt.Errorf("error fetching binary osqueryd binary: %w", err) | ||
} | ||
|
||
outfile := filepath.Join(*flDir, filepath.Base(dlpath)) | ||
if err := fsutil.CopyFile(dlpath, outfile); err != nil { | ||
return fmt.Errorf("error copying binary osqueryd binary: %w", err) | ||
} | ||
|
||
fmt.Printf("Downloaded to: %s\n", outfile) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.