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

Enable godot #739

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ linters:
- gochecksumtype
# - goconst - TODO(ben): Consider moving consts into separate package
- gocritic
- godot


# TODO(ben): Enable those linters step by step and fix existing issues.
# - gocyclo
# - godot
# - godox
# - gofmt
# - gofumpt
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/client/dqlite/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var nextDqlitePort = 37312
// })
// }
//
// ```
// ```.
func withDqliteCluster(t *testing.T, size int, f func(ctx context.Context, dirs []string)) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/client/helm/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ type MockApplyArguments struct {
Values map[string]any
}

// Mock is a mock implementation of helm.Client
// Mock is a mock implementation of helm.Client.
type Mock struct {
ApplyCalledWith []MockApplyArguments
ApplyChanged bool
ApplyErr error
}

// Apply implements helm.Client
// Apply implements helm.Client.
func (m *Mock) Apply(ctx context.Context, c helm.InstallableChart, desired helm.State, values map[string]any) (bool, error) {
m.ApplyCalledWith = append(m.ApplyCalledWith, MockApplyArguments{Context: ctx, Chart: c, State: desired, Values: values})
return m.ApplyChanged, m.ApplyErr
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/client/kubernetes/server_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ListResourcesForGroupVersion lists the resources for a given group version (e.g. "cilium.io/v2alpha1")
// ListResourcesForGroupVersion lists the resources for a given group version (e.g. "cilium.io/v2alpha1").
func (c *Client) ListResourcesForGroupVersion(groupVersion string) (*v1.APIResourceList, error) {
resources, err := c.Discovery().ServerResourcesForGroupVersion(groupVersion)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/certificates_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func refreshCertsRunControlPlane(s state.State, r *http.Request, snap snap.Snap)

}

// refreshCertsRunWorker refreshes the certificates for a worker node
// refreshCertsRunWorker refreshes the certificates for a worker node.
func refreshCertsRunWorker(s state.State, r *http.Request, snap snap.Snap) response.Response {
log := log.FromContext(r.Context())

Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/api/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
)

const (
// StatusNodeUnavailable is the Http status code that the API returns if the node isn't in the cluster
// StatusNodeUnavailable is the Http status code that the API returns if the node isn't in the cluster.
StatusNodeUnavailable = 520
// StatusNodeInUse is the Http status code that the API returns if the node is already in the cluster
// StatusNodeInUse is the Http status code that the API returns if the node is already in the cluster.
StatusNodeInUse = 521
)

Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (a *App) Run(ctx context.Context, customHooks *state.Hooks) error {
// markNodeReady will decrement the readyWg counter to signal that the node is ready.
// The node is ready if:
// - the microcluster database is accessible
// - the kubernetes endpoint is reachable
// - the kubernetes endpoint is reachable.
func (a *App) markNodeReady(ctx context.Context, s state.State) error {
log := log.FromContext(ctx).WithValues("startup", "waitForReady")

Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/app/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ func (a *App) NotifyFeatureController(network, gateway, ingress, loadBalancer, l
}
}

// Ensure App implements api.Provider
// Ensure App implements api.Provider.
var _ api.Provider = &App{}
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/controllers/control_plane_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ControlPlaneConfigurationController struct {
}

// NewControlPlaneConfigurationController creates a new controller.
// triggerCh is typically a `time.NewTicker(<duration>).C`
// triggerCh is typically a `time.NewTicker(<duration>).C`.
func NewControlPlaneConfigurationController(snap snap.Snap, waitReady func(), triggerCh <-chan time.Time) *ControlPlaneConfigurationController {
return &ControlPlaneConfigurationController{
snap: snap,
Expand All @@ -35,7 +35,7 @@ func NewControlPlaneConfigurationController(snap snap.Snap, waitReady func(), tr
// Run starts the controller.
// Run accepts a context to manage the lifecycle of the controller.
// Run accepts a function that retrieves the current cluster configuration.
// Run will loop every time the trigger channel is
// Run will loop every time the trigger channel is.
func (c *ControlPlaneConfigurationController) Run(ctx context.Context, getClusterConfig func(context.Context) (types.ClusterConfig, error)) {
c.waitReady()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
. "github.com/onsi/gomega"
)

// channelSendTimeout is the timeout for pushing to channels for TestControlPlaneConfigController
// channelSendTimeout is the timeout for pushing to channels for TestControlPlaneConfigController.
const channelSendTimeout = 100 * time.Millisecond

type configProvider struct {
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/controllers/csrsigning/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package csrsigning
import "time"

const (
// requeueAfterSigningFailure is the time to requeue requests when any step of the signing process failed
// requeueAfterSigningFailure is the time to requeue requests when any step of the signing process failed.
requeueAfterSigningFailure = 3 * time.Second

// requeueAfterWaitingForApproved is the amount of time to requeue requests if waiting for CSR to be approved
// requeueAfterWaitingForApproved is the amount of time to requeue requests if waiting for CSR to be approved.
requeueAfterWaitingForApproved = 10 * time.Second
)
6 changes: 3 additions & 3 deletions src/k8s/pkg/k8sd/database/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
)

const (
// microclusterDatabaseInitTimeout is the timeout for microcluster database initialization operations
// microclusterDatabaseInitTimeout is the timeout for microcluster database initialization operations.
microclusterDatabaseInitTimeout = 3 * time.Second
// microclusterDatabaseShutdownTimeout is the timeout for microcluster database shutdown operations
// microclusterDatabaseShutdownTimeout is the timeout for microcluster database shutdown operations.
microclusterDatabaseShutdownTimeout = 3 * time.Second
)

var (
// nextIdx is used to pick different listen ports for each microcluster instance
// nextIdx is used to pick different listen ports for each microcluster instance.
nextIdx int
)

Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/k8sd/features/cilium/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

const (
// minVLANIDValue is the minimum valid 802.1Q VLAN ID value
// minVLANIDValue is the minimum valid 802.1Q VLAN ID value.
minVLANIDValue = 0
// maxVLANIDValue is the maximum valid 802.1Q VLAN ID value
// maxVLANIDValue is the maximum valid 802.1Q VLAN ID value.
maxVLANIDValue = 4094
)

Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/features/cilium/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
networkDeployFailedMsgTmpl = "Failed to deploy Cilium Network, the error was: %v"
)

// required for unittests
// required for unittests.
var (
getMountPath = utils.GetMountPath
getMountPropagationType = utils.GetMountPropagationType
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/features/contour/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func ApplyGateway(ctx context.Context, snap snap.Snap, gateway types.Gateway, ne
}

// waitForRequiredContourCommonCRDs waits for the required contour CRDs to be available
// by checking the API resources by group version
// by checking the API resources by group version.
func waitForRequiredContourCommonCRDs(ctx context.Context, snap snap.Snap) error {
client, err := snap.KubernetesClient("")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/features/contour/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
// deployment.
// ApplyIngress returns an error if anything fails. The error is also wrapped in the .Message field of the
// returned FeatureStatus.
// Contour CRDS are applied through a ck-contour common chart (Overlap with gateway)
// Contour CRDS are applied through a ck-contour common chart (Overlap with gateway).
func ApplyIngress(ctx context.Context, snap snap.Snap, ingress types.Ingress, _ types.Network, _ types.Annotations) (types.FeatureStatus, error) {
m := snap.HelmClient()

Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/types/cluster_config_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ func (c Certificates) GetAdminClientKey() string { return getField(c.AdminClien
func (c Certificates) GetK8sdPublicKey() string { return getField(c.K8sdPublicKey) }
func (c Certificates) GetK8sdPrivateKey() string { return getField(c.K8sdPrivateKey) }

// Empty returns true if all Certificates fields are unset
// Empty returns true if all Certificates fields are unset.
func (c Certificates) Empty() bool { return c == Certificates{} }
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/types/cluster_config_datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (c Datastore) GetExternalClientCert() string { return getField(c.ExternalCl
func (c Datastore) GetExternalClientKey() string { return getField(c.ExternalClientKey) }
func (c Datastore) Empty() bool { return c == Datastore{} }

// DatastorePathsProvider is to avoid circular dependency for snap.Snap in Datastore.ToKubeAPIServerArguments()
// DatastorePathsProvider is to avoid circular dependency for snap.Snap in Datastore.ToKubeAPIServerArguments().
type DatastorePathsProvider interface {
K8sDqliteStateDir() string
EtcdPKIDir() string
Expand Down
6 changes: 3 additions & 3 deletions src/k8s/pkg/utils/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// SplitIPAndDNSSANs splits a list of SANs into IP and DNS SANs
// Returns a list of IP addresses and a list of DNS names
// Returns a list of IP addresses and a list of DNS names.
func SplitIPAndDNSSANs(extraSANs []string) ([]net.IP, []string) {
var ipSANs []net.IP
var dnsSANs []string
Expand Down Expand Up @@ -57,7 +57,7 @@ func TLSClientConfigWithTrustedCertificate(remoteCert *x509.Certificate, rootCAs

// GetRemoteCertificate retrieves the remote certificate from a given address
// The address should be in the format of "hostname:port"
// Returns the remote certificate or an error
// Returns the remote certificate or an error.
func GetRemoteCertificate(address string) (*x509.Certificate, error) {
// validate address
_, _, err := net.SplitHostPort(address)
Expand Down Expand Up @@ -95,7 +95,7 @@ func GetRemoteCertificate(address string) (*x509.Certificate, error) {
return resp.TLS.PeerCertificates[0], nil
}

// CertFingerprint returns the SHA256 fingerprint of a certificate
// CertFingerprint returns the SHA256 fingerprint of a certificate.
func CertFingerprint(cert *x509.Certificate) string {
return fmt.Sprintf("%x", sha256.Sum256(cert.Raw))
}
2 changes: 1 addition & 1 deletion src/k8s/pkg/utils/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func SecondsToExpirationDate(now time.Time, seconds int) time.Time {
// - y: years
// - mo: months
// - d: days
// - any other unit supported by time.ParseDuration
// - any other unit supported by time.ParseDuration.
func TTLToSeconds(ttl string) (int, error) {
if len(ttl) < 2 {
return 0, fmt.Errorf("invalid TTL length: %s", ttl)
Expand Down
Loading