diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8be06ed9e..5ea05a0c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -101,8 +101,10 @@ jobs: run: go generate ./... - name: Check for changes in generated code run: | - git diff -- '*.pb.go' || ( echo "Rerun go generate ./... locally and resubmit" && false ) - git diff -- '*.gen.go' || ( echo "Rerun go generate ./... locally and resubmit" && false ) + if [[ $(git diff -- '*.gen.go') ]]; then + echo "Run go generate ./..." locally and commit changes + exit 1 + fi excludereplace: name: Exclude Replace in go.mod runs-on: ubuntu-latest diff --git a/pkg/registry/common/endpointurls/sync_map.gen.go b/pkg/registry/common/endpointurls/sync_map.gen.go index d5ee43d1e..cf7285a8b 100644 --- a/pkg/registry/common/endpointurls/sync_map.gen.go +++ b/pkg/registry/common/endpointurls/sync_map.gen.go @@ -1,12 +1,12 @@ -// Code generated by "go-syncmap -output sync_map.gen.go -type Map"; DO NOT EDIT. - +// Code generated by "-output sync_map.gen.go -type Map -output sync_map.gen.go -type Map"; DO NOT EDIT. package endpointurls import ( "net/url" - "sync" + "sync" // Used by sync.Map. ) +// Generate code that will fail if the constants change value. func _() { // An "cannot convert Map literal (type Map) to type sync.Map" compiler error signifies that the base type have changed. // Re-run the go-syncmap command to generate them again. @@ -15,10 +15,25 @@ func _() { var _nil_Map_string_value = func() (val string) { return }() +// Load returns the value stored in the map for a key, or nil if no +// value is present. +// The ok result indicates whether value was found in the map. +func (m *Map) Load(key url.URL) (string, bool) { + value, ok := (*sync.Map)(m).Load(key) + if value == nil { + return _nil_Map_string_value, ok + } + return value.(string), ok +} + +// Store sets the value for a key. func (m *Map) Store(key url.URL, value string) { (*sync.Map)(m).Store(key, value) } +// LoadOrStore returns the existing value for the key if present. +// Otherwise, it stores and returns the given value. +// The loaded result is true if the value was loaded, false if stored. func (m *Map) LoadOrStore(key url.URL, value string) (string, bool) { actual, loaded := (*sync.Map)(m).LoadOrStore(key, value) if actual == nil { @@ -27,18 +42,31 @@ func (m *Map) LoadOrStore(key url.URL, value string) (string, bool) { return actual.(string), loaded } -func (m *Map) Load(key url.URL) (string, bool) { - value, ok := (*sync.Map)(m).Load(key) - if value == nil { - return _nil_Map_string_value, ok +// LoadAndDelete deletes the value for a key, returning the previous value if any. +// The loaded result reports whether the key was present. +func (m *Map) LoadAndDelete(key url.URL) (value string, loaded bool) { + actual, loaded := (*sync.Map)(m).LoadAndDelete(key) + if actual == nil { + return _nil_Map_string_value, loaded } - return value.(string), ok + return actual.(string), loaded } +// Delete deletes the value for a key. func (m *Map) Delete(key url.URL) { (*sync.Map)(m).Delete(key) } +// Range calls f sequentially for each key and value present in the map. +// If f returns false, range stops the iteration. +// +// Range does not necessarily correspond to any consistent snapshot of the Map's +// contents: no key will be visited more than once, but if the value for any key +// is stored or deleted concurrently, Range may reflect any mapping for that key +// from any point during the Range call. +// +// Range may be O(N) with the number of elements in the map even if f returns +// false after a constant number of calls. func (m *Map) Range(f func(key url.URL, value string) bool) { (*sync.Map)(m).Range(func(key, value interface{}) bool { return f(key.(url.URL), value.(string))