Merge "Fixed TODO in package config"
This commit is contained in:
commit
eaa66fded7
@ -239,3 +239,31 @@ func (e ErrUnknownManagementType) Error() string {
|
|||||||
return fmt.Sprintf("Unknown management type '%s'. Known types include '%s' and '%s'.", e.Type,
|
return fmt.Sprintf("Unknown management type '%s'. Known types include '%s' and '%s'.", e.Type,
|
||||||
redfish.ClientType, redfishdell.ClientType)
|
redfish.ClientType, redfishdell.ClientType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrMissingManifestName is returned when manifest name is empty
|
||||||
|
type ErrMissingManifestName struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrMissingManifestName) Error() string {
|
||||||
|
return "missing manifest name"
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrMissingFlag is returned when flag is not provided
|
||||||
|
type ErrMissingFlag struct {
|
||||||
|
FlagName string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrMissingFlag) Error() string {
|
||||||
|
return fmt.Sprintf("missing flag, specify a --%s to embed", e.FlagName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrCheckFile is returned if there is error when checking file on FS
|
||||||
|
type ErrCheckFile struct {
|
||||||
|
FlagName string
|
||||||
|
Path string
|
||||||
|
InternalErr error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrCheckFile) Error() string {
|
||||||
|
return fmt.Sprintf("could not read %s data from '%s': %v", e.FlagName, e.Path, e.InternalErr)
|
||||||
|
}
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"opendev.org/airship/airshipctl/pkg/errors"
|
"opendev.org/airship/airshipctl/pkg/errors"
|
||||||
@ -77,8 +76,6 @@ type ManifestOptions struct {
|
|||||||
// is possible to create (and validate) these objects without using the command
|
// is possible to create (and validate) these objects without using the command
|
||||||
// line.
|
// line.
|
||||||
|
|
||||||
// TODO(howell): strongly type the errors in this file
|
|
||||||
|
|
||||||
// Validate checks for the possible authentication values and returns
|
// Validate checks for the possible authentication values and returns
|
||||||
// Error when invalid value or incompatible choice of values given
|
// Error when invalid value or incompatible choice of values given
|
||||||
func (o *AuthInfoOptions) Validate() error {
|
func (o *AuthInfoOptions) Validate() error {
|
||||||
@ -162,10 +159,14 @@ func (o *ClusterOptions) Validate() error {
|
|||||||
|
|
||||||
func checkExists(flagName, path string) error {
|
func checkExists(flagName, path string) error {
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return fmt.Errorf("you must specify a --%s to embed", flagName)
|
return ErrMissingFlag{FlagName: flagName}
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(path); err != nil {
|
if _, err := os.Stat(path); err != nil {
|
||||||
return fmt.Errorf("could not read %s data from '%s': %v", flagName, path, err)
|
return ErrCheckFile{
|
||||||
|
FlagName: flagName,
|
||||||
|
Path: path,
|
||||||
|
InternalErr: err,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -174,10 +175,10 @@ func checkExists(flagName, path string) error {
|
|||||||
// Error when invalid value or incompatible choice of values given
|
// Error when invalid value or incompatible choice of values given
|
||||||
func (o *ManifestOptions) Validate() error {
|
func (o *ManifestOptions) Validate() error {
|
||||||
if o.Name == "" {
|
if o.Name == "" {
|
||||||
return fmt.Errorf("you must specify a non-empty Manifest name")
|
return ErrMissingManifestName{}
|
||||||
}
|
}
|
||||||
if o.RemoteRef != "" {
|
if o.RemoteRef != "" {
|
||||||
return fmt.Errorf("repository checkout by RemoteRef is not yet implemented\n%w", errors.ErrNotImplemented{})
|
return errors.ErrNotImplemented{What: "repository checkout by RemoteRef"}
|
||||||
}
|
}
|
||||||
if o.IsPrimary && o.RepoName == "" {
|
if o.IsPrimary && o.RepoName == "" {
|
||||||
return ErrMissingRepositoryName{}
|
return ErrMissingRepositoryName{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user