Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: WIP add control etc crds #46

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module github.com/kubescape/storage

go 1.21.3
go 1.21.5

require (
github.com/anchore/syft v0.97.1
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/softwarecomposition/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&SBOMSyftList{},
&SBOMSyftFiltered{},
&SBOMSyftFilteredList{},
&Framework{},
&FrameworkList{},
&Control{},
&ControlList{},
&Rule{},
&RuleList{},
&Exception{},
&ExceptionList{},
&ControlConfiguration{},
&ControlConfigurationList{},
)
return nil
}
102 changes: 102 additions & 0 deletions pkg/apis/softwarecomposition/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package softwarecomposition

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -596,3 +597,104 @@ type SBOMSyftFilteredList struct {

Items []SBOMSyftFiltered
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Framework struct {
metav1.TypeMeta
metav1.ObjectMeta
ControlsRef []FrameworkControlRef
Payload unstructured.Unstructured
}

type FrameworkControlRef struct {
Name string
ControlID string
Kind string
ApiVersion string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type FrameworkList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Framework
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Control struct {
metav1.TypeMeta
metav1.ObjectMeta
RulesRef []ControlRuleRef
Payload unstructured.Unstructured
}

type ControlRuleRef struct {
Name string
Kind string
ApiVersion string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ControlList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Control
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Rule struct {
metav1.TypeMeta
metav1.ObjectMeta
Rego string
Payload unstructured.Unstructured
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type RuleList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Rule
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Exception struct {
metav1.TypeMeta
metav1.ObjectMeta
Payload unstructured.Unstructured
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ExceptionList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Exception
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ControlConfiguration struct {
metav1.TypeMeta
metav1.ObjectMeta
Payload unstructured.Unstructured
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ControlConfigurationList struct {
metav1.TypeMeta
metav1.ListMeta
Items []ControlConfiguration
}
Copy link
Collaborator

@vladklokun vladklokun Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: fix line endings in PR

Please see the sign after this line. It indicates that the files have improper line endings at the end: they don’t have the terminating \n characters. I believe it’s because you’re using Visual Studio Code or some other IDE that terminates the files with Windows line endings.

Please refer to this issue: microsoft/vscode#141169

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this,

also the fact that VSC does this is just concerning, I'd at least hope to have my tooling follow standards :(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that’s a common problem. Nonetheless, we could always add a Git pre-commit hook to fix the line endings automatically or a linter to complain about it. But as you can imagine, this is very low on our priorities list :)

10 changes: 10 additions & 0 deletions pkg/apis/softwarecomposition/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&SBOMSyftList{},
&SBOMSyftFiltered{},
&SBOMSyftFilteredList{},
&Framework{},
&FrameworkList{},
&Control{},
&ControlList{},
&Rule{},
&RuleList{},
&Exception{},
&ExceptionList{},
&ControlConfiguration{},
&ControlConfigurationList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
102 changes: 102 additions & 0 deletions pkg/apis/softwarecomposition/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -572,3 +573,104 @@ type SBOMSyftFilteredList struct {

Items []SBOMSyftFiltered `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Framework struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
ControlsRef []FrameworkControlRef `json:"controlsRef,omitempty" protobuf:"bytes,2,opt,name=controlsRef"`
Payload unstructured.Unstructured `json:"payload,omitempty" protobuf:"bytes,3,opt,name=payload"`
}

type FrameworkControlRef struct {
Name string `json:"name,omitempty"`
ControlID string `json:"controlID,omitempty"`
Kind string `json:"kind,omitempty"`
ApiVersion string `json:"apiVersion,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type FrameworkList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Items []Framework `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Control struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
RulesRef []ControlRuleRef `json:"rulesRef,omitempty" protobuf:"bytes,2,opt,name=rulesRef"`
Payload unstructured.Unstructured `json:"payload,omitempty" protobuf:"bytes,3,opt,name=payload"`
}

type ControlRuleRef struct {
Name string `json:"name,omitempty"`
Kind string `json:"kind,omitempty"`
ApiVersion string `json:"apiVersion,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ControlList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Items []Control `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Rule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Rego string `json:"rego,omitempty" protobuf:"bytes,2,opt,name=rego"`
Payload unstructured.Unstructured `json:"payload,omitempty" protobuf:"bytes,3,opt,name=payload"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type RuleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Items []Rule `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Exception struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Payload unstructured.Unstructured `json:"payload,omitempty" protobuf:"bytes,2,opt,name=payload"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ExceptionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Items []Exception `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ControlConfiguration struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Payload unstructured.Unstructured `json:"payload,omitempty" protobuf:"bytes,2,opt,name=payload"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type ControlConfigurationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Items []ControlConfiguration `json:"items" protobuf:"bytes,2,rep,name=items"`
}
Loading