-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from vshn/add/policy
Add policy management
- Loading branch information
Showing
53 changed files
with
1,919 additions
and
58 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
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,29 @@ | ||
package v1 | ||
|
||
import ( | ||
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// Updating returns a Ready condition where the service is updating. | ||
func Updating() xpv1.Condition { | ||
return xpv1.Condition{ | ||
Type: xpv1.TypeReady, | ||
Status: corev1.ConditionFalse, | ||
Reason: "Updating", | ||
Message: "The service is being updated", | ||
LastTransitionTime: metav1.Now(), | ||
} | ||
} | ||
|
||
// Disabled returns a Ready condition where the service is disabled. | ||
func Disabled() xpv1.Condition { | ||
return xpv1.Condition{ | ||
Type: xpv1.TypeReady, | ||
Status: corev1.ConditionFalse, | ||
Reason: "Disabled", | ||
Message: "The service is disabled", | ||
LastTransitionTime: metav1.Now(), | ||
} | ||
} |
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,72 @@ | ||
package v1 | ||
|
||
import ( | ||
"reflect" | ||
|
||
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Policy{}, &PolicyList{}) | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" | ||
// +kubebuilder:printcolumn:name="Synced",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" | ||
// +kubebuilder:printcolumn:name="External Name",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" | ||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:scope=Cluster,categories={crossplane,minio} | ||
// +kubebuilder:webhook:verbs=create;update,path=/validate-minio-crossplane-io-v1-policy,mutating=false,failurePolicy=fail,groups=minio.crossplane.io,resources=policies,versions=v1,name=policies.minio.crossplane.io,sideEffects=None,admissionReviewVersions=v1 | ||
|
||
type Policy struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec PolicySpec `json:"spec"` | ||
Status PolicyStatus `json:"status,omitempty"` | ||
} | ||
|
||
type PolicySpec struct { | ||
xpv1.ResourceSpec `json:",inline"` | ||
ForProvider PolicyParameters `json:"forProvider,omitempty"` | ||
} | ||
|
||
type PolicyStatus struct { | ||
xpv1.ResourceStatus `json:",inline"` | ||
AtProvider PolicyProviderStatus `json:"atProvider,omitempty"` | ||
} | ||
|
||
type PolicyProviderStatus struct { | ||
// Policy contains the rendered policy in JSON format as it's applied on minio. | ||
Policy string `json:"policy,omitempty"` | ||
} | ||
|
||
type PolicyParameters struct { | ||
// AllowBucket will create a simple policy that allows all operations for the given bucket. | ||
// Mutually exclusive to `RawPolicy`. | ||
AllowBucket string `json:"allowBucket,omitempty"` | ||
|
||
// RawPolicy describes a raw S3 policy ad verbatim. | ||
// Please consult https://min.io/docs/minio/linux/administration/identity-access-management/policy-based-access-control.html for more details about the policy. | ||
// Mutually exclusive to `AllowBucket`. | ||
RawPolicy string `json:"rawPolicy,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
type PolicyList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Policy `json:"items"` | ||
} | ||
|
||
// Dummy type metadata. | ||
var ( | ||
PolicyKind = reflect.TypeOf(Policy{}).Name() | ||
PolicyGroupKind = schema.GroupKind{Group: Group, Kind: PolicyKind}.String() | ||
PolicyKindAPIVersion = PolicyKind + "." + SchemeGroupVersion.String() | ||
PolicyGroupVersionKind = SchemeGroupVersion.WithKind(PolicyKind) | ||
) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.