diff --git a/app/graphql/types/metadata_type.rb b/app/graphql/types/metadata_type.rb
index b00fcfd38ad33d1493a0e9cd8315742e8a14d583..492cca365f3f8215bd616bc8c2790f07a06cff4e 100644
--- a/app/graphql/types/metadata_type.rb
+++ b/app/graphql/types/metadata_type.rb
@@ -6,6 +6,8 @@ class MetadataType < ::Types::BaseObject
authorize :read_instance_metadata
+ field :enterprise, GraphQL::Types::Boolean, null: false,
+ description: 'Enterprise edition.'
field :kas, ::Types::Metadata::KasType, null: false,
description: 'Metadata about KAS.'
field :revision, GraphQL::Types::String, null: false,
diff --git a/app/models/instance_metadata.rb b/app/models/instance_metadata.rb
index 6cac78178e03ce17ff06c14fddf062f7487d26ba..47460c856713dfe7bf49b4f8617ea6e091dad5ef 100644
--- a/app/models/instance_metadata.rb
+++ b/app/models/instance_metadata.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
class InstanceMetadata
- attr_reader :version, :revision, :kas
+ attr_reader :version, :revision, :kas, :enterprise
- def initialize(version: Gitlab::VERSION, revision: Gitlab.revision)
+ def initialize(version: Gitlab::VERSION, revision: Gitlab.revision, enterprise: Gitlab.ee?)
@version = version
@revision = revision
@kas = ::InstanceMetadata::Kas.new
+ @enterprise = enterprise
end
end
diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md
index a8e48a952c0d78cbc92dbc166f3cafb564e49db3..b1f9d6ceae172f6abcbca851d959a0e42ce73b23 100644
--- a/doc/api/graphql/reference/index.md
+++ b/doc/api/graphql/reference/index.md
@@ -15783,6 +15783,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| Name | Type | Description |
| ---- | ---- | ----------- |
+| `enterprise` | [`Boolean!`](#boolean) | Enterprise edition. |
| `kas` | [`Kas!`](#kas) | Metadata about KAS. |
| `revision` | [`String!`](#string) | Revision. |
| `version` | [`String!`](#string) | Version. |
diff --git a/doc/api/metadata.md b/doc/api/metadata.md
index 3803173b0b8c244aada39911a2907c867d9c1221..c3cbae70a54baecbd1cea56ee7d954a76741ed86 100644
--- a/doc/api/metadata.md
+++ b/doc/api/metadata.md
@@ -24,6 +24,7 @@ Response body attributes:
| `kas.enabled` | boolean | Indicates whether KAS is enabled. |
| `kas.externalUrl` | string or null | URL used by the agents to communicate with KAS. It's `null` if `kas.enabled` is `false`. |
| `kas.version` | string or null | Version of KAS. It's `null` if `kas.enabled` is `false`. |
+| `enterprise` | boolean | Indicates whether GitLab instance is Enterprise Edition. |
Example request:
@@ -41,6 +42,7 @@ Example response:
"enabled": true,
"externalUrl": "grpc://gitlab.example.com:8150",
"version": "15.0.0"
- }
+ },
+ "enterprise": true
}
```
diff --git a/lib/api/entities/metadata.rb b/lib/api/entities/metadata.rb
index 1e04b5c59821f213e2ec887d2121ff9529d9b0ec..7dfcad2ccabd3c9b936c9707050035d72a89835e 100644
--- a/lib/api/entities/metadata.rb
+++ b/lib/api/entities/metadata.rb
@@ -10,6 +10,7 @@ class Metadata < Grape::Entity
expose :externalUrl, documentation: { type: 'string', example: 'grpc://gitlab.example.com:8150' }
expose :version, documentation: { type: 'string', example: '15.0.0' }
end
+ expose :enterprise, documentation: { type: 'boolean' }
end
end
end
diff --git a/lib/api/metadata.rb b/lib/api/metadata.rb
index 2fdb97f98efcb414350d157e3085340bb99da032..788d9843c6392e1dbb9f7226a8cfb8787aad9b10 100644
--- a/lib/api/metadata.rb
+++ b/lib/api/metadata.rb
@@ -23,6 +23,7 @@ class Metadata < ::API::Base
externalUrl
version
}
+ enterprise
}
}
EOF
diff --git a/spec/fixtures/api/schemas/public_api/v4/metadata.json b/spec/fixtures/api/schemas/public_api/v4/metadata.json
index fd219b95df8ac6d205c53215e33266c97dc014eb..f5a6aa8689006b3c9ab02f6cce168135f4cc2112 100644
--- a/spec/fixtures/api/schemas/public_api/v4/metadata.json
+++ b/spec/fixtures/api/schemas/public_api/v4/metadata.json
@@ -3,11 +3,16 @@
"required": [
"version",
"revision",
- "kas"
+ "kas",
+ "enterprise"
],
"properties": {
- "version": { "type": "string" },
- "revision": { "type": "string" },
+ "version": {
+ "type": "string"
+ },
+ "revision": {
+ "type": "string"
+ },
"kas": {
"type": "object",
"required": [
@@ -16,11 +21,26 @@
"version"
],
"properties": {
- "enabled": { "type": "boolean" },
- "externalUrl": { "type": ["string", "null"] },
- "version": { "type": ["string", "null"] }
+ "enabled": {
+ "type": "boolean"
+ },
+ "externalUrl": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "version": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
}
+ },
+ "enterprise": {
+ "type": "boolean"
}
},
"additionalProperties": false
-}
+}
\ No newline at end of file
diff --git a/spec/models/instance_metadata_spec.rb b/spec/models/instance_metadata_spec.rb
index 5fc073c392dc85c5ab1037aafd1687f9cfca0edd..46fd165e0653785f3ac5f7f29e5ff8fee82e9af3 100644
--- a/spec/models/instance_metadata_spec.rb
+++ b/spec/models/instance_metadata_spec.rb
@@ -9,7 +9,8 @@
expect(subject).to have_attributes(
version: Gitlab::VERSION,
revision: Gitlab.revision,
- kas: kind_of(::InstanceMetadata::Kas)
+ kas: kind_of(::InstanceMetadata::Kas),
+ enterprise: Gitlab.ee?
)
end
end
diff --git a/spec/requests/api/graphql/metadata_query_spec.rb b/spec/requests/api/graphql/metadata_query_spec.rb
index 840bd7c018c16b218874593fd5f6b82b8212e534..435e1b5b59658e603dcda87e6fe37d09f9b6421e 100644
--- a/spec/requests/api/graphql/metadata_query_spec.rb
+++ b/spec/requests/api/graphql/metadata_query_spec.rb
@@ -17,7 +17,8 @@
'enabled' => Gitlab::Kas.enabled?,
'version' => expected_kas_version,
'externalUrl' => expected_kas_external_url
- }
+ },
+ 'enterprise' => Gitlab.ee?
}
}
end