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

removing left behind scaffold todos and fixing misspelling #212

Merged
merged 5 commits into from
May 3, 2019
Merged
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 keps/0004-add-testing-infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ As a repository owner, I don't want to have to validate the execution of common
* Are new tests required for all (code) PRs? If fixing a bug, it's re-assuring if you can provide a test that demonstrates it not working,
but the level of effort is significantly increased to push code. This might be counter productive in trying to encourage
developers from contributing.
* Being able to run the "Test Frameworks" on a runninging cluster might provide value (e.g. sonobouy), but requires a maturation
* Being able to run the "Test Frameworks" on a running cluster might provide value (e.g. sonobouy), but requires a maturation
of that capability and might not be worth the effort

### Risks and Mitigations
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/kudo/v1alpha1/framework_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// FrameworkSpec defines the desired state of Framework
type FrameworkSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/source"
)

/**
* USER ACTION REQUIRED: This is a scaffold file intended for the user to modify with their own Controller
* business logic. Delete these comments after modifying this file.*
*/

// Add creates a new FrameworkVersion Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
// and Start it when the Manager is Started.
// USER ACTION REQUIRED: update cmd/manager/main.go to call this kudo.Add(mgr) to install this Controller
Expand Down Expand Up @@ -93,8 +88,6 @@ func (r *ReconcileFrameworkVersion) Reconcile(request reconcile.Request) (reconc
}

log.Printf("FrameworkVersionController: Recieved Reconcile request for a frameworkversion named: %v", request.Name)
//When this is changed, we need to Reconcile all instances objects that reference this
//object.

//TODO Validate FrameworkVersion is appropriate
return reconcile.Result{}, nil
Expand Down
26 changes: 12 additions & 14 deletions pkg/controller/instance/instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/source"
)

/**
* USER ACTION REQUIRED: This is a scaffold file intended for the user to modify with their own Controller
* business logic. Delete these comments after modifying this file.*
*/

// Add creates a new Instance Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
// and Start it when the Manager is Started.
// USER ACTION REQUIRED: update cmd/manager/main.go to call this kudo.Add(mgr) to install this Controller
Expand Down Expand Up @@ -204,20 +199,20 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
//New Instances should have Deploy called
CreateFunc: func(e event.CreateEvent) bool {
log.Printf("InstanceController: Received create event for an instance named: %v", e.Meta.GetName())
new := e.Object.(*kudov1alpha1.Instance)
instance := e.Object.(*kudov1alpha1.Instance)

//get the new FrameworkVersion object
//get the instance FrameworkVersion object
fv := &kudov1alpha1.FrameworkVersion{}
err = mgr.GetClient().Get(context.TODO(),
types.NamespacedName{
Name: new.Spec.FrameworkVersion.Name,
Namespace: new.Spec.FrameworkVersion.Namespace,
Name: instance.Spec.FrameworkVersion.Name,
Namespace: instance.Spec.FrameworkVersion.Namespace,
},
fv)
if err != nil {
log.Printf("InstanceController: Error getting frameworkversion \"%v\" for instance \"%v\": %v",
new.Spec.FrameworkVersion.Name,
new.Name,
instance.Spec.FrameworkVersion.Name,
instance.Name,
err)
//TODO
//We probably want to handle this differently and mark this instance as unhealthy
Expand All @@ -231,9 +226,9 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
return false
}

err = createPlan(mgr, planName, new)
err = createPlan(mgr, planName, instance)
if err != nil {
log.Printf("InstanceController: Error creating \"%v\" object for \"%v\": %v", planName, new.Name, err)
log.Printf("InstanceController: Error creating \"%v\" object for \"%v\": %v", planName, instance.Name, err)
}
return err == nil
},
Expand Down Expand Up @@ -279,7 +274,10 @@ func createPlan(mgr manager.Manager, planName string, instance *kudov1alpha1.Ins
},
}
//Make this instance the owner of the PlanExecution
controllerutil.SetControllerReference(instance, &planExecution, mgr.GetScheme())
if err := controllerutil.SetControllerReference(instance, &planExecution, mgr.GetScheme()); err != nil {
log.Printf("InstanceController: Error setting ControllerReference")
return err
}
//new!
if err := mgr.GetClient().Create(context.TODO(), &planExecution); err != nil {
log.Printf("InstanceController: Error creating planexecution \"%v\": %v", planExecution.Name, err)
Expand Down
10 changes: 0 additions & 10 deletions pkg/controller/planexecution/planexecution_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ import (

const basePath = "/kustomize"

/**
* USER ACTION REQUIRED: This is a scaffold file intended for the user to modify with their own Controller
* business logic. Delete these comments after modifying this file.*
*/

// Add creates a new PlanExecution Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller
// and Start it when the Manager is Started.
// USER ACTION REQUIRED: update cmd/manager/main.go to call this kudo.Add(mgr) to install this Controller
Expand Down Expand Up @@ -118,9 +113,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {

// 'UpdateFunc' and 'CreateFunc' used to judge if a event about the object is
// what we want. If that is true, the event will be processed by the reconciler.

//PlanExecutions should be mostly immutable. Updates should only

p := predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
log.Printf("PlanExecutionController: Recieved update event for an instance named: %v", e.MetaNew.GetName())
Expand Down Expand Up @@ -201,7 +194,6 @@ type ReconcilePlanExecution struct {

// Reconcile reads that state of the cluster for a PlanExecution object and makes changes based on the state read
// and what is in the PlanExecution.Spec
// TODO(user): Modify this Reconcile function to implement your Controller logic. The scaffolding writes
// a Deployment as an example
// Automatically generate RBAC rules to allow the Controller to read and write Deployments
// +kubebuilder:rbac:groups=apps,resources=deployments;statefulsets,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -232,7 +224,6 @@ func (r *ReconcilePlanExecution) Reconcile(request reconcile.Request) (reconcile
},
instance)
if err != nil {
//TODO how to handle errors.
//Can't find the instance. Update sta
r.recorder.Event(planExecution, "Warning", "InvalidInstance", fmt.Sprintf("Could not find required instance (%v)", planExecution.Spec.Instance.Name))
planExecution.Status.State = kudov1alpha1.PhaseStateError
Expand Down Expand Up @@ -286,7 +277,6 @@ func (r *ReconcilePlanExecution) Reconcile(request reconcile.Request) (reconcile
},
frameworkVersion)
if err != nil {
//TODO how to handle errors.
//Can't find the instance. Update sta
planExecution.Status.State = kudov1alpha1.PhaseStateError
r.recorder.Event(planExecution, "Warning", "InvalidFrameworkVersion", fmt.Sprintf("Could not find FrameworkVersion %v", instance.Spec.FrameworkVersion.Name))
Expand Down