Skip to content

Conversation

@umohnani8
Copy link
Member

Need it in kpod pull and kpod load. These commands need all the manifests, so took out the length checking block from loadTarManifest.

Signed-off-by: umohnani8 umohnani@redhat.com

@umohnani8
Copy link
Member Author

@rhatdan PTAL

@rhatdan
Copy link
Member

rhatdan commented Jul 18, 2017

We are going to need similar functionality to this to get the tags out of the oci image spec.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Just adding the method to Source is a much better than my proposal of splitting Source into two.

Still, loadTarManifest should be split into two: “just load everything” and “load + check that there is only one manifest”.

return nil, errors.Wrap(err, "Error decoding tar manifest.json")
}
if len(items) != 1 {
return nil, errors.Errorf("Unexpected tar manifest.json: expected 1 item, got %d", len(items))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check should remain in place when using Source as a types.ImageSource backend.

Copy link
Member

Choose a reason for hiding this comment

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

Can we move it to the other function? The only one that calls this? Then we would only have one loadmanafest function.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mtrmac I added the error check in ensureCachedDataIsPresent() after loadTarManifest() is being called.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That’s better, sure.

}

// LoadTarManifest loads and decodes the manifest.json
func (s *Source) LoadTarManifest() ([]manifestItem, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it acceptable to return a private type from a public function? AFAIK the caller won’t be able to refer to the type in parameter/return value declarations.

(If it works for you, fine; just make sure that it does.)

Copy link
Member

Choose a reason for hiding this comment

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

It is working in her current code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup it works fine. I looked it up and a private type can be accessed from an exported function, but the private type can't be created outside its own package.

@mtrmac
Copy link
Collaborator

mtrmac commented Jul 19, 2017

👍

Approved with PullApprove

Need it in kpod pull and kpod load. These commands need all the manifests, so took out the length checking block from loadTarManifest.

Signed-off-by: umohnani8 <umohnani@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Jul 19, 2017

@runcom PTAL

@runcom
Copy link
Member

runcom commented Jul 19, 2017

LGTM

Approved with PullApprove

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.

4 participants