Skip to content
Draft
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
2 changes: 2 additions & 0 deletions pkg/gitops/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
// order, and EdgeDependency.Module stays the signed principal the host
// resolves through its catalogue — never a name, binding id or release.
authority.InstallationRole = resolved.InstallationRole
authority.Setup = append([]modulecontract.ResolvedSetup(nil), resolved.Setup...)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

resolved.Setup undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

undefined: modulecontract.ResolvedSetup

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / control-integration

resolved.Setup undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / control-integration

undefined: modulecontract.ResolvedSetup

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / control-integration

authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / coverage

resolved.Setup undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / coverage

undefined: modulecontract.ResolvedSetup

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / coverage

authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (0)

resolved.Setup undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (0)

undefined: modulecontract.ResolvedSetup

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (0)

authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (1)

resolved.Setup undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (1)

undefined: modulecontract.ResolvedSetup

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (1)

authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (2)

resolved.Setup undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (2)

undefined: modulecontract.ResolvedSetup

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (2)

authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / lint

resolved.Setup undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method Setup)

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / lint

undefined: modulecontract.ResolvedSetup

Check failure on line 169 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / lint

authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)
authority.OwnerAwareResourceKinds = append([]string(nil), resolved.OwnerAwareResourceKinds...)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

resolved.OwnerAwareResourceKinds undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / control-integration

resolved.OwnerAwareResourceKinds undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / control-integration

authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / coverage

resolved.OwnerAwareResourceKinds undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / coverage

authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (0)

resolved.OwnerAwareResourceKinds undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (0)

authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (1)

resolved.OwnerAwareResourceKinds undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (1)

authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (2)

resolved.OwnerAwareResourceKinds undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / generate (2)

authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / lint

resolved.OwnerAwareResourceKinds undefined (type *"github.com/codefly-dev/core/contracts/module".Resolved has no field or method OwnerAwareResourceKinds)

Check failure on line 170 in pkg/gitops/authority.go

View workflow job for this annotation

GitHub Actions / lint

authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)
authority.EdgeDependencies = append([]modulecontract.EdgeDependency(nil), resolved.EdgeDependencies...)
authority.Queues = append([]string(nil), resolved.Queues...)
authority.Namespaces = append([]string(nil), resolved.Namespaces...)
Expand Down
12 changes: 11 additions & 1 deletion pkg/gitops/composition_delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@
// generation or another module. A nil declaration carries nothing, which is
// how a withdrawal keeps its Core-only identity.
func SignedAuthorityDocument(manifest *solutionhost.ModuleManifest, core, declaration []byte, signer solutionhost.Signer) (*compositionv1.SignedManifestV1, error) {
if declaration == nil {
hasResolved := !manifest.Removed && manifest.Authority != nil && (len(manifest.Authority.Setup) > 0 || len(manifest.Authority.OwnerAwareResourceKinds) > 0)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

manifest.Authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / control-integration

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / control-integration

manifest.Authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / coverage

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / coverage

manifest.Authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (0)

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (0)

manifest.Authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (1)

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (1)

manifest.Authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (2)

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (2)

manifest.Authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / lint

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 219 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / lint

manifest.Authority.Setup undefined (type *solutionhost.Authority has no field or method Setup)
if declaration == nil && !hasResolved {
return nil, nil
}
if signer == nil {
Expand All @@ -226,6 +227,15 @@
if err := proto.Unmarshal(declaration, &policy); err != nil {
return nil, err
}
// Setup requirements need resolved callees. Use the Core-resolved carrier
// already captured by native run or publish, never reparse or re-resolve here.
policy.Setup, policy.OwnerAwareResourceKinds = nil, nil

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

policy.OwnerAwareResourceKinds undefined (type compositionv1.AuthorityManifestV1 has no field or method OwnerAwareResourceKinds)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

policy.Setup undefined (type compositionv1.AuthorityManifestV1 has no field or method Setup)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / control-integration

policy.OwnerAwareResourceKinds undefined (type compositionv1.AuthorityManifestV1 has no field or method OwnerAwareResourceKinds)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / control-integration

policy.Setup undefined (type compositionv1.AuthorityManifestV1 has no field or method Setup)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / coverage

policy.OwnerAwareResourceKinds undefined (type compositionv1.AuthorityManifestV1 has no field or method OwnerAwareResourceKinds)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / coverage

policy.Setup undefined (type compositionv1.AuthorityManifestV1 has no field or method Setup)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (0)

policy.OwnerAwareResourceKinds undefined (type compositionv1.AuthorityManifestV1 has no field or method OwnerAwareResourceKinds)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (0)

policy.Setup undefined (type compositionv1.AuthorityManifestV1 has no field or method Setup)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (1)

policy.OwnerAwareResourceKinds undefined (type compositionv1.AuthorityManifestV1 has no field or method OwnerAwareResourceKinds)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (1)

policy.Setup undefined (type compositionv1.AuthorityManifestV1 has no field or method Setup)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (2)

policy.OwnerAwareResourceKinds undefined (type compositionv1.AuthorityManifestV1 has no field or method OwnerAwareResourceKinds)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (2)

policy.Setup undefined (type compositionv1.AuthorityManifestV1 has no field or method Setup)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / lint

policy.OwnerAwareResourceKinds undefined (type compositionv1.AuthorityManifestV1 has no field or method OwnerAwareResourceKinds)

Check failure on line 232 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / lint

policy.Setup undefined (type compositionv1.AuthorityManifestV1 has no field or method Setup)
if hasResolved {
policy.OwnerAwareResourceKinds = append([]string(nil), manifest.Authority.OwnerAwareResourceKinds...)

Check failure on line 234 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / bootstrap-audit

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 234 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / control-integration

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 234 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / coverage

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 234 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (0)

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 234 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (1)

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 234 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / generate (2)

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)

Check failure on line 234 in pkg/gitops/composition_delivery.go

View workflow job for this annotation

GitHub Actions / lint

manifest.Authority.OwnerAwareResourceKinds undefined (type *solutionhost.Authority has no field or method OwnerAwareResourceKinds)
for _, entry := range manifest.Authority.Setup {
policy.Setup = append(policy.Setup, &compositionv1.SetupGrantV1{Binding: entry.Binding, Methods: append([]string(nil), entry.Methods...), Scopes: append([]string(nil), entry.Scopes...)})
}
}
policy.Module, policy.Generation, policy.CoreManifestDigest = manifest.Alias, manifest.Generation, delivery.Digest(core)
document, err := proto.MarshalOptions{Deterministic: true}.Marshal(&policy)
if err != nil {
Expand Down
37 changes: 37 additions & 0 deletions pkg/gitops/paired_installation_agreement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,40 @@ func TestNilAndEmptyEdgesAgree(t *testing.T) {

_ = context.Background()
}

func TestResolvedSetupAndOwnerKindsSurviveSignedDelivery(t *testing.T) {
conn, peer := pairedConnection(t)
signer := nativeSigner(t)
composition := NewCompositionDelivery(conn, signer,
func(context.Context, string) ([]*compositionv1.MethodPolicyV1, bool, error) { return nil, false, nil },
func(context.Context, string) ([]*authorityv1.WorkScopeV1, error) { return nil, nil },
func(context.Context, string) ([]*compositionv1.RoleV1, error) { return nil, nil },
func(context.Context, string) (bool, error) { return false, nil }, nil)
d := &NativeDeliverer{Signer: signer, StateDir: t.TempDir(), Prepare: composition.Prepare, Token: func(string) (string, error) { return "credential", nil }}
m := pairedManifest()
m.Authority = &solutionhost.Authority{Principal: m.Alias, Setup: []modulecontract.ResolvedSetup{{Binding: "schemas", Methods: []string{"/store.v1.Store/Define"}, Scopes: []string{"records.types:define"}}}, OwnerAwareResourceKinds: []string{"example.items"}}
_, err := d.Deliver(t.Context(), m)
require.NoError(t, err)
requests := peer.requests()
require.Len(t, requests, 1)
request := requests[0]
require.NotNil(t, request.Authority)
manifest, err := solutionhost.ManifestFromVerified(request.Carrier.Document)
require.NoError(t, err)
var policy compositionv1.AuthorityManifestV1
require.NoError(t, proto.Unmarshal(request.Authority.Document, &policy))
require.Equal(t, m.Authority.OwnerAwareResourceKinds, policy.OwnerAwareResourceKinds)
require.Len(t, policy.Setup, 1)
require.Equal(t, "schemas", policy.Setup[0].Binding)
require.Equal(t, m.Authority.Setup[0].Methods, policy.Setup[0].Methods)
require.Equal(t, m.Authority.Setup[0].Scopes, policy.Setup[0].Scopes)
doc := documentOf(t, request.Authority.Document, manifest)
doc.CoreManifestDigest = policy.CoreManifestDigest
doc.OwnerAwareResourceKinds = policy.OwnerAwareResourceKinds
for _, entry := range policy.Setup {
doc.Setup = append(doc.Setup, modulecontract.ResolvedSetup{Binding: entry.Binding, Methods: entry.Methods, Scopes: entry.Scopes})
}
require.NoError(t, delivered.Pair(doc, request.Carrier.Document, manifest))
doc.Setup[0].Methods = []string{"/store.v1.Store/Other"}
require.Error(t, delivered.Pair(doc, request.Carrier.Document, manifest), "equal permission cannot hide changed exact method")
}
Loading