Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group alias references #39

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions apis/identity/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions apis/identity/v1alpha1/zz_generated.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions apis/identity/v1alpha1/zz_groupalias_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions config/common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright 2021 The Crossplane Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package common

import (
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
"github.com/crossplane/crossplane-runtime/pkg/reference"
"github.com/crossplane/crossplane-runtime/pkg/resource"
)

const (
// SelfPackagePath is the golang path for this package.
SelfPackagePath = "github.com/upbound/provider-vault/config/common"

// AccessorExtractor is the golang path to ExtractAccessor function
// in this package.
AccessorExtractor = SelfPackagePath + ".ExtractAccessor()"
)


// ExtractAccessor extracts accessor ID of the resources from "status.atProvider.accessor"
func ExtractAccessor() reference.ExtractValueFn {
return func(mg resource.Managed) string {
paved, err := fieldpath.PaveObject(mg)
if err != nil {
return ""
}
r, err := paved.GetString("status.atProvider.accessor")
if err != nil {
return ""
}
return r
}
}
16 changes: 15 additions & 1 deletion config/vault/config.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
package vault

import "github.com/upbound/upjet/pkg/config"
import (
"github.com/upbound/provider-vault/config/common"
"github.com/upbound/upjet/pkg/config"
)

// ConfigureNamespace configures the namespace resource.
func Configure(p *config.Provider) {
p.AddResourceConfigurator("vault_namespace", func(r *config.Resource) {
r.Kind = "VaultNamespace"
r.ShortGroup = "vault"
})
p.AddResourceConfigurator("vault_identity_group_alias", func(r *config.Resource) {
r.Kind = "GroupAlias"
r.ShortGroup = "identity"
r.References["canonical_id"] = config.Reference{
Type: "Group",
}
r.References["mount_accessor"] = config.Reference{
Type: "github.com/upbound/provider-vault/apis/jwt/v1alpha1.AuthBackend",
Extractor: common.AccessorExtractor,
}
})
}
8 changes: 6 additions & 2 deletions examples-generated/identity/groupalias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ metadata:
name: group-alias
spec:
forProvider:
canonicalId: ${vault_identity_group.group.id}
mountAccessor: ${vault_auth_backend.github.accessor}
canonicalIdSelector:
matchLabels:
testing.upbound.io/example-name: group
mountAccessorSelector:
matchLabels:
testing.upbound.io/example-name: github
name: Github_Team_Slug

---
Expand Down
Loading