Skip to content

Commit cc397fb

Browse files
Merge pull request #36 from derek10cloud/faet/remove-current-provider-version
feat: add methods to remove existing provider version and clear provi…
2 parents 210c896 + 4815e31 commit cc397fb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

anysdk/registry.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ type RegistryAPI interface {
5050
GetServiceDocBytes(string) ([]byte, error)
5151
GetResourcesRegisterDocBytes(string) ([]byte, error)
5252
LoadProviderByName(string, string) (Provider, error)
53+
RemoveProviderVersion(string, string) error
54+
ClearProviderCache(string) error
5355
}
5456

5557
type RegistryConfig struct {
@@ -692,3 +694,17 @@ func (r *Registry) getLatestPublishedVersion(providerName string) (string, error
692694
}
693695
return latestVersion, nil
694696
}
697+
698+
// RemoveProviderVersion removes a specific version of a provider
699+
// e.g) RemoveProviderVersion("googleapis.com", "v23.09.00169")
700+
func (r *Registry) RemoveProviderVersion(providerId string, version string) error {
701+
providerPath := path.Join(r.getLocalDocRoot(), providerId, version)
702+
return os.RemoveAll(providerPath)
703+
}
704+
705+
// ClearProviderCache clears the cache for a specific provider
706+
// e.g) ClearProviderCache("aws")
707+
func (r *Registry) ClearProviderCache(providerId string) error {
708+
cachePath := path.Join(r.getLocalDocRoot(), providerId)
709+
return os.RemoveAll(cachePath)
710+
}

0 commit comments

Comments
 (0)