imgtype: check earlier for expected manifest type
imgtype: check earlier for expected manifest type

imgtype has a --expected-manifest-type option; the intention
seems to be to fail if the given image is not of the expected
type. This was not actually working as intended: the user-
specified expected-type was being trusted prematurely and
used to set state inappropriately.

Solution: check earlier, and bail if actual != expected.

There's quite a bit of duplicate code which I think can be
refactored here but it's probably ok to defer that for
the proverbial rainy day.

Fixes: #1951

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2006
Approved by: TomSweeneyRedHat

TomSweeneyRedHat/buildah,nalind/buildah-1,projectatomic/buildah,TomSweeneyRedHat/buildah,rhatdan/buildah,nalind/buildah,rhatdan/buildah,nalind/buildah-1,nalind/buildah-1,nalind/buildah,projectatomic/buildah,rhatdan/buildah,TomSweeneyRedHat/buildah,projectatomic/buildah