Skip to content
Snippets Groups Projects
Commit d8547b24 authored by Lyuben Penkovski's avatar Lyuben Penkovski
Browse files

Add service name and version to the liveness/readiness response

parent df815024
No related branches found
No related tags found
1 merge request!46Expose service to internet with ngrok for development purposes only
Pipeline #67090 passed with stages
in 2 minutes and 47 seconds
Showing with 568 additions and 300 deletions
......@@ -156,7 +156,7 @@ func main() {
)
{
policySvc = policy.New(storage, regocache, cache, logger)
healthSvc = health.New()
healthSvc = health.New(Version)
}
// create endpoints
......
......@@ -82,7 +82,7 @@ var _ = Service("health", func() {
Method("Liveness", func() {
Payload(Empty)
Result(Empty)
Result(HealthResponse)
HTTP(func() {
GET("/liveness")
Response(StatusOK)
......@@ -91,7 +91,7 @@ var _ = Service("health", func() {
Method("Readiness", func() {
Payload(Empty)
Result(Empty)
Result(HealthResponse)
HTTP(func() {
GET("/readiness")
Response(StatusOK)
......
......@@ -62,3 +62,10 @@ var PoliciesResult = Type("PoliciesResult", func() {
Field(1, "policies", ArrayOf(Policy), "JSON array of policies.")
Required("policies")
})
var HealthResponse = Type("HealthResponse", func() {
Field(1, "service", String, "Service name.")
Field(2, "status", String, "Status message.")
Field(3, "version", String, "Service runtime version.")
Required("service", "status", "version")
})
......@@ -28,13 +28,21 @@ func NewClient(liveness, readiness goa.Endpoint) *Client {
}
// Liveness calls the "Liveness" endpoint of the "health" service.
func (c *Client) Liveness(ctx context.Context) (err error) {
_, err = c.LivenessEndpoint(ctx, nil)
return
func (c *Client) Liveness(ctx context.Context) (res *HealthResponse, err error) {
var ires any
ires, err = c.LivenessEndpoint(ctx, nil)
if err != nil {
return
}
return ires.(*HealthResponse), nil
}
// Readiness calls the "Readiness" endpoint of the "health" service.
func (c *Client) Readiness(ctx context.Context) (err error) {
_, err = c.ReadinessEndpoint(ctx, nil)
return
func (c *Client) Readiness(ctx context.Context) (res *HealthResponse, err error) {
var ires any
ires, err = c.ReadinessEndpoint(ctx, nil)
if err != nil {
return
}
return ires.(*HealthResponse), nil
}
......@@ -37,7 +37,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) {
// "Liveness" of service "health".
func NewLivenessEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
return nil, s.Liveness(ctx)
return s.Liveness(ctx)
}
}
......@@ -45,6 +45,6 @@ func NewLivenessEndpoint(s Service) goa.Endpoint {
// "Readiness" of service "health".
func NewReadinessEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
return nil, s.Readiness(ctx)
return s.Readiness(ctx)
}
}
......@@ -14,9 +14,9 @@ import (
// Health service provides health check endpoints.
type Service interface {
// Liveness implements Liveness.
Liveness(context.Context) (err error)
Liveness(context.Context) (res *HealthResponse, err error)
// Readiness implements Readiness.
Readiness(context.Context) (err error)
Readiness(context.Context) (res *HealthResponse, err error)
}
// ServiceName is the name of the service as defined in the design. This is the
......@@ -28,3 +28,13 @@ const ServiceName = "health"
// are the same values that are set in the endpoint request contexts under the
// MethodKey key.
var MethodNames = [2]string{"Liveness", "Readiness"}
// HealthResponse is the result type of the health service Liveness method.
type HealthResponse struct {
// Service name.
Service string
// Status message.
Status string
// Service runtime version.
Version string
}
......@@ -23,15 +23,15 @@ import (
//
// command (subcommand1|subcommand2|...)
func UsageCommands() string {
return `health (liveness|readiness)
policy (evaluate|lock|unlock|list-policies)
return `policy (evaluate|lock|unlock|list-policies)
health (liveness|readiness)
`
}
// UsageExamples produces an example of a valid invocation of the CLI tool.
func UsageExamples() string {
return os.Args[0] + ` health liveness` + "\n" +
os.Args[0] + ` policy evaluate --body "Quibusdam ab repellendus in illum." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Nihil repudiandae dolore quod sunt aut." --ttl 4633716418015214972` + "\n" +
return os.Args[0] + ` policy evaluate --body "At incidunt unde consequatur voluptas dolorem nisi." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Illum est et hic." --ttl 5942762461305129155` + "\n" +
os.Args[0] + ` health liveness` + "\n" +
""
}
......@@ -45,12 +45,6 @@ func ParseEndpoint(
restore bool,
) (goa.Endpoint, any, error) {
var (
healthFlags = flag.NewFlagSet("health", flag.ContinueOnError)
healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError)
healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError)
policyFlags = flag.NewFlagSet("policy", flag.ContinueOnError)
policyEvaluateFlags = flag.NewFlagSet("evaluate", flag.ExitOnError)
......@@ -76,17 +70,23 @@ func ParseEndpoint(
policyListPoliciesRegoFlag = policyListPoliciesFlags.String("rego", "", "")
policyListPoliciesDataFlag = policyListPoliciesFlags.String("data", "", "")
policyListPoliciesDataConfigFlag = policyListPoliciesFlags.String("data-config", "", "")
)
healthFlags.Usage = healthUsage
healthLivenessFlags.Usage = healthLivenessUsage
healthReadinessFlags.Usage = healthReadinessUsage
healthFlags = flag.NewFlagSet("health", flag.ContinueOnError)
healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError)
healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError)
)
policyFlags.Usage = policyUsage
policyEvaluateFlags.Usage = policyEvaluateUsage
policyLockFlags.Usage = policyLockUsage
policyUnlockFlags.Usage = policyUnlockUsage
policyListPoliciesFlags.Usage = policyListPoliciesUsage
healthFlags.Usage = healthUsage
healthLivenessFlags.Usage = healthLivenessUsage
healthReadinessFlags.Usage = healthReadinessUsage
if err := flag.CommandLine.Parse(os.Args[1:]); err != nil {
return nil, nil, err
}
......@@ -102,10 +102,10 @@ func ParseEndpoint(
{
svcn = flag.Arg(0)
switch svcn {
case "health":
svcf = healthFlags
case "policy":
svcf = policyFlags
case "health":
svcf = healthFlags
default:
return nil, nil, fmt.Errorf("unknown service %q", svcn)
}
......@@ -121,16 +121,6 @@ func ParseEndpoint(
{
epn = svcf.Arg(0)
switch svcn {
case "health":
switch epn {
case "liveness":
epf = healthLivenessFlags
case "readiness":
epf = healthReadinessFlags
}
case "policy":
switch epn {
case "evaluate":
......@@ -147,6 +137,16 @@ func ParseEndpoint(
}
case "health":
switch epn {
case "liveness":
epf = healthLivenessFlags
case "readiness":
epf = healthReadinessFlags
}
}
}
if epf == nil {
......@@ -167,16 +167,6 @@ func ParseEndpoint(
)
{
switch svcn {
case "health":
c := healthc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
case "liveness":
endpoint = c.Liveness()
data = nil
case "readiness":
endpoint = c.Readiness()
data = nil
}
case "policy":
c := policyc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
......@@ -193,6 +183,16 @@ func ParseEndpoint(
endpoint = c.ListPolicies()
data, err = policyc.BuildListPoliciesPayload(*policyListPoliciesLockedFlag, *policyListPoliciesRegoFlag, *policyListPoliciesDataFlag, *policyListPoliciesDataConfigFlag)
}
case "health":
c := healthc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
case "liveness":
endpoint = c.Liveness()
data = nil
case "readiness":
endpoint = c.Readiness()
data = nil
}
}
}
if err != nil {
......@@ -202,40 +202,6 @@ func ParseEndpoint(
return endpoint, data, nil
}
// healthUsage displays the usage of the health command and its subcommands.
func healthUsage() {
fmt.Fprintf(os.Stderr, `Health service provides health check endpoints.
Usage:
%[1]s [globalflags] health COMMAND [flags]
COMMAND:
liveness: Liveness implements Liveness.
readiness: Readiness implements Readiness.
Additional help:
%[1]s health COMMAND --help
`, os.Args[0])
}
func healthLivenessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness
Liveness implements Liveness.
Example:
%[1]s health liveness
`, os.Args[0])
}
func healthReadinessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness
Readiness implements Readiness.
Example:
%[1]s health readiness
`, os.Args[0])
}
// policyUsage displays the usage of the policy command and its subcommands.
func policyUsage() {
fmt.Fprintf(os.Stderr, `Policy Service provides evaluation of policies through Open Policy Agent.
......@@ -264,7 +230,7 @@ Evaluate executes a policy with the given 'data' as input.
-ttl INT:
Example:
%[1]s policy evaluate --body "Quibusdam ab repellendus in illum." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Nihil repudiandae dolore quod sunt aut." --ttl 4633716418015214972
%[1]s policy evaluate --body "At incidunt unde consequatur voluptas dolorem nisi." --group "example" --policy-name "example" --version "1.0" --evaluation-id "Illum est et hic." --ttl 5942762461305129155
`, os.Args[0])
}
......@@ -277,7 +243,7 @@ Lock a policy so that it cannot be evaluated.
-version STRING: Policy version.
Example:
%[1]s policy lock --group "Aliquam atque voluptatum ut dolorem." --policy-name "Aut facere veniam repudiandae id." --version "Aut minus alias."
%[1]s policy lock --group "At eos facilis molestias in voluptas rem." --policy-name "Ab accusantium ut ut aliquid sint animi." --version "Dolorem cumque laborum quis nesciunt."
`, os.Args[0])
}
......@@ -290,7 +256,7 @@ Unlock a policy so it can be evaluated again.
-version STRING: Policy version.
Example:
%[1]s policy unlock --group "Aut voluptas." --policy-name "Sint nam voluptatem ea consequatur similique et." --version "Non mollitia nesciunt impedit facere."
%[1]s policy unlock --group "Ut commodi perspiciatis corporis." --policy-name "Accusamus autem sequi." --version "Et nulla."
`, os.Args[0])
}
......@@ -304,6 +270,40 @@ List policies from storage with optional filters.
-data-config BOOL:
Example:
%[1]s policy list-policies --locked false --rego true --data false --data-config false
%[1]s policy list-policies --locked true --rego true --data true --data-config false
`, os.Args[0])
}
// healthUsage displays the usage of the health command and its subcommands.
func healthUsage() {
fmt.Fprintf(os.Stderr, `Health service provides health check endpoints.
Usage:
%[1]s [globalflags] health COMMAND [flags]
COMMAND:
liveness: Liveness implements Liveness.
readiness: Readiness implements Readiness.
Additional help:
%[1]s health COMMAND --help
`, os.Args[0])
}
func healthLivenessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness
Liveness implements Liveness.
Example:
%[1]s health liveness
`, os.Args[0])
}
func healthReadinessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness
Readiness implements Readiness.
Example:
%[1]s health readiness
`, os.Args[0])
}
......@@ -51,7 +51,20 @@ func DecodeLivenessResponse(decoder func(*http.Response) goahttp.Decoder, restor
}
switch resp.StatusCode {
case http.StatusOK:
return nil, nil
var (
body LivenessResponseBody
err error
)
err = decoder(resp).Decode(&body)
if err != nil {
return nil, goahttp.ErrDecodingError("health", "Liveness", err)
}
err = ValidateLivenessResponseBody(&body)
if err != nil {
return nil, goahttp.ErrValidationError("health", "Liveness", err)
}
res := NewLivenessHealthResponseOK(&body)
return res, nil
default:
body, _ := io.ReadAll(resp.Body)
return nil, goahttp.ErrInvalidResponse("health", "Liveness", resp.StatusCode, string(body))
......@@ -93,7 +106,20 @@ func DecodeReadinessResponse(decoder func(*http.Response) goahttp.Decoder, resto
}
switch resp.StatusCode {
case http.StatusOK:
return nil, nil
var (
body ReadinessResponseBody
err error
)
err = decoder(resp).Decode(&body)
if err != nil {
return nil, goahttp.ErrDecodingError("health", "Readiness", err)
}
err = ValidateReadinessResponseBody(&body)
if err != nil {
return nil, goahttp.ErrValidationError("health", "Readiness", err)
}
res := NewReadinessHealthResponseOK(&body)
return res, nil
default:
body, _ := io.ReadAll(resp.Body)
return nil, goahttp.ErrInvalidResponse("health", "Readiness", resp.StatusCode, string(body))
......
......@@ -6,3 +6,84 @@
// $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/policy/design
package client
import (
health "gitlab.eclipse.org/eclipse/xfsc/tsa/policy/gen/health"
goa "goa.design/goa/v3/pkg"
)
// LivenessResponseBody is the type of the "health" service "Liveness" endpoint
// HTTP response body.
type LivenessResponseBody struct {
// Service name.
Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"`
// Status message.
Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"`
// Service runtime version.
Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"`
}
// ReadinessResponseBody is the type of the "health" service "Readiness"
// endpoint HTTP response body.
type ReadinessResponseBody struct {
// Service name.
Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"`
// Status message.
Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"`
// Service runtime version.
Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"`
}
// NewLivenessHealthResponseOK builds a "health" service "Liveness" endpoint
// result from a HTTP "OK" response.
func NewLivenessHealthResponseOK(body *LivenessResponseBody) *health.HealthResponse {
v := &health.HealthResponse{
Service: *body.Service,
Status: *body.Status,
Version: *body.Version,
}
return v
}
// NewReadinessHealthResponseOK builds a "health" service "Readiness" endpoint
// result from a HTTP "OK" response.
func NewReadinessHealthResponseOK(body *ReadinessResponseBody) *health.HealthResponse {
v := &health.HealthResponse{
Service: *body.Service,
Status: *body.Status,
Version: *body.Version,
}
return v
}
// ValidateLivenessResponseBody runs the validations defined on
// LivenessResponseBody
func ValidateLivenessResponseBody(body *LivenessResponseBody) (err error) {
if body.Service == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("service", "body"))
}
if body.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "body"))
}
if body.Version == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("version", "body"))
}
return
}
// ValidateReadinessResponseBody runs the validations defined on
// ReadinessResponseBody
func ValidateReadinessResponseBody(body *ReadinessResponseBody) (err error) {
if body.Service == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("service", "body"))
}
if body.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "body"))
}
if body.Version == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("version", "body"))
}
return
}
......@@ -11,6 +11,7 @@ import (
"context"
"net/http"
health "gitlab.eclipse.org/eclipse/xfsc/tsa/policy/gen/health"
goahttp "goa.design/goa/v3/http"
)
......@@ -18,8 +19,11 @@ import (
// health Liveness endpoint.
func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
return func(ctx context.Context, w http.ResponseWriter, v any) error {
res, _ := v.(*health.HealthResponse)
enc := encoder(ctx, w)
body := NewLivenessResponseBody(res)
w.WriteHeader(http.StatusOK)
return nil
return enc.Encode(body)
}
}
......@@ -27,7 +31,10 @@ func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) g
// health Readiness endpoint.
func EncodeReadinessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
return func(ctx context.Context, w http.ResponseWriter, v any) error {
res, _ := v.(*health.HealthResponse)
enc := encoder(ctx, w)
body := NewReadinessResponseBody(res)
w.WriteHeader(http.StatusOK)
return nil
return enc.Encode(body)
}
}
......@@ -6,3 +6,51 @@
// $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/policy/design
package server
import (
health "gitlab.eclipse.org/eclipse/xfsc/tsa/policy/gen/health"
)
// LivenessResponseBody is the type of the "health" service "Liveness" endpoint
// HTTP response body.
type LivenessResponseBody struct {
// Service name.
Service string `form:"service" json:"service" xml:"service"`
// Status message.
Status string `form:"status" json:"status" xml:"status"`
// Service runtime version.
Version string `form:"version" json:"version" xml:"version"`
}
// ReadinessResponseBody is the type of the "health" service "Readiness"
// endpoint HTTP response body.
type ReadinessResponseBody struct {
// Service name.
Service string `form:"service" json:"service" xml:"service"`
// Status message.
Status string `form:"status" json:"status" xml:"status"`
// Service runtime version.
Version string `form:"version" json:"version" xml:"version"`
}
// NewLivenessResponseBody builds the HTTP response body from the result of the
// "Liveness" endpoint of the "health" service.
func NewLivenessResponseBody(res *health.HealthResponse) *LivenessResponseBody {
body := &LivenessResponseBody{
Service: res.Service,
Status: res.Status,
Version: res.Version,
}
return body
}
// NewReadinessResponseBody builds the HTTP response body from the result of
// the "Readiness" endpoint of the "health" service.
func NewReadinessResponseBody(res *health.HealthResponse) *ReadinessResponseBody {
body := &ReadinessResponseBody{
Service: res.Service,
Status: res.Status,
Version: res.Version,
}
return body
}
This diff is collapsed.
......@@ -22,6 +22,12 @@ paths:
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/HealthLivenessResponseBody'
required:
- service
- status
- version
schemes:
- http
/policy/{group}/{policyName}/{version}/evaluation:
......@@ -243,6 +249,12 @@ paths:
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/HealthReadinessResponseBody'
required:
- service
- status
- version
schemes:
- http
/v1/policies:
......@@ -283,6 +295,54 @@ paths:
schemes:
- http
definitions:
HealthLivenessResponseBody:
title: HealthLivenessResponseBody
type: object
properties:
service:
type: string
description: Service name.
example: Quasi delectus debitis consectetur rerum vel sunt.
status:
type: string
description: Status message.
example: Ea architecto iure est similique architecto id.
version:
type: string
description: Service runtime version.
example: Ut est ut molestias sint ipsam.
example:
service: At ut dolore.
status: Aperiam aut odio dolorum.
version: Quae et et unde.
required:
- service
- status
- version
HealthReadinessResponseBody:
title: HealthReadinessResponseBody
type: object
properties:
service:
type: string
description: Service name.
example: Dolore ducimus accusamus et voluptatibus cupiditate.
status:
type: string
description: Status message.
example: Repellat inventore ut doloremque recusandae earum et.
version:
type: string
description: Service runtime version.
example: Nisi vitae iure fugiat sed sit dolores.
example:
service: Ut quibusdam.
status: Eaque fugiat et.
version: Vel non quo.
required:
- service
- status
- version
PolicyListPoliciesResponseBody:
title: PolicyListPoliciesResponseBody
type: object
......@@ -293,64 +353,40 @@ definitions:
$ref: '#/definitions/PolicyResponseBody'
description: JSON array of policies.
example:
- data: Commodi nemo fugiat id praesentium accusantium expedita.
dataConfig: Qui non quia.
group: Sequi adipisci et nulla.
lastUpdate: 8181859392515170659
- data: Optio quia et laborum.
dataConfig: In libero perspiciatis voluptatum ut soluta.
group: Commodi nemo fugiat id praesentium accusantium expedita.
lastUpdate: 9002532952206938167
locked: false
policyName: Consequatur accusamus.
rego: Sunt in et quia cum.
version: In quis nesciunt autem et.
- data: Commodi nemo fugiat id praesentium accusantium expedita.
dataConfig: Qui non quia.
group: Sequi adipisci et nulla.
lastUpdate: 8181859392515170659
policyName: Et aliquam sunt in et quia cum.
rego: Error maxime quasi quia non voluptatibus error.
version: Qui non quia.
- data: Optio quia et laborum.
dataConfig: In libero perspiciatis voluptatum ut soluta.
group: Commodi nemo fugiat id praesentium accusantium expedita.
lastUpdate: 9002532952206938167
locked: false
policyName: Consequatur accusamus.
rego: Sunt in et quia cum.
version: In quis nesciunt autem et.
- data: Commodi nemo fugiat id praesentium accusantium expedita.
dataConfig: Qui non quia.
group: Sequi adipisci et nulla.
lastUpdate: 8181859392515170659
locked: false
policyName: Consequatur accusamus.
rego: Sunt in et quia cum.
version: In quis nesciunt autem et.
policyName: Et aliquam sunt in et quia cum.
rego: Error maxime quasi quia non voluptatibus error.
version: Qui non quia.
example:
policies:
- data: Commodi nemo fugiat id praesentium accusantium expedita.
dataConfig: Qui non quia.
group: Sequi adipisci et nulla.
lastUpdate: 8181859392515170659
locked: false
policyName: Consequatur accusamus.
rego: Sunt in et quia cum.
version: In quis nesciunt autem et.
- data: Commodi nemo fugiat id praesentium accusantium expedita.
dataConfig: Qui non quia.
group: Sequi adipisci et nulla.
lastUpdate: 8181859392515170659
locked: false
policyName: Consequatur accusamus.
rego: Sunt in et quia cum.
version: In quis nesciunt autem et.
- data: Commodi nemo fugiat id praesentium accusantium expedita.
dataConfig: Qui non quia.
group: Sequi adipisci et nulla.
lastUpdate: 8181859392515170659
- data: Optio quia et laborum.
dataConfig: In libero perspiciatis voluptatum ut soluta.
group: Commodi nemo fugiat id praesentium accusantium expedita.
lastUpdate: 9002532952206938167
locked: false
policyName: Consequatur accusamus.
rego: Sunt in et quia cum.
version: In quis nesciunt autem et.
- data: Commodi nemo fugiat id praesentium accusantium expedita.
dataConfig: Qui non quia.
group: Sequi adipisci et nulla.
lastUpdate: 8181859392515170659
policyName: Et aliquam sunt in et quia cum.
rego: Error maxime quasi quia non voluptatibus error.
version: Qui non quia.
- data: Optio quia et laborum.
dataConfig: In libero perspiciatis voluptatum ut soluta.
group: Commodi nemo fugiat id praesentium accusantium expedita.
lastUpdate: 9002532952206938167
locked: false
policyName: Consequatur accusamus.
rego: Sunt in et quia cum.
version: In quis nesciunt autem et.
policyName: Et aliquam sunt in et quia cum.
rego: Error maxime quasi quia non voluptatibus error.
version: Qui non quia.
required:
- policies
PolicyResponseBody:
......@@ -360,19 +396,19 @@ definitions:
data:
type: string
description: Policy static data.
example: Accusamus enim.
example: Voluptate amet.
dataConfig:
type: string
description: Policy static data optional configuration.
example: Recusandae est rerum corrupti quia.
example: Aut et.
group:
type: string
description: Policy group.
example: Optio quia et laborum.
example: Totam officia necessitatibus tempore nulla animi.
lastUpdate:
type: integer
description: Last update (Unix timestamp).
example: 1029654258457164464
example: 4355437808814429430
format: int64
locked:
type: boolean
......@@ -381,24 +417,24 @@ definitions:
policyName:
type: string
description: Policy name.
example: Quia non voluptatibus error.
example: Corporis est rem.
rego:
type: string
description: Policy rego source code.
example: Ut amet.
example: Vitae dolores quas et aperiam dolores reiciendis.
version:
type: string
description: Policy version.
example: In libero perspiciatis voluptatum ut soluta.
example: Consequatur vel rerum rem ipsam nam.
example:
data: Totam officia necessitatibus tempore nulla animi.
dataConfig: Consequatur vel rerum rem ipsam nam.
group: Adipisci inventore ipsum voluptatibus recusandae.
lastUpdate: 1724369781608544610
locked: true
policyName: Architecto itaque voluptatum voluptas ad.
rego: Ab perspiciatis voluptatem pariatur corporis est rem.
version: Nisi distinctio vitae.
data: Aut asperiores.
dataConfig: Vel dolores omnis molestiae tempora sed repellendus.
group: Et dolores.
lastUpdate: 8993739598055578473
locked: false
policyName: Minus fugiat veritatis quam qui nostrum eaque.
rego: Ipsa ad voluptatum maxime ut.
version: Delectus rerum molestiae possimus cum laboriosam.
required:
- group
- policyName
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,7 +23,7 @@ func BuildEvaluatePayload(policyEvaluateBody string, policyEvaluateGroup string,
{
err = json.Unmarshal([]byte(policyEvaluateBody), &body)
if err != nil {
return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Quibusdam ab repellendus in illum.\"")
return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"At incidunt unde consequatur voluptas dolorem nisi.\"")
}
}
var group string
......
package health
import "context"
import (
"context"
type Service struct{}
"gitlab.eclipse.org/eclipse/xfsc/tsa/policy/gen/health"
)
func New() *Service {
return &Service{}
type Service struct {
ver string
}
func (s *Service) Liveness(_ context.Context) error {
return nil
func New(version string) *Service {
return &Service{ver: version}
}
func (s *Service) Readiness(_ context.Context) error {
return nil
func (s *Service) Liveness(_ context.Context) (*health.HealthResponse, error) {
return &health.HealthResponse{
Service: "policy",
Status: "up",
Version: s.ver,
}, nil
}
func (s *Service) Readiness(_ context.Context) (*health.HealthResponse, error) {
return &health.HealthResponse{
Service: "policy",
Status: "up",
Version: s.ver,
}, nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment