|
| 1 | +//go:generate go run github.com/crossplane/crossplane-tools/cmd/angryjet generate-methodsets ./... |
| 2 | + |
| 3 | +package v1alpha1 |
| 4 | + |
| 5 | +import ( |
| 6 | + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" |
| 7 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 8 | +) |
| 9 | + |
| 10 | +// TokenParameters define the desired state of an ArgoCD Project Token |
| 11 | +type TokenParameters struct { |
| 12 | + // Project is the project associated with the token |
| 13 | + // +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-argocd/apis/projects/v1alpha1.Project |
| 14 | + // +crossplane:generate:reference:refFieldName=ProjectRef |
| 15 | + // +crossplane:generate:reference:selectorFieldName=ProjectSelector |
| 16 | + Project *string `json:"project"` |
| 17 | + |
| 18 | + // ProjectRefs is a reference to a Project used to set Project |
| 19 | + // +optional |
| 20 | + ProjectRef *xpv1.Reference `json:"projectRef,omitempty"` |
| 21 | + |
| 22 | + // ProjectSelector selects reference to a Project used to ProjectRef |
| 23 | + // +optional |
| 24 | + ProjectSelector *xpv1.Selector `json:"projectSelector,omitempty"` |
| 25 | + |
| 26 | + // Role is the role associated with the token. |
| 27 | + Role string `json:"role"` |
| 28 | + |
| 29 | + // ID is an id for the token |
| 30 | + // +optional |
| 31 | + ID string `json:"id"` |
| 32 | + |
| 33 | + // Description is a description for the token |
| 34 | + // +optional |
| 35 | + Description *string `json:"description,omitempty"` |
| 36 | + |
| 37 | + // Duration before the token will expire. Valid time units are `s`, `m`, `h` and `d` E.g. 12h, 7d. No expiration if not set. |
| 38 | + // +optional |
| 39 | + // +kubebuilder:validation:Pattern=`^(0|[0-9]+(s|m|h|d))$` |
| 40 | + ExpiresIn *string `json:"expiresIn,omitempty"` |
| 41 | + |
| 42 | + // Duration to control token regeneration based on token age. Valid time units are `s`, `m`, `h` and `d`. |
| 43 | + // +optional |
| 44 | + // +kubebuilder:validation:Pattern=`^([0-9]+)(s|m|h|d)$` |
| 45 | + RenewAfter *string `json:"renewAfter,omitempty"` |
| 46 | + |
| 47 | + // Duration to control token regeneration based on remaining token lifetime. Valid time units are `s`, `m`, `h` and `d`. |
| 48 | + // +optional |
| 49 | + // +kubebuilder:validation:Pattern=`^([0-9]+)(s|m|h|d)$` |
| 50 | + RenewBefore *string `json:"renewBefore,omitempty"` |
| 51 | +} |
| 52 | + |
| 53 | +// TokenObservation holds the issuedAt and expiresAt values of a token |
| 54 | +type TokenObservation struct { |
| 55 | + IssuedAt int64 `json:"iat"` |
| 56 | + // +optional |
| 57 | + ExpiresAt *int64 `json:"exp,omitempty"` |
| 58 | + // +optional |
| 59 | + ID *string `json:"id,omitempty"` |
| 60 | +} |
| 61 | + |
| 62 | +// A TokenSpec defines the desired state of an ArgoCD Token. |
| 63 | +type TokenSpec struct { |
| 64 | + xpv1.ResourceSpec `json:",inline"` |
| 65 | + ForProvider TokenParameters `json:"forProvider"` |
| 66 | +} |
| 67 | + |
| 68 | +// A TokenStatus represents the observed state of an ArgoCD Project Token. |
| 69 | +type TokenStatus struct { |
| 70 | + xpv1.ResourceStatus `json:",inline"` |
| 71 | + AtProvider TokenObservation `json:"atProvider,omitempty"` |
| 72 | +} |
| 73 | + |
| 74 | +// +kubebuilder:object:root=true |
| 75 | + |
| 76 | +// A Token is a managed resource that represents an ArgoCD Project Token |
| 77 | +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" |
| 78 | +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" |
| 79 | +// +kubebuilder:printcolumn:name="PROJECT",type="string",JSONPath=".spec.forProvider.project" |
| 80 | +// +kubebuilder:printcolumn:name="ROLE",type="string",JSONPath=".spec.forProvider.role" |
| 81 | +// +kubebuilder:printcolumn:name="EXPIRES-AT",type="string",JSONPath=".status.atProvider.exp" |
| 82 | +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" |
| 83 | +// +kubebuilder:subresource:status |
| 84 | +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,argocd} |
| 85 | +type Token struct { |
| 86 | + metav1.TypeMeta `json:",inline"` |
| 87 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 88 | + |
| 89 | + Spec TokenSpec `json:"spec"` |
| 90 | + Status TokenStatus `json:"status,omitempty"` |
| 91 | +} |
| 92 | + |
| 93 | +// +kubebuilder:object:root=true |
| 94 | + |
| 95 | +// TokenList contains a list of Token items |
| 96 | +type TokenList struct { |
| 97 | + metav1.TypeMeta `json:",inline"` |
| 98 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 99 | + Items []Token `json:"items"` |
| 100 | +} |
0 commit comments