You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
terraform/internal/releaseauth/all.go

39 lines
956 B

// 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
}