// Decode returns a gob encoded representation of the Instance Identity Password
Decode returns a gob encoded representation of the Instance Identity Password
// Decode returns a gob encoded representation of the Instance Identity Password
func (iip *InstanceIdentityPassword) Decode(s string) error {
	compressedPassword, err := base64.StdEncoding.DecodeString(s)
	if err != nil {
		return fmt.Errorf("could not decode password: %w", err)
	}
	decomp, err := gzip.NewReader(bytes.NewBuffer(compressedPassword))
	if err != nil {
		return fmt.Errorf("could not create gzip decompressor: %w", err)
	}
	limitedDecomp := io.LimitReader(decomp, 2*1024*1024)
	decodedPassword := &bytes.Buffer{}
	_, err = io.Copy(decodedPassword, limitedDecomp)
	if err != nil {
		return fmt.Errorf("could not copy decompressed bytes: :%w", err)
	}
	if err := decomp.Close(); err != nil {
		return fmt.Errorf("could not close decompressor: %w", err)
	}
	dec := gob.NewDecoder(bytes.NewBuffer(decodedPassword.Bytes()))
	err = dec.Decode(iip)
	if err != nil {
		return fmt.Errorf("could not decode gob password: %w", err)
	}
	return nil
}
func ( iip * InstanceIdentityPassword ) Decode ( s string ) error { compressedPassword , err := base64 . StdEncoding . DecodeString ( s ) if err != nil { return fmt . Errorf ( " " , err ) } decomp , err := gzip . NewReader ( bytes . NewBuffer ( compressedPassword ) ) if err != nil { return fmt . Errorf ( " " , err ) } limitedDecomp := io . LimitReader ( decomp , 2 * 1024 * 1024 ) decodedPassword := & bytes . Buffer { } _ , err = io . Copy ( decodedPassword , limitedDecomp ) if err != nil { return fmt . Errorf ( " " , err ) } if err := decomp . Close ( ) ; err != nil { return fmt . Errorf ( " " , err ) } dec := gob . NewDecoder ( bytes . NewBuffer ( decodedPassword . Bytes ( ) ) ) err = dec . Decode ( iip ) if err != nil { return fmt . Errorf ( " " , err ) } return nil }
Decode returns a gob encoded representation of the Instance Identity Password
Decode returns a gob encoded representation of the Instance Identity Password