Created
October 9, 2018 03:44
-
-
Save mattmoor/11e6046701bf86aa8cdaf0388767fbcd to your computer and use it in GitHub Desktop.
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
func (c *Reconciler) reconcileFoo(parent *Parent) error { | |
// Get the current state of the Foo | |
foo, getFooErr := c.fooLister.Foos(ns).Get(name) | |
if apierrs.IsNotFound(getFooErr) { | |
// If it doesn’t exist, create it. | |
foo, err = c.createFoo(parent) | |
if err != nil { | |
return err | |
} | |
} else if getFooErr != nil { | |
return getFooErr | |
} | |
// If it does exist, make sure it matches our desired state. | |
if desired := resources.MakeFoo(parent); desired != foo { | |
foo, err = c.updateFoo(parent, desired) | |
if err != nil { | |
return err | |
} | |
} | |
// Lastly, reflect the status of the Foo in our own. | |
parent.Status.PropagateFooStatus(foo) | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment