@@ -2000,11 +2000,17 @@ var _ = Describe("Client", func() {
2000
2000
Describe ("CreateOptions" , func () {
2001
2001
It ("should allow setting DryRun to 'all'" , func () {
2002
2002
co := & client.CreateOptions {}
2003
- client .CreateDryRunAll (co )
2003
+ client .DryRunAll . ApplyToCreate (co )
2004
2004
all := []string {metav1 .DryRunAll }
2005
2005
Expect (co .AsCreateOptions ().DryRun ).To (Equal (all ))
2006
2006
})
2007
2007
2008
+ It ("should allow setting the field manager" , func () {
2009
+ po := & client.CreateOptions {}
2010
+ client .FieldOwner ("some-owner" ).ApplyToCreate (po )
2011
+ Expect (po .AsCreateOptions ().FieldManager ).To (Equal ("some-owner" ))
2012
+ })
2013
+
2008
2014
It ("should produce empty metav1.CreateOptions if nil" , func () {
2009
2015
var co * client.CreateOptions
2010
2016
Expect (co .AsCreateOptions ()).To (Equal (& metav1.CreateOptions {}))
@@ -2016,26 +2022,33 @@ var _ = Describe("Client", func() {
2016
2022
Describe ("DeleteOptions" , func () {
2017
2023
It ("should allow setting GracePeriodSeconds" , func () {
2018
2024
do := & client.DeleteOptions {}
2019
- client .GracePeriodSeconds (1 )(do )
2025
+ client .GracePeriodSeconds (1 ). ApplyToDelete (do )
2020
2026
gp := int64 (1 )
2021
2027
Expect (do .AsDeleteOptions ().GracePeriodSeconds ).To (Equal (& gp ))
2022
2028
})
2023
2029
2024
2030
It ("should allow setting Precondition" , func () {
2025
2031
do := & client.DeleteOptions {}
2026
2032
pc := metav1 .NewUIDPreconditions ("uid" )
2027
- client .Preconditions (pc )(do )
2033
+ client .Preconditions (* pc ). ApplyToDelete (do )
2028
2034
Expect (do .AsDeleteOptions ().Preconditions ).To (Equal (pc ))
2029
2035
Expect (do .Preconditions ).To (Equal (pc ))
2030
2036
})
2031
2037
2032
2038
It ("should allow setting PropagationPolicy" , func () {
2033
2039
do := & client.DeleteOptions {}
2034
- client .PropagationPolicy (metav1 .DeletePropagationForeground )(do )
2040
+ client .PropagationPolicy (metav1 .DeletePropagationForeground ). ApplyToDelete (do )
2035
2041
dp := metav1 .DeletePropagationForeground
2036
2042
Expect (do .AsDeleteOptions ().PropagationPolicy ).To (Equal (& dp ))
2037
2043
})
2038
2044
2045
+ It ("should allow setting DryRun" , func () {
2046
+ do := & client.DeleteOptions {}
2047
+ client .DryRunAll .ApplyToDelete (do )
2048
+ all := []string {metav1 .DryRunAll }
2049
+ Expect (do .AsDeleteOptions ().DryRun ).To (Equal (all ))
2050
+ })
2051
+
2039
2052
It ("should produce empty metav1.DeleteOptions if nil" , func () {
2040
2053
var do * client.DeleteOptions
2041
2054
Expect (do .AsDeleteOptions ()).To (Equal (& metav1.DeleteOptions {}))
@@ -2048,9 +2061,9 @@ var _ = Describe("Client", func() {
2048
2061
pc := metav1 .NewUIDPreconditions ("uid" )
2049
2062
dp := metav1 .DeletePropagationForeground
2050
2063
do := & client.DeleteOptions {}
2051
- do .ApplyOptions ([]client.DeleteOptionFunc {
2064
+ do .ApplyOptions ([]client.DeleteOption {
2052
2065
client .GracePeriodSeconds (gp ),
2053
- client .Preconditions (pc ),
2066
+ client .Preconditions (* pc ),
2054
2067
client .PropagationPolicy (dp ),
2055
2068
})
2056
2069
Expect (do .GracePeriodSeconds ).To (Equal (& gp ))
@@ -2060,79 +2073,35 @@ var _ = Describe("Client", func() {
2060
2073
})
2061
2074
2062
2075
Describe ("ListOptions" , func () {
2063
- It ("should be able to set a LabelSelector" , func () {
2064
- lo := & client.ListOptions {}
2065
- err := lo .SetLabelSelector ("foo=bar" )
2066
- Expect (err ).NotTo (HaveOccurred ())
2067
- Expect (lo .LabelSelector .String ()).To (Equal ("foo=bar" ))
2068
- })
2069
-
2070
- It ("should be able to set a FieldSelector" , func () {
2071
- lo := & client.ListOptions {}
2072
- err := lo .SetFieldSelector ("field1=bar" )
2073
- Expect (err ).NotTo (HaveOccurred ())
2074
- Expect (lo .FieldSelector .String ()).To (Equal ("field1=bar" ))
2075
- })
2076
-
2077
- It ("should be converted to metav1.ListOptions" , func () {
2078
- lo := & client.ListOptions {}
2079
- labels := map [string ]string {"foo" : "bar" }
2080
- mlo := lo .MatchingLabels (labels ).
2081
- MatchingField ("field1" , "bar" ).
2082
- InNamespace ("test-namespace" ).
2083
- AsListOptions ()
2076
+ It ("should be convertable to metav1.ListOptions" , func () {
2077
+ lo := (& client.ListOptions {}).ApplyOptions ([]client.ListOption {
2078
+ client .MatchingField ("field1" , "bar" ),
2079
+ client .InNamespace ("test-namespace" ),
2080
+ client.MatchingLabels {"foo" : "bar" },
2081
+ })
2082
+ mlo := lo .AsListOptions ()
2084
2083
Expect (mlo ).NotTo (BeNil ())
2085
2084
Expect (mlo .LabelSelector ).To (Equal ("foo=bar" ))
2086
2085
Expect (mlo .FieldSelector ).To (Equal ("field1=bar" ))
2087
2086
})
2088
2087
2089
- It ("should be able to set MatchingLabels" , func () {
2088
+ It ("should be populated by MatchingLabels" , func () {
2090
2089
lo := & client.ListOptions {}
2091
- Expect (lo .LabelSelector ).To (BeNil ())
2092
- labels := map [string ]string {"foo" : "bar" }
2093
- lo = lo .MatchingLabels (labels )
2094
- Expect (lo .LabelSelector .String ()).To (Equal ("foo=bar" ))
2095
- })
2096
-
2097
- It ("should be able to set MatchingField" , func () {
2098
- lo := & client.ListOptions {}
2099
- Expect (lo .FieldSelector ).To (BeNil ())
2100
- lo = lo .MatchingField ("field1" , "bar" )
2101
- Expect (lo .FieldSelector .String ()).To (Equal ("field1=bar" ))
2102
- })
2103
-
2104
- It ("should be able to set InNamespace" , func () {
2105
- lo := & client.ListOptions {}
2106
- lo = lo .InNamespace ("test-namespace" )
2107
- Expect (lo .Namespace ).To (Equal ("test-namespace" ))
2108
- })
2109
-
2110
- It ("should be created from MatchingLabels" , func () {
2111
- labels := map [string ]string {"foo" : "bar" }
2112
- lo := & client.ListOptions {}
2113
- client .MatchingLabels (labels )(lo )
2090
+ client.MatchingLabels {"foo" : "bar" }.ApplyToList (lo )
2114
2091
Expect (lo ).NotTo (BeNil ())
2115
2092
Expect (lo .LabelSelector .String ()).To (Equal ("foo=bar" ))
2116
2093
})
2117
2094
2118
- It ("should be created from MatchingField" , func () {
2095
+ It ("should be populated by MatchingField" , func () {
2119
2096
lo := & client.ListOptions {}
2120
- client .MatchingField ("field1" , "bar" )(lo )
2097
+ client .MatchingField ("field1" , "bar" ). ApplyToList (lo )
2121
2098
Expect (lo ).NotTo (BeNil ())
2122
2099
Expect (lo .FieldSelector .String ()).To (Equal ("field1=bar" ))
2123
2100
})
2124
2101
2125
- It ("should be created from InNamespace" , func () {
2102
+ It ("should be populated by InNamespace" , func () {
2126
2103
lo := & client.ListOptions {}
2127
- client .InNamespace ("test" )(lo )
2128
- Expect (lo ).NotTo (BeNil ())
2129
- Expect (lo .Namespace ).To (Equal ("test" ))
2130
- })
2131
-
2132
- It ("should allow pre-built ListOptions" , func () {
2133
- lo := & client.ListOptions {}
2134
- newLo := & client.ListOptions {}
2135
- client .UseListOptions (newLo .InNamespace ("test" ))(lo )
2104
+ client .InNamespace ("test" ).ApplyToList (lo )
2136
2105
Expect (lo ).NotTo (BeNil ())
2137
2106
Expect (lo .Namespace ).To (Equal ("test" ))
2138
2107
})
@@ -2141,11 +2110,17 @@ var _ = Describe("Client", func() {
2141
2110
Describe ("UpdateOptions" , func () {
2142
2111
It ("should allow setting DryRun to 'all'" , func () {
2143
2112
uo := & client.UpdateOptions {}
2144
- client .UpdateDryRunAll (uo )
2113
+ client .DryRunAll . ApplyToUpdate (uo )
2145
2114
all := []string {metav1 .DryRunAll }
2146
2115
Expect (uo .AsUpdateOptions ().DryRun ).To (Equal (all ))
2147
2116
})
2148
2117
2118
+ It ("should allow setting the field manager" , func () {
2119
+ po := & client.UpdateOptions {}
2120
+ client .FieldOwner ("some-owner" ).ApplyToUpdate (po )
2121
+ Expect (po .AsUpdateOptions ().FieldManager ).To (Equal ("some-owner" ))
2122
+ })
2123
+
2149
2124
It ("should produce empty metav1.UpdateOptions if nil" , func () {
2150
2125
var co * client.UpdateOptions
2151
2126
Expect (co .AsUpdateOptions ()).To (Equal (& metav1.UpdateOptions {}))
@@ -2157,22 +2132,22 @@ var _ = Describe("Client", func() {
2157
2132
Describe ("PatchOptions" , func () {
2158
2133
It ("should allow setting DryRun to 'all'" , func () {
2159
2134
po := & client.PatchOptions {}
2160
- client .PatchDryRunAll (po )
2135
+ client .DryRunAll . ApplyToPatch (po )
2161
2136
all := []string {metav1 .DryRunAll }
2162
2137
Expect (po .AsPatchOptions ().DryRun ).To (Equal (all ))
2163
2138
})
2164
2139
2165
2140
It ("should allow setting Force to 'true'" , func () {
2166
2141
po := & client.PatchOptions {}
2167
- client .ForceOwnership (po )
2142
+ client .ForceOwnership . ApplyToPatch (po )
2168
2143
mpo := po .AsPatchOptions ()
2169
2144
Expect (mpo .Force ).NotTo (BeNil ())
2170
2145
Expect (* mpo .Force ).To (BeTrue ())
2171
2146
})
2172
2147
2173
2148
It ("should allow setting the field manager" , func () {
2174
2149
po := & client.PatchOptions {}
2175
- client .FieldOwner ("some-owner" )(po )
2150
+ client .FieldOwner ("some-owner" ). ApplyToPatch (po )
2176
2151
Expect (po .AsPatchOptions ().FieldManager ).To (Equal ("some-owner" ))
2177
2152
})
2178
2153
@@ -2320,7 +2295,7 @@ func (f *fakeReader) Get(ctx context.Context, key client.ObjectKey, obj runtime.
2320
2295
return nil
2321
2296
}
2322
2297
2323
- func (f * fakeReader ) List (ctx context.Context , list runtime.Object , opts ... client.ListOptionFunc ) error {
2298
+ func (f * fakeReader ) List (ctx context.Context , list runtime.Object , opts ... client.ListOption ) error {
2324
2299
f .Called = f .Called + 1
2325
2300
return nil
2326
2301
}
0 commit comments