@@ -953,6 +953,58 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
953953 Expect (cm .Data ).To (BeComparableTo (data ))
954954 Expect (cm .Data ).To (BeComparableTo (obj .Data ))
955955 })
956+
957+ It ("should create a secret without SSA and later create update a secret using SSA" , func (ctx SpecContext ) {
958+ cl , err := client .New (cfg , client.Options {})
959+ Expect (err ).NotTo (HaveOccurred ())
960+ Expect (cl ).NotTo (BeNil ())
961+ data := map [string ][]byte {
962+ "some-key" : []byte ("some-value" ),
963+ }
964+ secretObject := & corev1.Secret {
965+ TypeMeta : metav1.TypeMeta {
966+ Kind : "Secret" ,
967+ APIVersion : "v1" ,
968+ },
969+ ObjectMeta : metav1.ObjectMeta {
970+ Name : "secret-one" ,
971+ Namespace : "default" ,
972+ },
973+ Data : data ,
974+ }
975+
976+ secretApplyConfiguration := corev1applyconfigurations .
977+ Secret ("secret-two" , "default" ).
978+ WithAPIVersion ("v1" ).
979+ WithKind ("Secret" ).
980+ WithData (data )
981+
982+ err = cl .Create (ctx , secretObject )
983+ Expect (err ).NotTo (HaveOccurred ())
984+
985+ err = cl .Apply (ctx , secretApplyConfiguration , & client.ApplyOptions {FieldManager : "test-manager" })
986+ Expect (err ).NotTo (HaveOccurred ())
987+
988+ cm , err := clientset .CoreV1 ().Secrets (ptr .Deref (secretApplyConfiguration .GetNamespace (), "" )).Get (ctx , ptr .Deref (secretApplyConfiguration .GetName (), "" ), metav1.GetOptions {})
989+ Expect (err ).NotTo (HaveOccurred ())
990+
991+ Expect (cm .Data ).To (BeComparableTo (data ))
992+ Expect (cm .Data ).To (BeComparableTo (secretApplyConfiguration .Data ))
993+
994+ data = map [string ][]byte {
995+ "some-key" : []byte ("some-new-value" ),
996+ }
997+ secretApplyConfiguration .Data = data
998+
999+ err = cl .Apply (ctx , secretApplyConfiguration , & client.ApplyOptions {FieldManager : "test-manager" })
1000+ Expect (err ).NotTo (HaveOccurred ())
1001+
1002+ cm , err = clientset .CoreV1 ().Secrets (ptr .Deref (secretApplyConfiguration .GetNamespace (), "" )).Get (ctx , ptr .Deref (secretApplyConfiguration .GetName (), "" ), metav1.GetOptions {})
1003+ Expect (err ).NotTo (HaveOccurred ())
1004+
1005+ Expect (cm .Data ).To (BeComparableTo (data ))
1006+ Expect (cm .Data ).To (BeComparableTo (secretApplyConfiguration .Data ))
1007+ })
9561008 })
9571009 })
9581010
0 commit comments