Skip to content

Commit 0d077b2

Browse files
Add & Implement PolicyReport API for gatekeeper policies (#188)
Signed-off-by: Arnob kumar saha <[email protected]>
1 parent becd47a commit 0d077b2

File tree

1,424 files changed

+603074
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,424 files changed

+603074
-19
lines changed

.config/api-rules/violation_exceptions.list

+6-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,CertificateS
140140
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,CertificateSpec,EmailAddresses
141141
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,CertificateSpec,IPAddresses
142142
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,CertificateSpec,URIs
143+
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,ImageInfo,Lineages
144+
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,Lineage,Chain
145+
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,Lineage,Containers
146+
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,PullCredentials,SecretRefs
143147
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,TLSConfig,Certificates
144148
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,X509Subject,Countries
145149
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,X509Subject,Localities
@@ -148,7 +152,8 @@ API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,X509Subject,
148152
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,X509Subject,PostalCodes
149153
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,X509Subject,Provinces
150154
API rule violation: list_type_missing,kmodules.xyz/client-go/api/v1,X509Subject,StreetAddresses
151-
API rule violation: list_type_missing,kubeops.dev/ui-server/apis/identity/v1alpha1,UserInfo,Groups
155+
API rule violation: list_type_missing,kubeops.dev/ui-server/apis/policy/v1alpha1,Constraint,Violations
156+
API rule violation: list_type_missing,kubeops.dev/ui-server/apis/policy/v1alpha1,PolicyReportResponse,Constraints
152157
API rule violation: names_match,k8s.io/api/core/v1,AzureDiskVolumeSource,DataDiskURI
153158
API rule violation: names_match,k8s.io/api/core/v1,ContainerStatus,LastTerminationState
154159
API rule violation: names_match,k8s.io/api/core/v1,DaemonEndpoint,Port

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ COMPRESS ?= no
2626
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
2727
CRD_OPTIONS ?= "crd:crdVersions={v1},allowDangerousTypes=true"
2828
CODE_GENERATOR_IMAGE ?= appscode/gengo:release-1.25
29-
API_GROUPS ?= identity:v1alpha1
29+
API_GROUPS ?= identity:v1alpha1 policy:v1alpha1
3030

3131
# Where to push the docker image.
3232
REGISTRY ?= ghcr.io/appscode

apis/identity/v1alpha1/openapi_generated.go

+130-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/policy/fuzzer/fuzzer.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package fuzzer
18+
19+
import (
20+
"kubeops.dev/ui-server/apis/policy/v1alpha1"
21+
22+
fuzz "github.com/google/gofuzz"
23+
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
24+
)
25+
26+
// Funcs returns the fuzzer functions for this api group.
27+
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
28+
return []interface{}{
29+
// v1alpha1
30+
func(s *v1alpha1.PolicyReport, c fuzz.Continue) {
31+
c.FuzzNoCustom(s) // fuzz self without calling this function again
32+
},
33+
}
34+
}

apis/policy/install/install.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package install
18+
19+
import (
20+
"kubeops.dev/ui-server/apis/policy/v1alpha1"
21+
22+
"k8s.io/apimachinery/pkg/runtime"
23+
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
24+
)
25+
26+
// Install registers the API group and adds types to a scheme
27+
func Install(scheme *runtime.Scheme) {
28+
utilruntime.Must(v1alpha1.AddToScheme(scheme))
29+
}

apis/policy/install/roundtrip_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package install
18+
19+
import (
20+
"testing"
21+
22+
policyfuzzer "kubeops.dev/ui-server/apis/policy/fuzzer"
23+
24+
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
25+
)
26+
27+
func TestRoundTripTypes(t *testing.T) {
28+
roundtrip.RoundTripTestForAPIGroup(t, Install, policyfuzzer.Funcs)
29+
// TODO: enable protobuf generation for the sample-apiserver
30+
// roundtrip.RoundTripProtobufTestForAPIGroup(t, Install, identityfuzzer.Funcs)
31+
}

apis/policy/v1alpha1/doc.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1alpha1 contains API Schema definitions for the identity v1alpha1 API group
18+
19+
// +k8s:openapi-gen=true
20+
// +k8s:deepcopy-gen=package
21+
// +k8s:defaulter-gen=TypeMeta
22+
// +groupName=policy.k8s.appscode.com
23+
package v1alpha1 // import "kubeops.dev/ui-server/apis/policy/v1alpha1"
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Copyright AppsCode Inc. and Contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
const GroupName = "policy.k8s.appscode.com"

0 commit comments

Comments
 (0)