Skip to content

Commit

Permalink
refactor(puller/config): rename methods handling artifact config layer
Browse files Browse the repository at this point in the history
Signed-off-by: Aldo Lacuku <[email protected]>
  • Loading branch information
alacuku committed Nov 16, 2023
1 parent 4594749 commit 4456697
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/artifact/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (o *artifactConfigOptions) RunArtifactConfig(ctx context.Context, args []st
return fmt.Errorf("invalid platform format: %s", o.platform)
}

if config, err = puller.PullConfigLayer(ctx, ref, tokens[0], tokens[1]); err != nil {
if config, err = puller.RawConfigLayer(ctx, ref, tokens[0], tokens[1]); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/artifact/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (o *artifactInstallOptions) RunArtifactInstall(ctx context.Context, args []
return nil, err
}

artifactConfig, err := puller.GetArtifactConfig(ctx, ref, runtime.GOOS, runtime.GOARCH)
artifactConfig, err := puller.ArtifactConfig(ctx, ref, runtime.GOOS, runtime.GOARCH)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/follower/follower.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (f *Follower) follow(ctx context.Context) {
f.logger.Info("Found new artifact version", f.logger.Args("followerName", f.ref, "tag", f.tag))

// Pull config layer to check falco versions
artifactConfig, err := f.GetArtifactConfig(ctx, f.ref, runtime.GOOS, runtime.GOARCH)
artifactConfig, err := f.ArtifactConfig(ctx, f.ref, runtime.GOOS, runtime.GOARCH)
if err != nil {
f.logger.Error("Unable to pull config layer", f.logger.Args("followerName", f.ref, "reason", err.Error()))
return
Expand Down
10 changes: 5 additions & 5 deletions pkg/oci/puller/puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ func (p *Puller) RawManifest(ctx context.Context, ref, os, arch string) ([]byte,
return manifestBytes, nil
}

// GetArtifactConfig fetches only the config layer from a given ref.
// ArtifactConfig fetches only the config layer from a given ref.
// If the artifact has a v1.MediaTypeImageIndex descriptor then it fetches the config layer for the
// specified platform.
func (p *Puller) GetArtifactConfig(ctx context.Context, ref, os, arch string) (*oci.ArtifactConfig, error) {
configBytes, err := p.PullConfigLayer(ctx, ref, os, arch)
func (p *Puller) ArtifactConfig(ctx context.Context, ref, os, arch string) (*oci.ArtifactConfig, error) {
configBytes, err := p.RawConfigLayer(ctx, ref, os, arch)
if err != nil {
return nil, err
}
Expand All @@ -252,10 +252,10 @@ func (p *Puller) GetArtifactConfig(ctx context.Context, ref, os, arch string) (*
return &artifactConfig, nil
}

// PullConfigLayer fetches only the config layer from a given ref.
// RawConfigLayer fetches only the config layer from a given ref.
// If the artifact has a v1.MediaTypeImageIndex descriptor then it fetches the config layer for the
// specified platform.
func (p *Puller) PullConfigLayer(ctx context.Context, ref, os, arch string) ([]byte, error) {
func (p *Puller) RawConfigLayer(ctx context.Context, ref, os, arch string) ([]byte, error) {
repo, err := repository.NewRepository(ref, repository.WithClient(p.Client), repository.WithPlainHTTP(p.plainHTTP))
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/oci/puller/puller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ var _ = Describe("Puller", func() {
})
})

Context("PullConfigLayer func", func() {
Context("RawConfigLayer func", func() {
var (
ref string
os string
Expand All @@ -154,7 +154,7 @@ var _ = Describe("Puller", func() {
)
JustBeforeEach(func() {
puller = ocipuller.NewPuller(authn.NewClient(authn.WithCredentials(&auth.EmptyCredential)), plainHTTP, tracker)
cfgLayer, err = puller.PullConfigLayer(ctx, ref, os, arch)
cfgLayer, err = puller.RawConfigLayer(ctx, ref, os, arch)
})

JustAfterEach(func() {
Expand Down

0 comments on commit 4456697

Please sign in to comment.