-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bug] fix bug where verify status gets overwritten (#136)
* fix bug where verify status gets overwritten * add ociregistry adapter for oci for acr compatability
- Loading branch information
1 parent
e01cfd6
commit a430648
Showing
8 changed files
with
152 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package helm | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
helm_registry "helm.sh/helm/v3/pkg/registry" | ||
"oras.land/oras-go/v2/registry/remote" | ||
"oras.land/oras-go/v2/registry/remote/auth" | ||
"oras.land/oras-go/v2/registry/remote/credentials" | ||
"oras.land/oras-go/v2/registry/remote/retry" | ||
) | ||
|
||
type OCIRegistryClient struct { | ||
client RegistryClient | ||
PlainHTTP bool | ||
} | ||
|
||
func NewOCIRegistryClient(client RegistryClient, plainHTTP bool) *OCIRegistryClient { | ||
return &OCIRegistryClient{ | ||
client: client, | ||
PlainHTTP: plainHTTP, | ||
} | ||
} | ||
|
||
func (c *OCIRegistryClient) Pull(ref string, opts ...helm_registry.PullOption) (*helm_registry.PullResult, error) { | ||
return c.client.Pull(ref, opts...) | ||
} | ||
|
||
func (c *OCIRegistryClient) Push(chart []byte, destination string, opts ...helm_registry.PushOption) (*helm_registry.PushResult, error) { | ||
return c.client.Push(chart, destination, opts...) | ||
} | ||
|
||
func (c *OCIRegistryClient) Tags(ref string) ([]string, error) { | ||
ref = strings.TrimPrefix(strings.TrimSuffix(ref, "/"), "oci://") | ||
repo, err := remote.NewRepository(ref) | ||
if err != nil { | ||
return []string{}, err | ||
} | ||
repo.PlainHTTP = c.PlainHTTP | ||
|
||
storeOpts := credentials.StoreOptions{} | ||
credStore, err := credentials.NewStoreFromDocker(storeOpts) | ||
if err != nil { | ||
return []string{}, err | ||
} | ||
repo.Client = &auth.Client{ | ||
Client: retry.DefaultClient, | ||
Cache: auth.NewCache(), | ||
Credential: credentials.Credential(credStore), // Use the credentials store | ||
} | ||
|
||
vs := []string{} | ||
err = repo.Tags(context.TODO(), "", func(tags []string) error { | ||
vs = append(vs, tags...) | ||
return nil | ||
}) | ||
if err != nil { | ||
return []string{}, err | ||
} | ||
|
||
return vs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package helm | ||
|
||
import ( | ||
"go.uber.org/fx" | ||
"helm.sh/helm/v3/pkg/repo" | ||
) | ||
|
||
type IndexFileLoader interface { | ||
LoadIndexFile(indexFilePath string) (*repo.IndexFile, error) | ||
} | ||
|
||
type DefaultIndexFileLoader struct{} | ||
|
||
func (d *DefaultIndexFileLoader) LoadIndexFile(indexFilePath string) (*repo.IndexFile, error) { | ||
return repo.LoadIndexFile(indexFilePath) | ||
} | ||
|
||
var IndexFileLoaderModule = fx.Provide(FunctionLoader{LoadFunc: repo.LoadIndexFile}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package helm | ||
|
||
import ( | ||
"go.uber.org/fx" | ||
helm_registry "helm.sh/helm/v3/pkg/registry" | ||
) | ||
|
||
// Define the interface for the registry client | ||
type RegistryClient interface { | ||
Pull(ref string, opts ...helm_registry.PullOption) (*helm_registry.PullResult, error) | ||
Push(chart []byte, destination string, opts ...helm_registry.PushOption) (*helm_registry.PushResult, error) | ||
Tags(ref string) ([]string, error) | ||
} | ||
|
||
// Default registry client provider | ||
func NewDefaultRegistryClient() (RegistryClient, error) { | ||
plainHTTP := false | ||
debug := false | ||
|
||
return NewRegistryClient(plainHTTP, debug) | ||
} | ||
|
||
func NewRegistryClient(plainHTTP, debug bool) (RegistryClient, error) { | ||
opts := []helm_registry.ClientOption{} | ||
if plainHTTP { | ||
opts = append(opts, helm_registry.ClientOptPlainHTTP()) | ||
} | ||
if debug { | ||
opts = append(opts, helm_registry.ClientOptDebug(true)) | ||
} | ||
return helm_registry.NewClient(opts...) | ||
} | ||
|
||
var RegistryModule = fx.Provide(NewDefaultRegistryClient) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters