This repository was archived by the owner on Oct 14, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -23,22 +23,29 @@ import (
2323// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2424// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525
26+ // TargetType defines the Type of the Target
27+ // +kubebuilder:validation:Enum=Host;IPRange;Domain
28+ type TargetType string
29+
2630// TargetSpec defines the desired state of Target
2731type TargetSpec struct {
2832 // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
2933 // Important: Run "make" to regenerate code after modifying this file
34+ Type TargetType `json:"type,omitempty"`
3035
3136 // Foo is an example field of Target. Edit Target_types.go to remove/update
32- Foo string `json:"foo ,omitempty"`
37+ Address string `json:"address ,omitempty"`
3338}
3439
3540// TargetStatus defines the observed state of Target
3641type TargetStatus struct {
3742 // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
3843 // Important: Run "make" to regenerate code after modifying this file
44+ State string `json:"state,omitempty"`
3945}
4046
4147// +kubebuilder:object:root=true
48+ // +kubebuilder:subresource:status
4249
4350// Target is the Schema for the targets API
4451type Target struct {
Original file line number Diff line number Diff line change @@ -38,11 +38,32 @@ type TargetReconciler struct {
3838// +kubebuilder:rbac:groups=scans.experimental.securecodebox.io,resources=targets/status,verbs=get;update;patch
3939
4040func (r * TargetReconciler ) Reconcile (req ctrl.Request ) (ctrl.Result , error ) {
41- _ = context .Background ()
42- _ = r .Log .WithValues ("target" , req .NamespacedName )
41+ ctx : = context .Background ()
42+ log : = r .Log .WithValues ("target" , req .NamespacedName )
4343
4444 // your logic here
4545
46+ log .Info ("Starting Target Reconciler" )
47+
48+ var target scansv1.Target
49+ err := r .Get (ctx , req .NamespacedName , & target )
50+ if err != nil {
51+ return ctrl.Result {}, client .IgnoreNotFound (err )
52+ }
53+
54+ if target .Status .State == "" {
55+ target .Status .State = "Scanning"
56+ }
57+ switch target .Status .State {
58+ case "Scanning" :
59+ switch target .Spec .Type {
60+ case "Host" :
61+
62+ }
63+ case "Sleeping" :
64+ // TODO: Reschedule
65+ }
66+
4667 return ctrl.Result {}, nil
4768}
4869
You can’t perform that action at this time.
0 commit comments