MCPcopy
hub / github.com/harness/harness / proxyInternal

Function proxyInternal

registry/app/pkg/base/wrapper.go:61–100  ·  view source on GitHub ↗
(
	ctx context.Context,
	registryDao store.RegistryRepository,
	f func(registry registrytypes.Registry, a pkg.Artifact) response.Response,
	info pkg.PackageArtifactInfo,
	useUpstream bool,
)

Source from the content-addressed store, hash-verified

59}
60
61func proxyInternal(
62 ctx context.Context,
63 registryDao store.RegistryRepository,
64 f func(registry registrytypes.Registry, a pkg.Artifact) response.Response,
65 info pkg.PackageArtifactInfo,
66 useUpstream bool,
67) (response.Response, error) {
68 var r response.Response
69 requestRepoKey := info.BaseArtifactInfo().RegIdentifier
70 registries, skipped, err := filterRegs(ctx, registryDao, requestRepoKey, info, useUpstream)
71 if err != nil {
72 return r, err
73 }
74
75 for _, registry := range registries {
76 log.Ctx(ctx).Info().Msgf("Using Registry: %s, Type: %s", registry.Name, registry.Type)
77 art := GetArtifactRegistry(registry)
78 if art != nil {
79 r = f(registry, art)
80 if r.GetError() == nil {
81 return r, nil
82 }
83 log.Ctx(ctx).Warn().Msgf("Repository: %s, Type: %s, error: %v", registry.Name, registry.Type,
84 r.GetError())
85 }
86 }
87
88 if !pkg.IsEmpty(skipped) {
89 var skippedRegNames []string
90 for _, registry := range skipped {
91 skippedRegNames = append(skippedRegNames, registry.Name)
92 }
93 return r, errors.InvalidArgument("no matching artifacts found in registry %s, skipped registries: [%s] "+
94 "due to allowed/blocked policies",
95 requestRepoKey, pkg.JoinWithSeparator(", ", skippedRegNames...))
96 }
97
98 //todo: fix error message
99 return r, errors.NotFound("no matching artifacts found in registry %s", requestRepoKey)
100}
101
102func factory(key string) pkg.Artifact {
103 return TypeRegistry[key]

Callers 2

NoProxyWrapperFunction · 0.85
ProxyWrapperFunction · 0.85

Calls 11

GetErrorMethod · 0.95
IsEmptyFunction · 0.92
InvalidArgumentFunction · 0.92
JoinWithSeparatorFunction · 0.92
NotFoundFunction · 0.92
filterRegsFunction · 0.85
GetArtifactRegistryFunction · 0.85
MsgfMethod · 0.80
BaseArtifactInfoMethod · 0.65
InfoMethod · 0.65
WarnMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…