github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/pkg/certs.go (about)

     1  // Copyright (c) 2021, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package pkg
     5  
     6  import (
     7  	"context"
     8  
     9  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    10  	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
    11  	"k8s.io/apimachinery/pkg/runtime/schema"
    12  )
    13  
    14  // GetCertificate returns the a cert in a given namespace for the cluster specified in the environment
    15  func GetCertificate(namespace string, name string) (*unstructured.Unstructured, error) {
    16  	client, err := GetDynamicClient()
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  	cert, err := client.Resource(getScheme()).Namespace(namespace).Get(context.TODO(), name, metav1.GetOptions{})
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	return cert, nil
    25  }
    26  
    27  // getScheme returns the certificate scheme needed to get unstructured data
    28  func getScheme() schema.GroupVersionResource {
    29  	return schema.GroupVersionResource{
    30  		Group:    "cert-manager.io",
    31  		Version:  "v1alpha2",
    32  		Resource: "certificate",
    33  	}
    34  }