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

Add built image to image status #39

Merged
merged 4 commits into from
Jul 23, 2019

Conversation

djoyahoy
Copy link
Contributor

  • Add IsSuccess, IsFailure, and BuiltImage to Build type

closes #9

Signed-off-by: Joao Pereira jdealmeidapereira@pivotal.io

- Add IsSuccess, IsFailure, and BuiltImage to Build type

closes #9

Signed-off-by: Joao Pereira <jdealmeidapereira@pivotal.io>
@djoyahoy djoyahoy requested review from thisisnotashwin and matthewmcnew and removed request for thisisnotashwin July 22, 2019 20:32
@@ -55,6 +55,7 @@ type ImageBuild struct {
type ImageStatus struct {
duckv1alpha1.Status `json:",inline"`
LastBuildRef string `json:"lastBuildRef"`
LastBuiltImage string `json:"lastBuiltImage"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -21,9 +20,9 @@ func newBuildList(builds []*v1alpha1.Build) (buildList, error) {
buildList := buildList{}

for _, build := range builds {
if build.Status.GetCondition(duckv1alpha1.ConditionSucceeded).IsTrue() {
if build.IsSuccess() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice

@@ -148,6 +148,9 @@ func (c *Reconciler) Reconcile(ctx context.Context, key string) error {

image.Status.LastBuildRef = reconciledBuild.Build.BuildRef()
image.Status.BuildCounter = reconciledBuild.BuildCounter
if lastBuild.IsSuccess() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be moved to the reconciledBuild?
Perhaps a reconciledBuild.LatestImage?

That way the logic for an image.Status is recalculated on each reconcile even if it still utilizes the previous latestImage.

ObservedGeneration: originalGeneration,
},
LastBuildRef: "image-name-build-1",
LastBuiltImage: "some/image@some-sha",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we provide slightly more realistic example by including the "sha256"?

- Move LastImage reconciliation into reconcileBuild
Signed-off-by: Ashwin Venkatesh <avenkatesh@pivotal.io>
@thisisnotashwin
Copy link

Updated the field names to LatestBuildRef and LatestImage

Copy link

@thisisnotashwin thisisnotashwin left a comment

Choose a reason for hiding this comment

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

LGTM

if err != nil {
return nil, err
}
latestImage := im.Status.LatestImage
if latestBuild.IsSuccess() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you have a strong opinion on this?

Super subtle but, I find the imperative style a bit less reducible/more noisy.

thing = val
if
   thing= something-else
end 

Perhaps delegatable to?

image.currentLatestForImage(lastBuild)

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@matthewmcnew matthewmcnew left a comment

Choose a reason for hiding this comment

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

Looks good. I think the move to latestbuildRef.

One quick question

Signed-off-by: Ashwin Venkatesh <avenkatesh@pivotal.io>
@thisisnotashwin thisisnotashwin merged commit a77ad2a into master Jul 23, 2019
@thisisnotashwin thisisnotashwin deleted the add-last-successful-build-to-image branch July 30, 2019 13:01
@thisisnotashwin thisisnotashwin restored the add-last-successful-build-to-image branch July 30, 2019 13:02
@thisisnotashwin thisisnotashwin deleted the add-last-successful-build-to-image branch July 30, 2019 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resolve the built image for me
5 participants