Skip to content

Commit

Permalink
Merge pull request #382 from nullable-eth/fix-auth-anno
Browse files Browse the repository at this point in the history
fix auth annotation not being enabled on v1
  • Loading branch information
nullable-eth committed Oct 5, 2023
2 parents b2ae9b4 + f31f32c commit 343e602
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions internal/xpkg/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (

"github.com/crossplane/crossplane-runtime/pkg/errors"
pkgmetav1 "github.com/crossplane/crossplane/apis/pkg/meta/v1"
v1alpha1 "github.com/crossplane/crossplane/apis/pkg/meta/v1alpha1"
"github.com/crossplane/crossplane/apis/pkg/v1beta1"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"gopkg.in/yaml.v2"
crd "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer/json"

Expand Down Expand Up @@ -197,16 +197,15 @@ func (b *Builder) Build(ctx context.Context, opts ...BuildOpt) (v1.Image, runtim
linter = NewFunctionLinter()
case pkgmetav1.ProviderKind:
if b.ab != nil { // if we have an auth.yaml file
if p, ok := meta.(*v1alpha1.Provider); ok {
// if has annotation auth.upbound.io/group then look for the object
// specified there like aws.upbound.io and annotate that with auth.upbound.io/config
// and embed the contents of the auth.yaml file
if group, ok := p.ObjectMeta.Annotations[authMetaAnno]; ok {
if p, ok := meta.(metav1.Object); ok {
if group, ok := p.GetAnnotations()[authMetaAnno]; ok {
// if we found an annotation auth.upbound.io/group then look for the object
// specified there like aws.upbound.io and annotate that with auth.upbound.io/config
// and embed the contents of the auth.yaml file
ar, err := b.ab.Init(ctx)
if err != nil {
return nil, nil, errors.Wrap(err, errParseAuth)
}

// validate the auth.yaml file
var auth AuthExtension
if err := yaml.NewDecoder(ar).Decode(&auth); err != nil {
Expand Down

0 comments on commit 343e602

Please sign in to comment.