Skip to content

Commit

Permalink
create object
Browse files Browse the repository at this point in the history
Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>
  • Loading branch information
maia-iyer committed Oct 24, 2024
1 parent e4ed532 commit 71e87dc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/agent/spirecrd/federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

spirev1alpha1 "github.com/spiffe/spire-controller-manager/api/v1alpha1"
)
Expand Down Expand Up @@ -81,7 +82,23 @@ func (s *SPIRECRDManager) BatchCreateClusterFederatedTrustDomains(inp BatchCreat
return BatchCreateFederationRelationshipsResponse{}, fmt.Errorf("error parsing into clusterFederatedTrustDomain object: %v", err)
}
fmt.Printf("crd object: %+v\n", clusterFederatedTrustDomain)


// translate to unstructured
unstructuredObject, err := runtime.DefaultUnstructuredConverter.ToUnstructured(clusterFederatedTrustDomain)
if err != nil {
return BatchCreateFederationRelationshipsResponse{}, fmt.Errorf("error parsing trustdomain: %v", err)
}
createInput := &unstructured.Unstructured{Object: unstructuredObject}

// post ClusterFederatedTrustDomain object
createResult, err := s.kubeClient.Resource(gvrFederation).Create(context.TODO(), createInput, metav1.CreateOptions{})
// TODO do not return error, simply store result and continue
if err != nil {
return BatchCreateFederationRelationshipsResponse{}, fmt.Errorf("error listing trust domains: %v", err)
}

fmt.Printf("createResult: %+v\n\n", createResult)

}

return BatchCreateFederationRelationshipsResponse{}, nil
Expand Down

0 comments on commit 71e87dc

Please sign in to comment.