mirror of
https://github.com/docker/compose.git
synced 2025-07-30 17:14:13 +02:00
extract method to reduce cyclomatic complexity
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
fe8c2780c8
commit
599e4b242a
@ -108,8 +108,22 @@ func (g ociRemoteLoader) Load(ctx context.Context, path string) (string, error)
|
|||||||
local := filepath.Join(g.cache, descriptor.Digest.Hex())
|
local := filepath.Join(g.cache, descriptor.Digest.Hex())
|
||||||
composeFile := filepath.Join(local, "compose.yaml")
|
composeFile := filepath.Join(local, "compose.yaml")
|
||||||
if _, err = os.Stat(local); os.IsNotExist(err) {
|
if _, err = os.Stat(local); os.IsNotExist(err) {
|
||||||
|
var manifest v1.Manifest
|
||||||
|
err = json.Unmarshal(content, &manifest)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
err = os.MkdirAll(local, 0o700)
|
s, err2 := g.pullComposeFiles(ctx, local, composeFile, manifest, ref, resolver)
|
||||||
|
if err2 != nil {
|
||||||
|
return s, err2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return composeFile, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g ociRemoteLoader) pullComposeFiles(ctx context.Context, local string, composeFile string, manifest v1.Manifest, ref reference.Named, resolver *imagetools.Resolver) (string, error) {
|
||||||
|
err := os.MkdirAll(local, 0o700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -120,12 +134,6 @@ func (g ociRemoteLoader) Load(ctx context.Context, path string) (string, error)
|
|||||||
}
|
}
|
||||||
defer f.Close() //nolint:errcheck
|
defer f.Close() //nolint:errcheck
|
||||||
|
|
||||||
var manifest v1.Manifest
|
|
||||||
err = json.Unmarshal(content, &manifest)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
if manifest.ArtifactType != "application/vnd.docker.compose.project" {
|
if manifest.ArtifactType != "application/vnd.docker.compose.project" {
|
||||||
return "", fmt.Errorf("%s is not a compose project OCI artifact, but %s", ref.String(), manifest.ArtifactType)
|
return "", fmt.Errorf("%s is not a compose project OCI artifact, but %s", ref.String(), manifest.ArtifactType)
|
||||||
}
|
}
|
||||||
@ -150,8 +158,7 @@ func (g ociRemoteLoader) Load(ctx context.Context, path string) (string, error)
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return "", nil
|
||||||
return composeFile, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ loader.ResourceLoader = ociRemoteLoader{}
|
var _ loader.ResourceLoader = ociRemoteLoader{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user