@ -33,6 +33,31 @@ type Interface interface {
AuthorizeSSHRekey ( ctx context . Context , token string ) ( * ssh . Certificate , [ ] SignOption , error )
AuthorizeSSHRekey ( ctx context . Context , token string ) ( * ssh . Certificate , [ ] SignOption , error )
}
}
// Disabled represents a disabled provisioner. Disabled provisioners are created
// when the Init methods fails.
type Disabled struct {
Interface
Reason error
}
// MarshalJSON returns the JSON encoding of the provisioner with the disabled
// reason.
func ( p Disabled ) MarshalJSON ( ) ( [ ] byte , error ) {
provisionerJSON , err := json . Marshal ( p . Interface )
if err != nil {
return nil , err
}
reasonJSON , err := json . Marshal ( struct {
Disabled bool ` json:"disabled" `
DisabledReason string ` json:"disabledReason" `
} { true , p . Reason . Error ( ) } )
if err != nil {
return nil , err
}
reasonJSON [ 0 ] = ','
return append ( provisionerJSON [ : len ( provisionerJSON ) - 1 ] , reasonJSON ... ) , nil
}
// ErrAllowTokenReuse is an error that is returned by provisioners that allows
// ErrAllowTokenReuse is an error that is returned by provisioners that allows
// the reuse of tokens.
// the reuse of tokens.
//
//