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

Update artifact file download #138

Merged
merged 1 commit into from
Nov 2, 2022
Merged
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
18 changes: 7 additions & 11 deletions kf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ func (b *BPF) GetArtifacts(conf *config.Config) error {

buf := &bytes.Buffer{}
isDefaultURLUsed := false
platform, err := GetPlatform()
if err != nil {
return fmt.Errorf("failed to identify platform type: %v", err)
}

RepoURL := b.Program.EPRURL
if len(b.Program.EPRURL) == 0 {
RepoURL = conf.EBPFRepoURL
Expand All @@ -548,17 +553,11 @@ func (b *BPF) GetArtifacts(conf *config.Config) error {
}
}

URL.Path = path.Join(URL.Path, b.Program.Name, b.Program.Version, platform, b.Program.Artifact)
log.Info().Msgf("Retrieving artifact - %s", URL)
switch URL.Scheme {
case httpsScheme, httpScheme:
{
platform, err := GetPlatform()
if err != nil {
return fmt.Errorf("failed to identify platform type: %v", err)
}

URL.Path = path.Join(URL.Path, b.Program.Name, b.Program.Version, platform, b.Program.Artifact)
log.Info().Msgf("Downloading - %s", URL)

timeOut := time.Duration(conf.HttpClientTimeout) * time.Second
var netTransport = &http.Transport{
ResponseHeaderTimeout: timeOut,
Expand All @@ -575,9 +574,7 @@ func (b *BPF) GetArtifacts(conf *config.Config) error {
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("get request returned unexpected status code: %d (%s), %d was expected\n\tResponse Body: %s", resp.StatusCode, http.StatusText(resp.StatusCode), http.StatusOK, buf.Bytes())
}

buf.ReadFrom(resp.Body)

}
case fileScheme:
{
Expand All @@ -586,7 +583,6 @@ func (b *BPF) GetArtifacts(conf *config.Config) error {
if err != nil {
return fmt.Errorf("opening err : %v", err)
}

buf.ReadFrom(f)
f.Close()
} else {
Expand Down