mirror of
https://github.com/hashicorp/terraform.git
synced 2026-03-21 10:00:09 -04:00
38 lines
956 B
Go
38 lines
956 B
Go
// Copyright IBM Corp. 2014, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package releaseauth
|
|
|
|
// Authenticator is a generic interface for interacting with types that authenticate
|
|
// an archive.
|
|
type Authenticator interface {
|
|
Authenticate() error
|
|
}
|
|
|
|
// All is a meta Authenticator that wraps other Authenticators and ensures they all
|
|
// return without failure.
|
|
type All struct {
|
|
Authenticator
|
|
authenticators []Authenticator
|
|
}
|
|
|
|
var _ Authenticator = All{}
|
|
|
|
// AllAuthenticators creates a meta Authenticator that ensures all the
|
|
// given Authenticators return without failure.
|
|
func AllAuthenticators(authenticators ...Authenticator) All {
|
|
return All{
|
|
authenticators: authenticators,
|
|
}
|
|
}
|
|
|
|
// Authenticate returns the first archive authentication failure from
|
|
// the list of Authenticators given.
|
|
func (a All) Authenticate() error {
|
|
for _, auth := range a.authenticators {
|
|
if err := auth.Authenticate(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|