Skip to content

Commit

Permalink
Make dns names optional, misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Faisal Memon committed Jul 18, 2020
1 parent 8a080d1 commit e4f0d49
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ type Selector struct {
Namespace string `json:"namespace,omitempty"`
// ServiceAccount to match for this spiffe ID
ServiceAccount string `json:"serviceAccount,omitempty"`
// ContainerImage to match
// ContainerImage to match for this spiffe ID
ContainerImage string `json:"containerImage,omitempty"`
// ContainerName to match
// ContainerName to match for this spiffe ID
ContainerName string `json:"containerName,omitempty"`
// NodeName to match
NodeName string `json:"NodeName,omitempty"`
// NodeName to match for this spiffe ID
NodeName string `json:"nodeName,omitempty"`
// Arbitrary k8s selectors
Arbitrary []string `json:"arbitrary,omitempty"`
}
Expand All @@ -46,7 +46,7 @@ type SpiffeIDSpec struct {
ParentId string `json:"parentId"`
SpiffeId string `json:"spiffeId"`
Selector Selector `json:"selector"`
DnsNames []string `json:"dnsNames"`
DnsNames []string `json:"dnsNames,omitempty"`
}

// SpiffeIDStatus defines the observed state of SpiffeID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
status: {}
validation:
openAPIV3Schema:
description: SpiffeID is the Schema for the spireentries API
description: SpiffeID is the Schema for the spiffeid API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -40,16 +40,27 @@ spec:
items:
type: string
type: array
parentId:
type: string
selector:
properties:
arbitrary:
description: Arbitrary selectors
items:
type: string
type: array
containerImage:
description: Container image to match for this spiffe ID
type: string
containerName:
description: Container name to match for this spiffe ID
type: string
namespace:
description: Namespace to match for this spiffe ID
type: string
nodeName:
description: Node name to match for this spiffe ID
type: string
podLabel:
additionalProperties:
type: string
Expand All @@ -68,7 +79,7 @@ spec:
spiffeId:
type: string
required:
- dnsNames
- parentId
- selector
- spiffeId
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func (r *SpiffeIDReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {

if err := r.Get(ctx, req.NamespacedName, &spiffeID); err != nil {
if !k8serrors.IsNotFound(err) {
r.c.Log.WithError(err).Error("Unable to fetch SpiffeID CRD")
r.c.Log.WithFields(logrus.Fields{
"name": spiffeID.Name,
"namespace": spiffeID.Namespace,
}).WithError(err).Error("Unable to fetch SpiffeID resource")
return ctrl.Result{}, err
}

Expand All @@ -83,6 +86,10 @@ func (r *SpiffeIDReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
if !containsString(spiffeID.GetFinalizers(), myFinalizerName) {
spiffeID.SetFinalizers(append(spiffeID.GetFinalizers(), myFinalizerName))
if err := r.Update(ctx, &spiffeID); err != nil {
r.c.Log.WithFields(logrus.Fields{
"name": spiffeID.Name,
"namespace": spiffeID.Namespace,
}).WithError(err).Error("Unable to update finalizer list")
return ctrl.Result{}, err
}
}
Expand Down

0 comments on commit e4f0d49

Please sign in to comment.