Skip to content
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
13 changes: 12 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ linters:
# against idiomatic Go programming, which encourages this approach - e.g.
# to scope errors.
- noinlineerr

# Deprecated in favour of gomodguard_v2, which is enabled by default: all
- gomodguard
settings:
depguard:
rules:
Expand All @@ -117,6 +120,7 @@ linters:
goconst:
min-len: 3
min-occurrences: 5
ignore-tests: true
gocritic:
enabled-tags:
- performance
Expand Down Expand Up @@ -159,7 +163,6 @@ linters:
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gosec
- scopelint
- unparam
Expand All @@ -178,6 +181,14 @@ linters:
- gochecknoinits
path: apis/

# The xcrd package builds OpenAPI schemas, so it repeats schema
# vocabulary like "string", "object", and "apiVersion". Each literal
# mirrors the schema field it emits, which reads better than a named
# constant standing in for it.
- linters:
- goconst
path: pkg/xcrd/

# These are performance optimisations rather than style issues per se.
# They warn when function arguments or range values copy a lot of memory
# rather than using a pointer.
Expand Down
2 changes: 1 addition & 1 deletion apis/changelogs/proto/v1alpha1/changelog.pb.go

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

6 changes: 3 additions & 3 deletions apis/changelogs/proto/v1alpha1/changelog_grpc.pb.go

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

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

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

2 changes: 1 addition & 1 deletion apis/proto/v1alpha1/ess.pb.go

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

10 changes: 5 additions & 5 deletions apis/proto/v1alpha1/ess_grpc.pb.go

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

8 changes: 4 additions & 4 deletions flake.lock

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

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
description = "Crossplane Runtime - Go library for building Crossplane providers and controllers";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

# TODO(negz): Unpin once https://github.com/nix-community/gomod2nix/pull/231 is released.
Expand Down Expand Up @@ -99,7 +99,7 @@
pkgs.kubernetes-controller-tools

# Nix
pkgs.nixfmt-rfc-style
pkgs.nixfmt
];

shellHook = ''
Expand Down
2 changes: 1 addition & 1 deletion nix/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
nativeBuildInputs = [
pkgs.statix
pkgs.deadnix
pkgs.nixfmt-rfc-style
pkgs.nixfmt
];
}
''
Expand Down
6 changes: 3 additions & 3 deletions pkg/fieldpath/fieldpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ func (sg Segments) String() string {
switch s.Type {
case SegmentField:
if s.Field == wildcard || strings.ContainsRune(s.Field, period) {
b.WriteString(fmt.Sprintf("[%s]", s.Field))
fmt.Fprintf(&b, "[%s]", s.Field)
continue
}

b.WriteString(fmt.Sprintf(".%s", s.Field))
fmt.Fprintf(&b, ".%s", s.Field)
case SegmentIndex:
b.WriteString(fmt.Sprintf("[%d]", s.Index))
fmt.Fprintf(&b, "[%d]", s.Index)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/fieldpath/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ func merge(dst, src any, mergeOptions *xpv1.MergeOptions) (any, error) {

func removeSourceDuplicates(dst, src any) any {
sliceDst, sliceSrc := reflect.ValueOf(dst), reflect.ValueOf(src)
if sliceDst.Kind() == reflect.Ptr {
if sliceDst.Kind() == reflect.Pointer {
sliceDst = sliceDst.Elem()
}

if sliceSrc.Kind() == reflect.Ptr {
if sliceSrc.Kind() == reflect.Pointer {
sliceSrc = sliceSrc.Elem()
}

Expand Down
15 changes: 9 additions & 6 deletions pkg/reconciler/managed/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import (
"github.com/crossplane/crossplane-runtime/v2/pkg/resource"
)

const subSystem = "crossplane"
const (
subSystem = "crossplane"
labelGVK = "gvk"
)

// MetricRecorder records the managed resource metrics.
type MetricRecorder interface { //nolint:interfacebloat // The first two methods are coming from Prometheus
Expand Down Expand Up @@ -61,25 +64,25 @@ func NewMRMetricRecorder() *MRMetricRecorder {
Name: "managed_resource_first_time_to_reconcile_seconds",
Help: "The time it took for a managed resource to be detected by the controller",
Buckets: kmetrics.ExponentialBuckets(10e-9, 10, 10),
}, []string{"gvk"}),
}, []string{labelGVK}),
mrFirstTimeReady: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: subSystem,
Name: "managed_resource_first_time_to_readiness_seconds",
Help: "The time it took for a managed resource to become ready first time after creation",
Buckets: []float64{1, 5, 10, 15, 30, 60, 120, 300, 600, 1800, 3600},
}, []string{"gvk"}),
}, []string{labelGVK}),
mrDeletion: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: subSystem,
Name: "managed_resource_deletion_seconds",
Help: "The time it took for a managed resource to be deleted",
Buckets: []float64{1, 5, 10, 15, 30, 60, 120, 300, 600, 1800, 3600},
}, []string{"gvk"}),
}, []string{labelGVK}),
mrDrift: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: subSystem,
Name: "managed_resource_drift_seconds",
Help: "ALPHA: How long since the previous successful reconcile when a resource was found to be out of sync; excludes restart of the provider",
Buckets: kmetrics.ExponentialBuckets(10e-9, 10, 10),
}, []string{"gvk"}),
}, []string{labelGVK}),
}
}

Expand Down Expand Up @@ -176,6 +179,6 @@ func (r *NopMetricRecorder) recordFirstTimeReady(_ resource.Managed) {}

func getLabels(r resource.Managed) prometheus.Labels {
return prometheus.Labels{
"gvk": r.GetObjectKind().GroupVersionKind().String(),
labelGVK: r.GetObjectKind().GroupVersionKind().String(),
}
}
Loading