Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix-subscription-termination
Browse files Browse the repository at this point in the history
  • Loading branch information
mavilein committed Apr 11, 2019
2 parents f0832bb + e620b02 commit b76b6ea
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
13 changes: 7 additions & 6 deletions server/.buildkite/build-cli/src/pipeline_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ def release_artifacts_steps
end

def build_steps_for(version)
['debian', 'lambda'].map do |target|
PipelineStep.new
.label(":rust: Native image [#{target}] [#{version}]")
.command("./server/.buildkite/pipeline.sh native-image #{target} #{version}")
.queue("native-linux")
end
# ['debian', 'lambda'].map do |target|
# PipelineStep.new
# .label(":rust: Native image [#{target}] [#{version}]")
# .command("./server/.buildkite/pipeline.sh native-image #{target} #{version}")
# .queue("native-linux")
# end
[]
end

def calculate_next_unstable_docker_tag()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ case class JdbcProjectPersistence(slickDatabase: SlickDatabase, dbConfig: Databa

override def load(id: String): Future[Option[Project]] = {
val query = sql
.select(pt.id, pt.secrets, pt.allowQueries, pt.allowMutations, mt.schema, mt.functions, mt.revision)
.select(pt.id, pt.secrets, pt.allowQueries, pt.allowMutations, mt.schema, mt.functions, mt.revision, mt.dataModel)
.from(pt.t)
.join(mt.t)
.on(mt.projectId.equal(pt.id))
Expand Down Expand Up @@ -74,7 +74,7 @@ case class JdbcProjectPersistence(slickDatabase: SlickDatabase, dbConfig: Databa
.from(mt.t.as("outer"))

val query = sql
.select(pt.id, pt.secrets, pt.allowQueries, pt.allowMutations, mt.schema, mt.functions, mt.revision)
.select(pt.id, pt.secrets, pt.allowQueries, pt.allowMutations, mt.schema, mt.functions, mt.revision, mt.dataModel)
.from(pt.t)
.join(revisionQuery.asTable("jt"))
.on(field(name("jt", "projectId")).equal(pt.id))
Expand Down Expand Up @@ -164,7 +164,8 @@ case class JdbcProjectPersistence(slickDatabase: SlickDatabase, dbConfig: Databa
allowQueries = rs.getBoolean(pt.allowQueries.getName),
allowMutations = rs.getBoolean(pt.allowMutations.getName),
functions = functions,
manifestation = projectManifestation
manifestation = projectManifestation,
rawDataModel = rs.getString(mt.dataModel.getName)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ object DbMapper extends JsonBsonConversion with MongoExtensions {
revision = migration.revision,
schema = schemaWithAddedBackRelations,
functions = migration.functions.toList,
manifestation = manifestation
manifestation = manifestation,
rawDataModel = migration.rawDataModel
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ case class SangriaHandlerImpl(managementApiEnabled: Boolean)(
sys.error(s"The connector is missing the import / export capability.")
}
}
case Some("_datamodel") =>
verifyAuth(projectIdAsString, rawRequest) { project =>
val response = Response(Json.toJson(project.rawDataModel))
Future.successful(response)
}

case _ =>
requestThrottler.throttleCallIfNeeded(projectIdAsString, isManagementApiRequest = isManagementApiRequest(rawRequest)) {
Expand Down Expand Up @@ -175,7 +180,7 @@ case class SangriaHandlerImpl(managementApiEnabled: Boolean)(
}

private def splitReservedSegment(elements: List[String]): (List[String], Option[String]) = {
val reservedSegments = Set("private", "import", "export")
val reservedSegments = Set("private", "import", "export", "_datamodel")
if (elements.nonEmpty && reservedSegments.contains(elements.last)) {
(elements.dropRight(1), elements.lastOption)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class ProjectPersistenceSpec extends FlatSpec with Matchers with DeploySpecBase
}

// Load the applied revision, which is 2 (2 steps are done in setupProject)
loadProject.get.revision shouldEqual 2
val project1 = loadProject.get
project1.revision shouldEqual 2
project1.rawDataModel should equal(basicTypesGql)

// After another migration is completed, the revision is bumped to the revision of the latest migration
migrationPersistence.updateMigrationStatus(MigrationId(project.id, 3), MigrationStatus.Success).await
Expand All @@ -48,12 +50,13 @@ class ProjectPersistenceSpec extends FlatSpec with Matchers with DeploySpecBase
setupProject(basicTypesGql, stage = "stage1")
setupProject(basicTypesGql, stage = "stage2")

projectPersistence.loadAll().await should have(size(2))
val projects = projectPersistence.loadAll().await
projects should have(size(2))
projects.foreach(p => p.rawDataModel should equal(basicTypesGql))
}

".update()" should "update a project" in {
val (project, _) = setupProject(basicTypesGql)
println(project.id)

val updatedProject = project.copy(secrets = Vector("Some", "secrets"))
projectPersistence.update(updatedProject).await()
Expand All @@ -67,7 +70,6 @@ class ProjectPersistenceSpec extends FlatSpec with Matchers with DeploySpecBase

".delete()" should "delete a project" in {
val (project, _) = setupProject(basicTypesGql)
println(project.id)

projectPersistence.delete(project.id).await()
projectPersistence.load(project.id).await should be(None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ case class Project(
allowQueries: Boolean = true,
allowMutations: Boolean = true,
functions: List[Function] = List.empty,
manifestation: ProjectManifestation = ProjectManifestation.empty
manifestation: ProjectManifestation = ProjectManifestation.empty,
rawDataModel: String = ""
) {
def models = schema.models
def relations = schema.relations
Expand Down

0 comments on commit b76b6ea

Please sign in to comment.