-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jian Qiu <jqiu@redhat.com>
- Loading branch information
Showing
16 changed files
with
186 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package testing | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
func NewUnstructured(apiVersion, kind, namespace, name string, owners ...metav1.OwnerReference) *unstructured.Unstructured { | ||
u := &unstructured.Unstructured{ | ||
Object: map[string]interface{}{ | ||
"apiVersion": apiVersion, | ||
"kind": kind, | ||
"metadata": map[string]interface{}{ | ||
"namespace": namespace, | ||
"name": name, | ||
}, | ||
}, | ||
} | ||
|
||
u.SetOwnerReferences(owners) | ||
|
||
return u | ||
} | ||
|
||
func NewUnstructuredWithContent( | ||
apiVersion, kind, namespace, name string, content map[string]interface{}) *unstructured.Unstructured { | ||
object := NewUnstructured(apiVersion, kind, namespace, name) | ||
for key, val := range content { | ||
object.Object[key] = val | ||
} | ||
|
||
return object | ||
} | ||
|
||
func NewUnstructuredSecret(namespace, name string, terminated bool, uid string, owners ...metav1.OwnerReference) *unstructured.Unstructured { | ||
u := NewUnstructured("v1", "Secret", namespace, name, owners...) | ||
if terminated { | ||
now := metav1.Now() | ||
u.SetDeletionTimestamp(&now) | ||
} | ||
if uid != "" { | ||
u.SetUID(types.UID(uid)) | ||
} | ||
return u | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.