/*
Copyright 2021 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kubecross

import "sigs.k8s.io/release-utils/http"

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
//counterfeiter:generate . impl
type impl interface {
	GetURLResponse(url string, trim bool) (string, error)
}

type defaultImpl struct{}

func (*defaultImpl) GetURLResponse(url string, trim bool) (string, error) {
	return http.GetURLResponse(url, trim)
}

/*
Copyright 2021 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kubecross

import (
	"bytes"

	"sigs.k8s.io/release-utils/http"
)

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
//counterfeiter:generate . impl
type impl interface {
	GetURLResponse(url string, trim bool) (string, error)
}

type defaultImpl struct{}

func (*defaultImpl) GetURLResponse(url string, trim bool) (string, error) {
	content, err := http.NewAgent().Get(url)
	if err != nil {
		return "", err
	}
	return string(bytes.TrimSpace(content)), nil
}

Use http agent for kubecross version retrieval
Use http agent for kubecross version retrieval

This agent allows retries and should be more future proof.

Signed-off-by: Sascha Grunert <70ab469ddb2ac3e35f32ed7c2fd1cca514b2e879@redhat.com>
