~sircmpwn/sr.ht-dev

hg.sr.ht: api: Add settings field to version v1 PROPOSED

Thorben Günther: 1
 api: Add settings field to version

 2 files changed, 15 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/31378/mbox | git am -3
Learn more about email & git

[PATCH hg.sr.ht] api: Add settings field to version Export this patch

# HG changeset patch
# User Thorben Günther <admin@xenrox.net>
# Date 1650478167 -7200
#      Wed Apr 20 20:09:27 2022 +0200
# Node ID 6bceb227ff7a7b197c20992230ee662ad11892ef
# Parent  237d8f3beedcc0796aba697f8d44120db338e92f
api: Add settings field to version

diff --git a/api/graph/schema.graphqls b/api/graph/schema.graphqls
--- a/api/graph/schema.graphqls
+++ b/api/graph/schema.graphqls
@@ -46,6 +46,9 @@

  "Optional features"
  features: Features!

  "Config settings"
  settings: Settings!
}

"Describes the status of optional features"
@@ -53,6 +56,11 @@
  artifacts: Boolean!
}

"Instance specific settings"
type Settings {
  sshUser: String!
}

enum AccessMode {
  "Read-only"
  RO
diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go
--- a/api/graph/schema.resolvers.go
+++ b/api/graph/schema.resolvers.go
@@ -493,6 +493,10 @@
}

func (r *queryResolver) Version(ctx context.Context) (*model.Version, error) {
	conf := config.ForContext(ctx)
	sshUser, _ := conf.Get("hg.sr.ht::dispatch", "/usr/bin/hgsrht-keys")
	sshUser = strings.Split(sshUser, ":")[0]

	return &model.Version{
		Major:           0,
		Minor:           0,
@@ -500,6 +504,9 @@
		DeprecationDate: nil,

		Features: &model.Features{},
		Settings: &model.Settings{
			SSHUser: sshUser,
		},
	}, nil
}