@@ -953,6 +953,52 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
953953Expect (cm .Data ).To (BeComparableTo (data ))
954954Expect (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+ ObjectMeta : metav1.ObjectMeta {
966+ Name : "secret-one" ,
967+ Namespace : "default" ,
968+ },
969+ Data : data ,
970+ }
971+
972+ secretApplyConfiguration := corev1applyconfigurations .
973+ Secret ("secret-two" , "default" ).
974+ WithData (data )
975+
976+ err = cl .Create (ctx , secretObject )
977+ Expect (err ).NotTo (HaveOccurred ())
978+
979+ err = cl .Apply (ctx , secretApplyConfiguration , & client.ApplyOptions {FieldManager : "test-manager" })
980+ Expect (err ).NotTo (HaveOccurred ())
981+
982+ secret , err := clientset .CoreV1 ().Secrets (ptr .Deref (secretApplyConfiguration .GetNamespace (), "" )).Get (ctx , ptr .Deref (secretApplyConfiguration .GetName (), "" ), metav1.GetOptions {})
983+ Expect (err ).NotTo (HaveOccurred ())
984+
985+ Expect (secret .Data ).To (BeComparableTo (data ))
986+ Expect (secret .Data ).To (BeComparableTo (secretApplyConfiguration .Data ))
987+
988+ data = map [string ][]byte {
989+ "some-key" : []byte ("some-new-value" ),
990+ }
991+ secretApplyConfiguration .Data = data
992+
993+ err = cl .Apply (ctx , secretApplyConfiguration , & client.ApplyOptions {FieldManager : "test-manager" })
994+ Expect (err ).NotTo (HaveOccurred ())
995+
996+ secret , err = clientset .CoreV1 ().Secrets (ptr .Deref (secretApplyConfiguration .GetNamespace (), "" )).Get (ctx , ptr .Deref (secretApplyConfiguration .GetName (), "" ), metav1.GetOptions {})
997+ Expect (err ).NotTo (HaveOccurred ())
998+
999+ Expect (secret .Data ).To (BeComparableTo (data ))
1000+ Expect (secret .Data ).To (BeComparableTo (secretApplyConfiguration .Data ))
1001+ })
9561002})
9571003})
9581004
0 commit comments