Skip to content

Commit

Permalink
Fix update preparation & lint issues (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
adracus authored Aug 23, 2022
1 parent 6a09b84 commit 6d1774d
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'
go-version: '1.19'
- name: Run make generate
run: make generate
- name: Compare the expected and actual generated/* directories
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'
go-version: '1.19'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.43.0
version: v1.48.0
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Pull Request Code test

on:
pull_request_target:
pull_request:
types: [ assigned, opened, synchronize, reopened ]
paths-ignore:
- 'docs/**'
Expand All @@ -13,9 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-go@v3
with:
go-version: '1.17'
go-version: '1.19'
- run: make test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.18 as builder
FROM --platform=$BUILDPLATFORM golang:1.19 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
19 changes: 11 additions & 8 deletions apis/common/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type LocalUIDReference struct {
}

// IP is an IP address.
//+kubebuilder:validation:Type=string
// +kubebuilder:validation:Type=string
type IP struct {
netaddr.IP `json:"-"`
}
Expand Down Expand Up @@ -254,8 +254,8 @@ func EqualIPRanges(a, b IPRange) bool {
}

// IPPrefix represents a network prefix.
//+kubebuilder:validation:Type=string
//+nullable
// +kubebuilder:validation:Type=string
// +nullable
type IPPrefix struct {
netaddr.IPPrefix `json:"-"`
}
Expand Down Expand Up @@ -375,7 +375,7 @@ type Taint struct {
Effect TaintEffect `json:"effect"`
}

//+kubebuilder:validation:Enum=NoSchedule
// +kubebuilder:validation:Enum=NoSchedule
type TaintEffect string

const (
Expand Down Expand Up @@ -408,11 +408,14 @@ type Toleration struct {
// ToleratesTaint checks if the toleration tolerates the taint.
// The matching follows the rules below:
// (1) Empty toleration.effect means to match all taint effects,
// otherwise taint effect must equal to toleration.effect.
//
// otherwise taint effect must equal to toleration.effect.
//
// (2) If toleration.operator is 'Exists', it means to match all taint values.
// (3) Empty toleration.key means to match all taint keys.
// If toleration.key is empty, toleration.operator must be 'Exists';
// this combination means to match all taint values and all taint keys.
//
// If toleration.key is empty, toleration.operator must be 'Exists';
// this combination means to match all taint values and all taint keys.
func (t *Toleration) ToleratesTaint(taint *Taint) bool {
if len(t.Effect) > 0 && t.Effect != taint.Effect {
return false
Expand All @@ -433,7 +436,7 @@ func (t *Toleration) ToleratesTaint(taint *Taint) bool {
}

// A toleration operator is the set of operators that can be used in a toleration.
//+kubebuilder:validation:Enum=Equal;Exists
// +kubebuilder:validation:Enum=Equal;Exists
type TolerationOperator string

const (
Expand Down
2 changes: 1 addition & 1 deletion apis/compute/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ type MachineStatus struct {
}

// MachineState is the state of a machine.
//+enum
// +enum
type MachineState string

const (
Expand Down
2 changes: 1 addition & 1 deletion apis/compute/machinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type MachinePoolCondition struct {
}

// MachinePoolState is a state a MachinePool can be in.
//+enum
// +enum
type MachinePoolState string

const (
Expand Down
4 changes: 2 additions & 2 deletions apis/compute/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package compute contains API Schema definitions for the compute internal API group
//+kubebuilder:object:generate=true
//+groupName=compute.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=compute.api.onmetal.de
package compute

import (
Expand Down
2 changes: 1 addition & 1 deletion apis/compute/v1alpha1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ type MachineStatus struct {
}

// MachineState is the state of a machine.
//+enum
// +enum
type MachineState string

const (
Expand Down
2 changes: 1 addition & 1 deletion apis/compute/v1alpha1/machinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type MachinePoolCondition struct {
}

// MachinePoolState is a state a MachinePool can be in.
//+enum
// +enum
type MachinePoolState string

const (
Expand Down
4 changes: 2 additions & 2 deletions apis/compute/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package v1alpha1 contains API Schema definitions for the compute v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=compute.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=compute.api.onmetal.de
package v1alpha1

import (
Expand Down
4 changes: 2 additions & 2 deletions apis/ipam/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package ipam contains API Schema definitions for the ipam internal API group
//+kubebuilder:object:generate=true
//+groupName=ipam.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=ipam.api.onmetal.de
package ipam

import (
Expand Down
4 changes: 2 additions & 2 deletions apis/ipam/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package v1alpha1 contains API Schema definitions for the network v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=ipam.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=ipam.api.onmetal.de
package v1alpha1

import (
Expand Down
4 changes: 2 additions & 2 deletions apis/networking/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package networking contains API Schema definitions for the networking internal API group
//+kubebuilder:object:generate=true
//+groupName=networking.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=networking.api.onmetal.de
package networking

import (
Expand Down
4 changes: 2 additions & 2 deletions apis/networking/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package v1alpha1 contains API Schema definitions for the networking v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=networking.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=networking.api.onmetal.de
package v1alpha1

import (
Expand Down
4 changes: 2 additions & 2 deletions apis/storage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package storage contains API Schema definitions for the storage internal API group
//+kubebuilder:object:generate=true
//+groupName=storage.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=storage.api.onmetal.de
package storage

import (
Expand Down
4 changes: 2 additions & 2 deletions apis/storage/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

// Package v1alpha1 contains API Schema definitions for the storage v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=storage.api.onmetal.de
// +kubebuilder:object:generate=true
// +groupName=storage.api.onmetal.de
package v1alpha1

import (
Expand Down
10 changes: 5 additions & 5 deletions controllers/ipam/prefix_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ func (r *PrefixReconciler) allocateSubPrefix(ctx context.Context, log logr.Logge

// adjustedAllocationPhase calculates an adjusted phase of a PrefixAllocation.
// For the adjusted phase, it is considered
// * If the allocation is in a terminal phase, that state is returned.
// * If the allocation is not scheduled, that state is returned.
// * If the allocation is scheduled but no lastTransitionTime has been recorded, that state is returned
// * If the allocation is in a non-terminal state, and it has been scheduled, once a configurable timeout has passed,
// it is considered to be failed.
// - If the allocation is in a terminal phase, that state is returned.
// - If the allocation is not scheduled, that state is returned.
// - If the allocation is scheduled but no lastTransitionTime has been recorded, that state is returned
// - If the allocation is in a non-terminal state, and it has been scheduled, once a configurable timeout has passed,
// it is considered to be failed.
func (r *PrefixReconciler) adjustedAllocationPhase(allocation *ipamv1alpha1.PrefixAllocation) ipamv1alpha1.PrefixAllocationPhase {
allocationPhase := allocation.Status.Phase
if allocationPhase.IsTerminal() || allocation.Spec.PrefixRef == nil {
Expand Down
2 changes: 1 addition & 1 deletion docs/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Requirements

* `go` >= 1.17
* `go` >= 1.19
* `git`, `make` and `kubectl`
* [Kustomize](https://kustomize.io/)
* Access to a Kubernetes cluster ([Minikube](https://minikube.sigs.k8s.io/docs/), [kind](https://kind.sigs.k8s.io/) or a
Expand Down
17 changes: 14 additions & 3 deletions envtestutils/apiservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"bufio"
"bytes"
"io"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -79,8 +78,20 @@ func renderAPIServices(options *APIServiceInstallOptions) ([]*apiregistrationv1.

if !info.IsDir() {
filePath, files = filepath.Dir(path), []os.FileInfo{info}
} else if files, err = ioutil.ReadDir(path); err != nil {
return nil, err
} else {
entries, err := os.ReadDir(path)
if err != nil {
return nil, err
}

for _, entry := range entries {
file, err := entry.Info()
if err != nil {
return nil, err
}

files = append(files, file)
}
}

log.V(1).Info("reading APIServices from path", "path", path)
Expand Down
17 changes: 8 additions & 9 deletions envtestutils/envtestutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package envtestutils
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -106,7 +105,7 @@ func (o *APIServiceInstallOptions) setupCA() error {
return fmt.Errorf("unable to set up api service serving certs: %v", err)
}

localServingCertsDir, err := ioutil.TempDir("", "envtest-apiservice-certs-")
localServingCertsDir, err := os.MkdirTemp("", "envtest-apiservice-certs-")
o.LocalServingCertDir = localServingCertsDir
if err != nil {
return fmt.Errorf("unable to create directory for apiservice serving certs: %v", err)
Expand All @@ -117,13 +116,13 @@ func (o *APIServiceInstallOptions) setupCA() error {
return fmt.Errorf("unable to marshal api service serving certs: %v", err)
}

if err := ioutil.WriteFile(o.caCertPath(), apiServiceCA.CA.CertBytes(), 0640); err != nil {
if err := os.WriteFile(o.caCertPath(), apiServiceCA.CA.CertBytes(), 0640); err != nil {
return fmt.Errorf("unable to write api service ca to disk: %w", err)
}
if err := ioutil.WriteFile(o.tlsCertPath(), certData, 0640); err != nil {
if err := os.WriteFile(o.tlsCertPath(), certData, 0640); err != nil {
return fmt.Errorf("unable to write api service serving cert to disk: %w", err)
}
if err := ioutil.WriteFile(o.tlsKeyPath(), keyData, 0640); err != nil {
if err := os.WriteFile(o.tlsKeyPath(), keyData, 0640); err != nil {
return fmt.Errorf("unable to write api service serving key to disk: %w", err)
}

Expand Down Expand Up @@ -232,7 +231,7 @@ func (o *APIServiceInstallOptions) SetupClientCA() error {
return fmt.Errorf("unable to set up apiserver client serving certs: %v", err)
}

clientCertDir, err := ioutil.TempDir("", "envtest-apiserver-client-certs-")
clientCertDir, err := os.MkdirTemp("", "envtest-apiserver-client-certs-")
o.ClientCertDir = clientCertDir
if err != nil {
return fmt.Errorf("unable to create directory for apiserver client certs: %v", err)
Expand All @@ -243,13 +242,13 @@ func (o *APIServiceInstallOptions) SetupClientCA() error {
return fmt.Errorf("unable to marshal apiserver client certs: %v", err)
}

if err := ioutil.WriteFile(o.clientCACertPath(), clientCA.CA.CertBytes(), 0640); err != nil {
if err := os.WriteFile(o.clientCACertPath(), clientCA.CA.CertBytes(), 0640); err != nil {
return fmt.Errorf("unable to write apiserver client ca to disk: %w", err)
}
if err := ioutil.WriteFile(o.clientCertPath(), certData, 0640); err != nil {
if err := os.WriteFile(o.clientCertPath(), certData, 0640); err != nil {
return fmt.Errorf("unable to write apiserver client cert to disk: %w", err)
}
if err := ioutil.WriteFile(o.clientKeyPath(), keyData, 0640); err != nil {
if err := os.WriteFile(o.clientKeyPath(), keyData, 0640); err != nil {
return fmt.Errorf("unable to write apiserver client key to disk: %w", err)
}

Expand Down
14 changes: 7 additions & 7 deletions generated/clientset/internalversion/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions generated/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6d1774d

Please sign in to comment.