Skip to content

Commit 8814d0b

Browse files
authored
Merge pull request #512 from turkenh/pre-v1-cleanup
Cleanup deprecated code that are no longer used
2 parents 3a49b12 + 11e9468 commit 8814d0b

File tree

14 files changed

+0
-1151
lines changed

14 files changed

+0
-1151
lines changed

pkg/fieldpath/paved.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -321,28 +321,6 @@ func (p *Paved) GetBool(path string) (bool, error) {
321321
return b, nil
322322
}
323323

324-
// NOTE(muvaf): If there is no CRD, unstructured.Unstructured reads numbers as
325-
// float64. However, in practice, use of float64 is discouraged and when you fetch
326-
// an instance of a CRD whose number fields are int64, you'll get int64. So,
327-
// it's not really possible to test this without an api-server but that's the
328-
// actual behavior.
329-
330-
// GetNumber value of the supplied field path.
331-
// Deprecated: Use of float64 is discouraged. Please use GetInteger.
332-
// See https://github.com/kubernetes/community/blob/c9ae475/contributors/devel/sig-architecture/api-conventions.md#primitive-types
333-
func (p *Paved) GetNumber(path string) (float64, error) {
334-
v, err := p.GetValue(path)
335-
if err != nil {
336-
return 0, err
337-
}
338-
339-
f, ok := v.(float64)
340-
if !ok {
341-
return 0, errors.Errorf("%s: not a (float64) number", path)
342-
}
343-
return f, nil
344-
}
345-
346324
// GetInteger value of the supplied field path.
347325
func (p *Paved) GetInteger(path string) (int64, error) {
348326
v, err := p.GetValue(path)

pkg/fieldpath/paved_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -484,59 +484,6 @@ func TestGetBool(t *testing.T) {
484484
}
485485
}
486486

487-
func TestGetNumber(t *testing.T) {
488-
type want struct {
489-
value float64
490-
err error
491-
}
492-
cases := map[string]struct {
493-
reason string
494-
path string
495-
data []byte
496-
want want
497-
}{
498-
"MetadataVersion": {
499-
reason: "Requesting a number field should work",
500-
path: "metadata.version",
501-
data: []byte(`{"metadata":{"version":2.0}}`),
502-
want: want{
503-
value: 2,
504-
},
505-
},
506-
"MalformedPath": {
507-
reason: "Requesting an invalid field path should fail",
508-
path: "spec[]",
509-
want: want{
510-
err: errors.Wrap(errors.New("unexpected ']' at position 5"), "cannot parse path \"spec[]\""),
511-
},
512-
},
513-
"NotANumber": {
514-
reason: "Requesting an non-number field path should fail",
515-
path: "metadata.name",
516-
data: []byte(`{"metadata":{"name":"cool"}}`),
517-
want: want{
518-
err: errors.New("metadata.name: not a (float64) number"),
519-
},
520-
},
521-
}
522-
523-
for name, tc := range cases {
524-
t.Run(name, func(t *testing.T) {
525-
in := make(map[string]any)
526-
_ = json.Unmarshal(tc.data, &in)
527-
p := Pave(in)
528-
529-
got, err := p.GetNumber(tc.path)
530-
if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" {
531-
t.Fatalf("\np.GetNumber(%s): %s: -want error, +got error:\n%s", tc.path, tc.reason, diff)
532-
}
533-
if diff := cmp.Diff(tc.want.value, got); diff != "" {
534-
t.Errorf("\np.GetNumber(%s): %s: -want, +got:\n%s", tc.path, tc.reason, diff)
535-
}
536-
})
537-
}
538-
}
539-
540487
func TestGetInteger(t *testing.T) {
541488
type want struct {
542489
value int64

pkg/meta/meta.go

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ limitations under the License.
1818
package meta
1919

2020
import (
21-
"fmt"
22-
"hash/fnv"
23-
"strings"
2421
"time"
2522

2623
corev1 "k8s.io/api/core/v1"
@@ -66,17 +63,6 @@ const (
6663
AnnotationKeyReconciliationPaused = "crossplane.io/paused"
6764
)
6865

69-
// Supported resources with all of these annotations will be fully or partially
70-
// propagated to the named resource of the same kind, assuming it exists and
71-
// consents to propagation.
72-
const (
73-
AnnotationKeyPropagateToPrefix = "to.propagate.crossplane.io/"
74-
75-
// Deprecated: This functionality will be removed soon.
76-
AnnotationKeyPropagateFromNamespace = "from.propagate.crossplane.io/namespace"
77-
AnnotationKeyPropagateFromName = "from.propagate.crossplane.io/name"
78-
)
79-
8066
// ReferenceTo returns an object reference to the supplied object, presumed to
8167
// be of the supplied group, version, and kind.
8268
// Deprecated: use a more specific reference type, such as TypedReference or
@@ -361,66 +347,6 @@ func ExternalCreateSucceededDuring(o metav1.Object, d time.Duration) bool {
361347
return time.Since(t) < d
362348
}
363349

364-
// AllowPropagation from one object to another by adding consenting annotations
365-
// to both.
366-
// Deprecated: This functionality will be removed soon.
367-
func AllowPropagation(from, to metav1.Object) {
368-
AddAnnotations(to, map[string]string{
369-
AnnotationKeyPropagateFromNamespace: from.GetNamespace(),
370-
AnnotationKeyPropagateFromName: from.GetName(),
371-
})
372-
373-
AddAnnotations(from, map[string]string{
374-
AnnotationKeyPropagateTo(to): to.GetNamespace() + "/" + to.GetName(),
375-
})
376-
}
377-
378-
// AnnotationKeyPropagateTo returns an annotation key whose presence indicates
379-
// that the annotated object consents to propagation from the supplied object.
380-
// The annotation name (which follows the prefix) can be anything that doesn't
381-
// collide with another annotation. to.propagation.crossplane.io/example would
382-
// be valid. This function uses a hash of the supplied object's namespace and
383-
// name in order to avoid collisions and keep the suffix relatively short.
384-
func AnnotationKeyPropagateTo(o metav1.Object) string {
385-
// Writing to a hash never returns an error.
386-
h := fnv.New32a()
387-
h.Write([]byte(o.GetNamespace()))
388-
h.Write([]byte(o.GetName()))
389-
return fmt.Sprintf("%s%x", AnnotationKeyPropagateToPrefix, h.Sum32())
390-
}
391-
392-
// AllowsPropagationFrom returns the NamespacedName of the object the supplied
393-
// object should be propagated from.
394-
func AllowsPropagationFrom(to metav1.Object) types.NamespacedName {
395-
return types.NamespacedName{
396-
Namespace: to.GetAnnotations()[AnnotationKeyPropagateFromNamespace],
397-
Name: to.GetAnnotations()[AnnotationKeyPropagateFromName],
398-
}
399-
}
400-
401-
// AllowsPropagationTo returns the set of NamespacedNames that the supplied
402-
// object may be propagated to.
403-
func AllowsPropagationTo(from metav1.Object) map[types.NamespacedName]bool {
404-
to := make(map[types.NamespacedName]bool)
405-
406-
for k, v := range from.GetAnnotations() {
407-
nn := strings.Split(v, "/")
408-
switch {
409-
case !strings.HasPrefix(k, AnnotationKeyPropagateToPrefix):
410-
continue
411-
case len(nn) != 2:
412-
continue
413-
case nn[0] == "":
414-
continue
415-
case nn[1] == "":
416-
continue
417-
}
418-
to[types.NamespacedName{Namespace: nn[0], Name: nn[1]}] = true
419-
}
420-
421-
return to
422-
}
423-
424350
// IsPaused returns true if the object has the AnnotationKeyReconciliationPaused
425351
// annotation set to `true`.
426352
func IsPaused(o metav1.Object) bool {

pkg/meta/meta_test.go

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package meta
1818

1919
import (
20-
"fmt"
21-
"hash/fnv"
2220
"testing"
2321
"time"
2422

@@ -1181,147 +1179,6 @@ func TestExternalCreateIncomplete(t *testing.T) {
11811179
}
11821180
}
11831181

1184-
func TestAllowPropagation(t *testing.T) {
1185-
fromns := "from-namespace"
1186-
from := "from-name"
1187-
tons := "to-namespace"
1188-
to := "to-name"
1189-
1190-
tohash := func() string {
1191-
h := fnv.New32a()
1192-
h.Write([]byte(tons))
1193-
h.Write([]byte(to))
1194-
return fmt.Sprintf("%x", h.Sum32())
1195-
}()
1196-
1197-
type args struct {
1198-
from metav1.Object
1199-
to metav1.Object
1200-
}
1201-
type want struct {
1202-
from metav1.Object
1203-
to metav1.Object
1204-
}
1205-
1206-
cases := map[string]struct {
1207-
args args
1208-
want want
1209-
}{
1210-
"Successful": {
1211-
args: args{
1212-
from: &corev1.Pod{ObjectMeta: metav1.ObjectMeta{
1213-
Namespace: fromns,
1214-
Name: from,
1215-
Annotations: map[string]string{
1216-
"existing": "annotation",
1217-
},
1218-
}},
1219-
to: &corev1.Pod{ObjectMeta: metav1.ObjectMeta{
1220-
Namespace: tons,
1221-
Name: to,
1222-
Annotations: map[string]string{
1223-
"existing": "annotation",
1224-
},
1225-
}},
1226-
},
1227-
want: want{
1228-
from: &corev1.Pod{ObjectMeta: metav1.ObjectMeta{
1229-
Namespace: fromns,
1230-
Name: from,
1231-
Annotations: map[string]string{
1232-
"existing": "annotation",
1233-
AnnotationKeyPropagateToPrefix + tohash: tons + "/" + to,
1234-
},
1235-
}},
1236-
to: &corev1.Pod{ObjectMeta: metav1.ObjectMeta{
1237-
Namespace: tons,
1238-
Name: to,
1239-
Annotations: map[string]string{
1240-
"existing": "annotation",
1241-
AnnotationKeyPropagateFromNamespace: fromns,
1242-
AnnotationKeyPropagateFromName: from,
1243-
},
1244-
}},
1245-
},
1246-
},
1247-
}
1248-
1249-
for name, tc := range cases {
1250-
t.Run(name, func(t *testing.T) {
1251-
AllowPropagation(tc.args.from, tc.args.to)
1252-
if diff := cmp.Diff(tc.want.from, tc.args.from); diff != "" {
1253-
t.Errorf("AllowPropagation(...): -want from, +got from\n%s", diff)
1254-
}
1255-
if diff := cmp.Diff(tc.want.to, tc.args.to); diff != "" {
1256-
t.Errorf("AllowPropagation(...): -want to, +got to\n%s", diff)
1257-
}
1258-
})
1259-
}
1260-
}
1261-
1262-
func TestAllowsPropagationFrom(t *testing.T) {
1263-
ns := "coolns"
1264-
name := "coolname"
1265-
1266-
cases := map[string]struct {
1267-
to metav1.Object
1268-
want types.NamespacedName
1269-
}{
1270-
"Successful": {
1271-
to: &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{
1272-
AnnotationKeyPropagateFromNamespace: ns,
1273-
AnnotationKeyPropagateFromName: name,
1274-
}}},
1275-
want: types.NamespacedName{Namespace: ns, Name: name},
1276-
},
1277-
}
1278-
1279-
for name, tc := range cases {
1280-
t.Run(name, func(t *testing.T) {
1281-
got := AllowsPropagationFrom(tc.to)
1282-
if diff := cmp.Diff(tc.want, got); diff != "" {
1283-
t.Errorf("AllowsPropagationFrom(...): -want, +got\n%s", diff)
1284-
}
1285-
})
1286-
}
1287-
}
1288-
1289-
func TestAllowsPropagationTo(t *testing.T) {
1290-
nsA := "coolns"
1291-
nameA := "coolname"
1292-
nsB := "coolerns"
1293-
nameB := "coolername"
1294-
1295-
cases := map[string]struct {
1296-
from metav1.Object
1297-
want map[types.NamespacedName]bool
1298-
}{
1299-
"Successful": {
1300-
from: &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{
1301-
"existing": "annotation",
1302-
AnnotationKeyPropagateToPrefix + "missingslash": "wat",
1303-
AnnotationKeyPropagateToPrefix + "missingname": "wat/",
1304-
AnnotationKeyPropagateToPrefix + "missingnamespace": "/wat",
1305-
AnnotationKeyPropagateToPrefix + "a": nsA + "/" + nameA,
1306-
AnnotationKeyPropagateToPrefix + "b": nsB + "/" + nameB,
1307-
}}},
1308-
want: map[types.NamespacedName]bool{
1309-
{Namespace: nsA, Name: nameA}: true,
1310-
{Namespace: nsB, Name: nameB}: true,
1311-
},
1312-
},
1313-
}
1314-
1315-
for name, tc := range cases {
1316-
t.Run(name, func(t *testing.T) {
1317-
got := AllowsPropagationTo(tc.from)
1318-
if diff := cmp.Diff(tc.want, got); diff != "" {
1319-
t.Errorf("AllowsPropagationTo(...): -want, +got\n%s", diff)
1320-
}
1321-
})
1322-
}
1323-
}
1324-
13251182
func TestIsPaused(t *testing.T) {
13261183
cases := map[string]struct {
13271184
o metav1.Object

pkg/ratelimiter/default.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ import (
2626
"sigs.k8s.io/controller-runtime/pkg/ratelimiter"
2727
)
2828

29-
const (
30-
// DefaultProviderRPS is the recommended default average requeues per
31-
// second tolerated by a Crossplane provider.
32-
//
33-
// Deprecated: Use a flag
34-
DefaultProviderRPS = 1
35-
)
36-
3729
// NewGlobal returns a token bucket rate limiter meant for limiting the number
3830
// of average total requeues per second for all controllers registered with a
3931
// controller manager. The bucket size (i.e. allowed burst) is rps * 10.
@@ -48,28 +40,6 @@ func NewController() ratelimiter.RateLimiter {
4840
return workqueue.NewItemExponentialFailureRateLimiter(1*time.Second, 60*time.Second)
4941
}
5042

51-
// NewDefaultProviderRateLimiter returns a token bucket rate limiter meant for
52-
// limiting the number of average total requeues per second for all controllers
53-
// registered with a controller manager. The bucket size is a linear function of
54-
// the requeues per second.
55-
//
56-
// Deprecated: Use NewGlobal.
57-
func NewDefaultProviderRateLimiter(rps int) *workqueue.BucketRateLimiter {
58-
return NewGlobal(rps)
59-
}
60-
61-
// NewDefaultManagedRateLimiter returns a rate limiter that takes the maximum
62-
// delay between the passed provider and a per-item exponential backoff limiter.
63-
// The exponential backoff limiter has a base delay of 1s and a maximum of 60s.
64-
//
65-
// Deprecated: Use NewController.
66-
func NewDefaultManagedRateLimiter(provider ratelimiter.RateLimiter) ratelimiter.RateLimiter {
67-
return workqueue.NewMaxOfRateLimiter(
68-
workqueue.NewItemExponentialFailureRateLimiter(1*time.Second, 60*time.Second),
69-
provider,
70-
)
71-
}
72-
7343
// LimitRESTConfig returns a copy of the supplied REST config with rate limits
7444
// derived from the supplied rate of reconciles per second.
7545
func LimitRESTConfig(cfg *rest.Config, rps int) *rest.Config {

0 commit comments

Comments
 (0)