mirror of https://github.com/docker/compose.git
warn user remote resource is disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
a345515f91
commit
fe8c2780c8
|
@ -252,29 +252,17 @@ func (o *ProjectOptions) ToProject(dockerCli command.Cli, services []string, po
|
|||
}
|
||||
|
||||
func (o *ProjectOptions) configureRemoteLoaders(dockerCli command.Cli, po []cli.ProjectOptionsFn) ([]cli.ProjectOptionsFn, error) {
|
||||
enabled, err := remote.GitRemoteLoaderEnabled()
|
||||
git, err := remote.NewGitRemoteLoader(o.Offline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if enabled {
|
||||
git, err := remote.NewGitRemoteLoader(o.Offline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
po = append(po, cli.WithResourceLoader(git))
|
||||
}
|
||||
|
||||
enabled, err = remote.OCIRemoteLoaderEnabled()
|
||||
oci, err := remote.NewOCIRemoteLoader(dockerCli, o.Offline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if enabled {
|
||||
git, err := remote.NewOCIRemoteLoader(dockerCli, o.Offline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
po = append(po, cli.WithResourceLoader(git))
|
||||
}
|
||||
|
||||
po = append(po, cli.WithResourceLoader(git), cli.WithResourceLoader(oci))
|
||||
return po, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/adrg/xdg"
|
||||
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
"github.com/compose-spec/compose-go/loader"
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
|
@ -34,8 +33,10 @@ import (
|
|||
"github.com/moby/buildkit/util/gitutil"
|
||||
)
|
||||
|
||||
func GitRemoteLoaderEnabled() (bool, error) {
|
||||
if v := os.Getenv("COMPOSE_EXPERIMENTAL_GIT_REMOTE"); v != "" {
|
||||
const GIT_REMOTE_ENABLED = "COMPOSE_EXPERIMENTAL_GIT_REMOTE"
|
||||
|
||||
func gitRemoteLoaderEnabled() (bool, error) {
|
||||
if v := os.Getenv(GIT_REMOTE_ENABLED); v != "" {
|
||||
enabled, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("COMPOSE_EXPERIMENTAL_GIT_REMOTE environment variable expects boolean value: %w", err)
|
||||
|
@ -74,6 +75,14 @@ func (g gitRemoteLoader) Accept(path string) bool {
|
|||
var commitSHA = regexp.MustCompile(`^[a-f0-9]{40}$`)
|
||||
|
||||
func (g gitRemoteLoader) Load(ctx context.Context, path string) (string, error) {
|
||||
enabled, err := gitRemoteLoaderEnabled()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !enabled {
|
||||
return "", fmt.Errorf("experimental git remote resource is disabled. %q must be set", GIT_REMOTE_ENABLED)
|
||||
}
|
||||
|
||||
ref, err := gitutil.ParseGitRef(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -26,17 +26,18 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/adrg/xdg"
|
||||
"github.com/compose-spec/compose-go/loader"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/docker/buildx/store/storeutil"
|
||||
"github.com/docker/buildx/util/imagetools"
|
||||
"github.com/docker/cli/cli/command"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
"github.com/compose-spec/compose-go/loader"
|
||||
)
|
||||
|
||||
func OCIRemoteLoaderEnabled() (bool, error) {
|
||||
if v := os.Getenv("COMPOSE_EXPERIMENTAL_OCI_REMOTE"); v != "" {
|
||||
const OCI_REMOTE_ENABLED = "COMPOSE_EXPERIMENTAL_OCI_REMOTE"
|
||||
|
||||
func ociRemoteLoaderEnabled() (bool, error) {
|
||||
if v := os.Getenv(OCI_REMOTE_ENABLED); v != "" {
|
||||
enabled, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("COMPOSE_EXPERIMENTAL_OCI_REMOTE environment variable expects boolean value: %w", err)
|
||||
|
@ -76,6 +77,14 @@ func (g ociRemoteLoader) Accept(path string) bool {
|
|||
}
|
||||
|
||||
func (g ociRemoteLoader) Load(ctx context.Context, path string) (string, error) {
|
||||
enabled, err := ociRemoteLoaderEnabled()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !enabled {
|
||||
return "", fmt.Errorf("experimental OCI remote resource is disabled. %q must be set", OCI_REMOTE_ENABLED)
|
||||
}
|
||||
|
||||
if g.offline {
|
||||
return "", nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue