Class: Igniter::Lang::SchemaCompatibilityDiagnostic
- Inherits:
-
Object
- Object
- Igniter::Lang::SchemaCompatibilityDiagnostic
- Defined in:
- lib/igniter/lang/schema_compatibility_diagnostic.rb
Constant Summary collapse
- SEMANTICS =
{ report_only: true, runtime_enforced: false, migration_execution_authorized: false, ledger_core: false }.freeze
- REQUIRED_EVIDENCE_LINKS =
%i[ compatibility_report_ref semantic_image_ref loaded_schema_descriptor_ref ].freeze
- REQUIRED_MIGRATION_PROFILE_KEYS =
%i[ migration_receipt_ref replaces_image_id replacement_semantic_image_ref replacement_schema_fingerprint loaded_schema_fingerprint migration_chain replacement_image_lifecycle migration_receipt_lifecycle packet_links post_migration_report_ref post_migration_schema_decision post_migration_compatibility_decision ].freeze
- REQUIRED_PACKET_LINKS =
%i[ replaces caused_by produced_by produced_in has_supersedes ].freeze
- DECISIONS =
%i[trusted provisional migrating blocked].freeze
Instance Attribute Summary collapse
-
#compatibility_decision ⇒ Object
readonly
Returns the value of attribute compatibility_decision.
-
#contract_ref ⇒ Object
readonly
Returns the value of attribute contract_ref.
-
#diagnostic_id ⇒ Object
readonly
Returns the value of attribute diagnostic_id.
-
#evidence_links ⇒ Object
readonly
Returns the value of attribute evidence_links.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#migration_available ⇒ Object
readonly
Returns the value of attribute migration_available.
-
#migration_profile ⇒ Object
readonly
Returns the value of attribute migration_profile.
-
#migration_ref ⇒ Object
readonly
Returns the value of attribute migration_ref.
-
#new_schema_fingerprint ⇒ Object
readonly
Returns the value of attribute new_schema_fingerprint.
-
#new_schema_version ⇒ Object
readonly
Returns the value of attribute new_schema_version.
-
#old_schema_fingerprint ⇒ Object
readonly
Returns the value of attribute old_schema_fingerprint.
-
#old_schema_version ⇒ Object
readonly
Returns the value of attribute old_schema_version.
-
#profile_cases ⇒ Object
readonly
Returns the value of attribute profile_cases.
-
#schema_check_outcome ⇒ Object
readonly
Returns the value of attribute schema_check_outcome.
Instance Method Summary collapse
- #blocked? ⇒ Boolean
-
#initialize(diagnostic_id:, contract_ref:, old_schema_version:, new_schema_version:, old_schema_fingerprint:, new_schema_fingerprint:, schema_check_outcome:, migration_available:, compatibility_decision:, evidence_links:, migration_ref: nil, migration_profile: nil, metadata: {}) ⇒ SchemaCompatibilityDiagnostic
constructor
A new instance of SchemaCompatibilityDiagnostic.
- #report_only? ⇒ Boolean
- #runtime_enforced? ⇒ Boolean
- #status ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(diagnostic_id:, contract_ref:, old_schema_version:, new_schema_version:, old_schema_fingerprint:, new_schema_fingerprint:, schema_check_outcome:, migration_available:, compatibility_decision:, evidence_links:, migration_ref: nil, migration_profile: nil, metadata: {}) ⇒ SchemaCompatibilityDiagnostic
Returns a new instance of SchemaCompatibilityDiagnostic.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 59 def initialize( diagnostic_id:, contract_ref:, old_schema_version:, new_schema_version:, old_schema_fingerprint:, new_schema_fingerprint:, schema_check_outcome:, migration_available:, compatibility_decision:, evidence_links:, migration_ref: nil, migration_profile: nil, metadata: {} ) @diagnostic_id = require_value(:diagnostic_id, diagnostic_id) @contract_ref = require_value(:contract_ref, contract_ref) @old_schema_version = require_value(:old_schema_version, old_schema_version) @new_schema_version = require_value(:new_schema_version, new_schema_version) @old_schema_fingerprint = require_value(:old_schema_fingerprint, old_schema_fingerprint) @new_schema_fingerprint = require_value(:new_schema_fingerprint, new_schema_fingerprint) @schema_check_outcome = normalize_decision(:schema_check_outcome, schema_check_outcome) @migration_available = normalize_boolean(:migration_available, migration_available) @compatibility_decision = normalize_decision(:compatibility_decision, compatibility_decision) @evidence_links = normalize_evidence_links(evidence_links) @migration_ref = migration_ref @migration_profile = normalize_migration_profile(migration_profile) validate_migration_evidence! @profile_cases = build_profile_cases.freeze @metadata = deep_freeze(normalize_hash(, :metadata)) freeze end |
Instance Attribute Details
#compatibility_decision ⇒ Object (readonly)
Returns the value of attribute compatibility_decision.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def compatibility_decision @compatibility_decision end |
#contract_ref ⇒ Object (readonly)
Returns the value of attribute contract_ref.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def contract_ref @contract_ref end |
#diagnostic_id ⇒ Object (readonly)
Returns the value of attribute diagnostic_id.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def diagnostic_id @diagnostic_id end |
#evidence_links ⇒ Object (readonly)
Returns the value of attribute evidence_links.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def evidence_links @evidence_links end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def @metadata end |
#migration_available ⇒ Object (readonly)
Returns the value of attribute migration_available.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def migration_available @migration_available end |
#migration_profile ⇒ Object (readonly)
Returns the value of attribute migration_profile.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def migration_profile @migration_profile end |
#migration_ref ⇒ Object (readonly)
Returns the value of attribute migration_ref.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def migration_ref @migration_ref end |
#new_schema_fingerprint ⇒ Object (readonly)
Returns the value of attribute new_schema_fingerprint.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def new_schema_fingerprint @new_schema_fingerprint end |
#new_schema_version ⇒ Object (readonly)
Returns the value of attribute new_schema_version.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def new_schema_version @new_schema_version end |
#old_schema_fingerprint ⇒ Object (readonly)
Returns the value of attribute old_schema_fingerprint.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def old_schema_fingerprint @old_schema_fingerprint end |
#old_schema_version ⇒ Object (readonly)
Returns the value of attribute old_schema_version.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def old_schema_version @old_schema_version end |
#profile_cases ⇒ Object (readonly)
Returns the value of attribute profile_cases.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def profile_cases @profile_cases end |
#schema_check_outcome ⇒ Object (readonly)
Returns the value of attribute schema_check_outcome.
44 45 46 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 44 def schema_check_outcome @schema_check_outcome end |
Instance Method Details
#blocked? ⇒ Boolean
108 109 110 111 112 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 108 def blocked? schema_check_outcome == :blocked || compatibility_decision == :blocked || profile_cases.any? { |entry| entry.fetch(:status) == :blocked } end |
#report_only? ⇒ Boolean
92 93 94 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 92 def report_only? true end |
#runtime_enforced? ⇒ Boolean
96 97 98 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 96 def runtime_enforced? false end |
#status ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 100 def status return :blocked if blocked? return :migrating if schema_check_outcome == :migrating || compatibility_decision == :migrating return :provisional if schema_check_outcome == :provisional || compatibility_decision == :provisional :trusted end |
#to_h ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/igniter/lang/schema_compatibility_diagnostic.rb', line 114 def to_h payload = { diagnostic_id: diagnostic_id, contract_ref: contract_ref, old_schema_version: old_schema_version, new_schema_version: new_schema_version, old_schema_fingerprint: old_schema_fingerprint, new_schema_fingerprint: new_schema_fingerprint, schema_check_outcome: schema_check_outcome, migration_available: migration_available, compatibility_decision: compatibility_decision, status: status, evidence_links: evidence_links, profile_cases: profile_cases, semantics: SEMANTICS, metadata: } payload[:migration_ref] = migration_ref if migration_ref payload[:migration_profile] = migration_profile if migration_profile payload end |