generated from giantswarm/template-app
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #4 from giantswarm/change-crd-spec
Change CRD spec for GiantSwarm Policy and rework controllers
- Loading branch information
Showing
26 changed files
with
586 additions
and
727 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2023. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package v1alpha1 contains API Schema definitions for the policy.giantswarm.io v1alpha1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=policy.giantswarm.io | ||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "policy.giantswarm.io", Version: "v1alpha1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
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,62 @@ | ||
/* | ||
Copyright 2023. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// PolicyExceptionSpec defines the desired state of PolicyException | ||
type PolicyExceptionSpec struct { | ||
// Policies defines the list of policies to be excluded | ||
Policies []string `json:"policies"` | ||
|
||
// Targes defines the list of target workloads where the exceptions will be applied | ||
Targets []Target `json:"targets"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:resource:shortName=gspolex | ||
//+kubebuilder:subresource:status | ||
|
||
// PolicyException is the Schema for the policyexceptions API | ||
type PolicyException struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec PolicyExceptionSpec `json:"spec,omitempty"` | ||
} | ||
|
||
// Target defines a resource to which a PolicyException applies | ||
type Target struct { | ||
Namespaces []string `json:"namespaces"` | ||
Names []string `json:"names"` | ||
Kind string `json:"kind"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// PolicyExceptionList contains a list of PolicyException | ||
type PolicyExceptionList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []PolicyException `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&PolicyException{}, &PolicyExceptionList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
config/crd/bases/policy.giantswarm.io_policyexceptions.yaml
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,75 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.12.0 | ||
name: policyexceptions.policy.giantswarm.io | ||
spec: | ||
group: policy.giantswarm.io | ||
names: | ||
kind: PolicyException | ||
listKind: PolicyExceptionList | ||
plural: policyexceptions | ||
shortNames: | ||
- gspolex | ||
singular: policyexception | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: PolicyException is the Schema for the policyexceptions API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: PolicyExceptionSpec defines the desired state of PolicyException | ||
properties: | ||
policies: | ||
description: Policies defines the list of policies to be excluded | ||
items: | ||
type: string | ||
type: array | ||
targets: | ||
description: Targes defines the list of target workloads where the | ||
exceptions will be applied | ||
items: | ||
description: Target defines a resource to which a PolicyException | ||
applies | ||
properties: | ||
kind: | ||
type: string | ||
names: | ||
items: | ||
type: string | ||
type: array | ||
namespaces: | ||
items: | ||
type: string | ||
type: array | ||
required: | ||
- kind | ||
- names | ||
- namespaces | ||
type: object | ||
type: array | ||
required: | ||
- policies | ||
- targets | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
Oops, something went wrong.