func NewImageRepoDetails(contentOrPath string) (o *ImageRepoDetails, err error) {
	if contentOrPath == "" {
		return o, nil
	}
	data := []byte(contentOrPath)
	isPath, err := fileExists(contentOrPath)
	if err == nil && isPath {
		logger.Debugf("reading image repository information from %q", contentOrPath)
		data, err = ioutil.ReadFile(contentOrPath)
		if err != nil {
			return nil, errors.Trace(err)
		}
	}
	o = &ImageRepoDetails{}
	err = json.Unmarshal(data, o)
	if err != nil {
		logger.Tracef("unmarshalling %q, err %#v", contentOrPath, err)
		return &ImageRepoDetails{Repository: contentOrPath}, nil
	}

	if err = o.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	if err = o.init(); err != nil {
		return nil, errors.Trace(err)
	}
	return o, nil
}
// NewImageRepoDetails tries to parse a file path or file content and returns an instance of ImageRepoDetails.
NewImageRepoDetails tries to parse a file path or file content and returns an instance of ImageRepoDetails.
// NewImageRepoDetails tries to parse a file path or file content and returns an instance of ImageRepoDetails .
func NewImageRepoDetails(contentOrPath string) (o *ImageRepoDetails, err error) {
	if contentOrPath == "" {
		return o, nil
	}
	data := []byte(contentOrPath)
	isPath, err := fileExists(contentOrPath)
	if err == nil && isPath {
		logger.Debugf("reading image repository information from %q", contentOrPath)
		data, err = ioutil.ReadFile(contentOrPath)
		if err != nil {
			return nil, errors.Trace(err)
		}
	}
	o = &ImageRepoDetails{}
	err = json.Unmarshal(data, o)
	if err != nil {
		logger.Tracef("unmarshalling %q, err %#v", contentOrPath, err)
		return &ImageRepoDetails{Repository: contentOrPath}, nil
	}
	if err = o.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	if err = o.init(); err != nil {
		return nil, errors.Trace(err)
	}
	return o, nil
}
func NewImageRepoDetails ( contentOrPath string ) ( o * ImageRepoDetails , err error ) { if contentOrPath == " " { return o , nil } data := [ ] byte ( contentOrPath ) isPath , err := fileExists ( contentOrPath ) if err == nil && isPath { logger . Debugf ( " " , contentOrPath ) data , err = ioutil . ReadFile ( contentOrPath ) if err != nil { return nil , errors . Trace ( err ) } } o = & ImageRepoDetails { } err = json . Unmarshal ( data , o ) if err != nil { logger . Tracef ( " " , contentOrPath , err ) return & ImageRepoDetails { Repository : contentOrPath } , nil } if err = o . Validate ( ) ; err != nil { return nil , errors . Trace ( err ) } if err = o . init ( ) ; err != nil { return nil , errors . Trace ( err ) } return o , nil }
NewImageRepoDetails tries to parse a file path or file content and returns an instance of ImageRepoDetails.
NewImageRepoDetails tries to parse a file path or file content and returns an instance of ImageRepoDetails .