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

Remove the managed resource providerConfig query (for now) #40

Merged
merged 1 commit into from
Apr 11, 2021
Merged
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
125 changes: 98 additions & 27 deletions internal/graph/generated/generated.go

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

4 changes: 2 additions & 2 deletions internal/graph/model/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ func TestGetKubernetesResource(t *testing.T) {
ID: ReferenceID{Name: "cool"},
Metadata: &ObjectMeta{Name: "cool"},
Spec: &ManagedResourceSpec{
ProviderConfigReference: &xpv1.Reference{Name: "pr"},
DeletionPolicy: &dp,
ProviderConfigRef: &ProviderConfigReference{Name: "pr"},
DeletionPolicy: &dp,
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions internal/graph/model/generated.go

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

15 changes: 12 additions & 3 deletions internal/graph/model/managed.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (

// A ManagedResourceSpec specifies the desired state of a managed resource.
type ManagedResourceSpec struct {
ProviderConfigRef *ProviderConfigReference `json:"providerConfigRef"`
DeletionPolicy *DeletionPolicy `json:"deletionPolicy"`

WritesConnectionSecretToReference *xpv1.SecretReference
ProviderConfigReference *xpv1.Reference
DeletionPolicy *DeletionPolicy `json:"deletionPolicy"`
}

// GetDeletionPolicy from the supplied Crossplane policy.
Expand All @@ -29,6 +30,14 @@ func GetDeletionPolicy(p xpv1.DeletionPolicy) *DeletionPolicy {
}
}

// GetProviderConfigReference from the supplied Crossplane reference.
func GetProviderConfigReference(in *xpv1.Reference) *ProviderConfigReference {
if in == nil {
return nil
}
return &ProviderConfigReference{Name: in.Name}
}

// GetManagedResourceStatus from the supplied Crossplane resource.
func GetManagedResourceStatus(in *unstructured.Managed) *ManagedResourceStatus {
c := in.GetConditions()
Expand All @@ -53,7 +62,7 @@ func GetManagedResource(u *kunstructured.Unstructured) ManagedResource {
Metadata: GetObjectMeta(mg),
Spec: &ManagedResourceSpec{
WritesConnectionSecretToReference: mg.GetWriteConnectionSecretToReference(),
ProviderConfigReference: mg.GetProviderConfigReference(),
ProviderConfigRef: GetProviderConfigReference(mg.GetProviderConfigReference()),
DeletionPolicy: GetDeletionPolicy(mg.GetDeletionPolicy()),
},
Status: GetManagedResourceStatus(mg),
Expand Down
4 changes: 2 additions & 2 deletions internal/graph/model/managed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func TestGetManagedResource(t *testing.T) {
Name: "cool",
},
Spec: &ManagedResourceSpec{
ProviderConfigReference: &xpv1.Reference{Name: "coolprov"},
WritesConnectionSecretToReference: &xpv1.SecretReference{Name: "coolsecret"},
ProviderConfigRef: &ProviderConfigReference{Name: "coolprov"},
DeletionPolicy: &orphan,
WritesConnectionSecretToReference: &xpv1.SecretReference{Name: "coolsecret"},
},
Status: &ManagedResourceStatus{
Conditions: []Condition{{}},
Expand Down
7 changes: 0 additions & 7 deletions internal/graph/resolvers/managed.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,3 @@ func (r *managedResourceSpec) ConnectionSecret(ctx context.Context, obj *model.M
out := model.GetSecret(s)
return &out, nil
}

func (r *managedResourceSpec) ProviderConfig(ctx context.Context, obj *model.ManagedResourceSpec) (*model.ProviderConfig, error) {
// TODO(negz): How can we resolve this? We only know the name of the config,
// not its apiVersion and kind. I can't immediately think of an approach
// that isn't hacky and/or expensive.
return nil, nil
}
10 changes: 9 additions & 1 deletion schema/managed.gql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type ManagedResourceSpec {
The provider configuration configures how this managed resource interacts
with an external system.
"""
providerConfig: ProviderConfig @goField(forceResolver: true)
providerConfigRef: ProviderConfigReference

"""
The deletion policy specifies what will happen to the underlying external
Expand All @@ -51,6 +51,14 @@ type ManagedResourceSpec {
deletionPolicy: DeletionPolicy
}

"""
A reference to the ProviderConfig used by a particular managed resource.
"""
type ProviderConfigReference {
"Name of the provider config."
name: String!
}

"""
A DeletionPolicy specifies what will happen to the underlying external resource
when this managed resource is deleted - either "Delete" or "Orphan" the external
Expand Down