Merge pull request #764 from jim-minter/staticanalysis

fixes from staticcheck tool
This commit is contained in:
Angus Salkeld 2020-06-01 11:05:47 +10:00 коммит произвёл GitHub
Родитель c7a9440736 36e9affd74
Коммит 24289036c6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 22 добавлений и 31 удалений

Просмотреть файл

@ -45,6 +45,10 @@ func getTokenURLFromConsoleURL(consoleURL string) (*url.URL, error) {
func getAuthorizedToken(ctx context.Context, tokenURL *url.URL, username, password string) (string, error) {
req, err := http.NewRequestWithContext(ctx, "GET", tokenURL.String(), nil)
if err != nil {
return "", err
}
req.SetBasicAuth(username, password)
req.Header.Add("X-CSRF-Token", "1")

Просмотреть файл

@ -10,11 +10,6 @@ import (
// APIVersion contains a version string as it will be used by clients
const APIVersion = "admin"
const (
resourceProviderNamespace = "Microsoft.RedHatOpenShift"
resourceType = "openShiftClusters"
)
func init() {
api.APIs[APIVersion] = &api.Version{
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {

Просмотреть файл

@ -12,7 +12,6 @@ import (
"github.com/Azure/ARO-RP/pkg/api/validate"
"github.com/Azure/ARO-RP/pkg/database"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/util/acrtoken"
pkgacrtoken "github.com/Azure/ARO-RP/pkg/util/acrtoken"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/features"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/network"
@ -39,7 +38,7 @@ type Manager struct {
keyvault keyvault.Manager
privateendpoint privateendpoint.Manager
subnet subnet.Manager
acrtoken acrtoken.Manager
acrtoken pkgacrtoken.Manager
doc *api.OpenShiftClusterDocument
}

Просмотреть файл

@ -10,7 +10,6 @@ import (
"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/util/encryption"
encrypt "github.com/Azure/ARO-RP/pkg/util/encryption"
)
var _ codec.InterfaceExt = (*secureBytesExt)(nil)
@ -45,7 +44,7 @@ func (s secureBytesExt) UpdateExt(dest interface{}, v interface{}) {
var _ codec.InterfaceExt = (*secureStringExt)(nil)
type secureStringExt struct {
cipher encrypt.Cipher
cipher encryption.Cipher
}
func (s secureStringExt) ConvertExt(v interface{}) interface{} {

Просмотреть файл

@ -669,20 +669,20 @@ func (g *generator) vmss() *arm.Resource {
}
parts = append(parts,
fmt.Sprintf("'LOCATION=$(base64 -d <<<'''"),
fmt.Sprintf("base64(resourceGroup().location)"),
"'LOCATION=$(base64 -d <<<'''",
"base64(resourceGroup().location)",
"''')\n'",
)
parts = append(parts,
fmt.Sprintf("'SUBSCRIPTIONID=$(base64 -d <<<'''"),
fmt.Sprintf("base64(subscription().subscriptionId)"),
"'SUBSCRIPTIONID=$(base64 -d <<<'''",
"base64(subscription().subscriptionId)",
"''')\n'",
)
parts = append(parts,
fmt.Sprintf("'RESOURCEGROUPNAME=$(base64 -d <<<'''"),
fmt.Sprintf("base64(resourceGroup().name)"),
"'RESOURCEGROUPNAME=$(base64 -d <<<'''",
"base64(resourceGroup().name)",
"''')\n'",
)

Просмотреть файл

@ -67,7 +67,6 @@ func TestAdminListOpenShiftCluster(t *testing.T) {
type test struct {
name string
mocks func(*gomock.Controller, *mock_database.MockOpenShiftClusters, *mock_clusterdata.MockOpenShiftClusterEnricher, *mock_encryption.MockCipher)
skipToken string
wantStatusCode int
wantResponse []*admin.OpenShiftCluster
wantError string

Просмотреть файл

@ -8,7 +8,6 @@ import (
"testing"
operatorv1 "github.com/openshift/api/operator/v1"
v1 "github.com/openshift/api/operator/v1"
"github.com/openshift/client-go/operator/clientset/versioned/fake"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -21,16 +20,16 @@ func TestUpdateConsoleBranding(t *testing.T) {
i := &Installer{
log: logrus.NewEntry(logrus.StandardLogger()),
operatorcli: fake.NewSimpleClientset(&v1.Console{
operatorcli: fake.NewSimpleClientset(&operatorv1.Console{
ObjectMeta: metav1.ObjectMeta{
Name: consoleName,
},
Status: v1.ConsoleStatus{
OperatorStatus: v1.OperatorStatus{
Conditions: []v1.OperatorCondition{
Status: operatorv1.ConsoleStatus{
OperatorStatus: operatorv1.OperatorStatus{
Conditions: []operatorv1.OperatorCondition{
{
Type: "DeploymentAvailable",
Status: v1.ConditionTrue,
Status: operatorv1.ConditionTrue,
},
},
},

Просмотреть файл

@ -12,11 +12,6 @@ import (
"github.com/Azure/ARO-RP/pkg/metrics"
)
type metric struct {
t time.Time
name string
}
var _ k8smetrics.LatencyMetric = (*tracer)(nil)
var _ k8smetrics.ResultMetric = (*tracer)(nil)

Просмотреть файл

@ -55,9 +55,6 @@ func NewManager(_env env.Interface, billing database.Billing, sub database.Subsc
}
e2estorage := storage.NewAccountsClient(_env.E2EStorageAccountSubID(), localFPAuthorizer)
if err != nil {
return nil, err
}
keys, err := e2estorage.ListKeys(context.Background(), _env.E2EStorageAccountRGName(), _env.E2EStorageAccountName(), "")
if err != nil {

Просмотреть файл

@ -67,8 +67,12 @@ func (ef *workerProfilesEnricherTask) FetchData(callbacks chan<- func(), errs ch
return
}
workerProfiles := make([]api.WorkerProfile, len(machinesets.Items), len(machinesets.Items))
workerProfiles := make([]api.WorkerProfile, len(machinesets.Items))
for i, machineset := range machinesets.Items {
if machineset.Spec.Template.Spec.ProviderSpec.Value == nil {
continue
}
o, _, err := codecs.UniversalDeserializer().Decode(machineset.Spec.Template.Spec.ProviderSpec.Value.Raw, nil, nil)
if err != nil {
ef.log.Error(err)