Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ entries. It runs as an aggregated API server under Milo, like

## Status

Early scaffold. The server runs and serves `FeedbackSource`. The other
resources in the design are tracked as sub-issues of the epic.
Early. Every resource in the design has a v1alpha1 type in
`pkg/apis/feedback/v1alpha1` and a sample in `config/samples`, but the server
only serves `FeedbackSource` so far. Storage for the rest is tracked as
sub-issues of the epic.

| Resource | Storage | State |
| --- | --- | --- |
Expand Down
112 changes: 112 additions & 0 deletions cmd/feedback/openapi_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package main

import (
"reflect"
"strings"
"testing"

apiopenapi "k8s.io/apiserver/pkg/endpoints/openapi"
openapicommon "k8s.io/kube-openapi/pkg/common"
openapiutil "k8s.io/kube-openapi/pkg/util"
"k8s.io/kube-openapi/pkg/validation/spec"

feedbackapiserver "go.miloapis.com/feedback/internal/apiserver"
feedbackv1alpha1 "go.miloapis.com/feedback/pkg/apis/feedback/v1alpha1"
"go.miloapis.com/feedback/pkg/generated/openapi"
)

const typesPkg = "go.miloapis.com/feedback/pkg/apis/feedback/v1alpha1"

func definitionNamer() func(string) (string, spec.Extensions) {
namer := apiopenapi.NewDefinitionNamer(feedbackapiserver.Scheme)
return func(name string) (string, spec.Extensions) {
if strings.Contains(name, "/") {
name = openapiutil.ToRESTFriendlyName(name)
}
return namer.GetDefinitionName(name)
}
}

// TestOpenAPIGVKExtensions checks every kind has the
// x-kubernetes-group-version-kind extension. Without it server-side apply
// fails with "no corresponding type".
func TestOpenAPIGVKExtensions(t *testing.T) {
getName := definitionNamer()
defs := openapi.GetOpenAPIDefinitions(func(string) spec.Ref { return spec.Ref{} })

for _, obj := range feedbackv1alpha1.KnownTypes() {
kind := reflect.TypeOf(obj).Elem().Name()
t.Run(kind, func(t *testing.T) {
key := typesPkg + "." + kind
if _, ok := defs[key]; !ok {
t.Fatalf("%s has no OpenAPI definition; run task generate", key)
}
_, ext := getName(key)
gvks, ok := ext["x-kubernetes-group-version-kind"].([]any)
if !ok {
t.Fatalf("no GVK extension for %s", key)
}
for _, g := range gvks {
m, _ := g.(map[string]any)
if m["group"] == feedbackv1alpha1.GroupName && m["version"] == "v1alpha1" && m["kind"] == kind {
return
}
}
t.Fatalf("GVK %s/v1alpha1 %s missing from %v", feedbackv1alpha1.GroupName, kind, gvks)
})
}
}

// TestOpenAPIRefsResolve checks every $ref points at a definition that
// exists under its REST-friendly name, which is what the server publishes.
func TestOpenAPIRefsResolve(t *testing.T) {
getName := definitionNamer()
defs := openapi.GetOpenAPIDefinitions(func(name string) spec.Ref {
n, _ := getName(name)
return spec.MustCreateRef("#/components/schemas/" + openapicommon.EscapeJsonPointer(n))
})
published := map[string]bool{}
for k := range defs {
n, _ := getName(k)
published[n] = true
}

for key, def := range defs {
if !strings.HasPrefix(key, typesPkg) {
continue
}
for _, dep := range def.Dependencies {
n, _ := getName(dep)
if !published[n] {
t.Errorf("%s depends on %s (%s), which is not published", key, dep, n)
}
}
}
}

// TestOpenAPIEnums checks +enum markers reach the schema, so clients get the
// allowed values.
func TestOpenAPIEnums(t *testing.T) {
defs := openapi.GetOpenAPIDefinitions(func(string) spec.Ref { return spec.Ref{} })
cases := []struct {
typ, field string
want []string
}{
{"PostStatus", "state", []string{"backlog", "closed", "in-progress", "none", "on-deck", "planning", "shipped"}},
{"SubmissionStatus", "phase", []string{"Approved", "Merged", "PendingReview", "Rejected"}},
{"PostQuerySpec", "sort", []string{"newest", "recentlyChanged", "relevance", "top", "trending"}},
}
for _, tc := range cases {
prop, ok := defs[typesPkg+"."+tc.typ].Schema.Properties[tc.field]
if !ok {
t.Fatalf("%s.%s not in schema", tc.typ, tc.field)
}
var got []string
for _, v := range prop.Enum {
got = append(got, v.(string))
}
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("%s.%s enum = %v, want %v", tc.typ, tc.field, got, tc.want)
}
}
}
9 changes: 9 additions & 0 deletions config/samples/attachmentupload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: feedback.miloapis.com/v1alpha1
kind: AttachmentUpload
metadata:
generateName: att-
spec:
purpose: Submission
name: error.log
contentType: text/plain
data: ZXJyb3I6IGNvbm5lY3Rpb24gcmVmdXNlZAo=
19 changes: 19 additions & 0 deletions config/samples/changelogentry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog entries are written by feedback-sync. Shown here for reference.
apiVersion: feedback.miloapis.com/v1alpha1
kind: ChangelogEntry
metadata:
name: datum-cloud.datum.303
status:
title: "Application Load Balancer: wildcard hostnames"
publishedAt: "2026-10-07T13:23:39Z"
categories: [deliver]
bodyHTML: "<p>...</p>"
posts:
- datum-cloud.enhancements.913
issueRefs:
- datum-cloud/enhancements#913
- datum-cloud/compute#311
reactions: {thumbsUp: 4}
github:
url: https://github.com/datum-cloud/datum/discussions/303
number: 303
55 changes: 55 additions & 0 deletions config/samples/post.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Posts are written by feedback-sync. Shown here for reference.
apiVersion: feedback.miloapis.com/v1alpha1
kind: Post
metadata:
name: datum-cloud.enhancements.912
spec:
hidden: false
status:
title: Bare Metal Infrastructure service
summary: Expands Datum's platform to support full lifecycle management of bare metal.
bodyHTML: "<h3>High-Level Summary</h3><p>This enhancement ...</p>"
state: in-progress
categories: [build]
labels: [Build]
issueType: Enhancement
github:
org: datum-cloud
repository: enhancements
number: 912
url: https://github.com/datum-cloud/enhancements/issues/912
state: open
createdAt: "2026-09-30T14:12:00Z"
updatedAt: "2026-10-07T09:40:00Z"
release: hedy-2-0
votes:
total: 9
datum: 6
github: 4
trendingScore: 3.42
publicVoters:
- displayName: Ada L.
avatarURL: https://example.com/ada.png
delivery:
stage: picked-up
highestNotified: picked-up
history:
- {stage: requested, at: "2026-09-30T14:12:00Z"}
- {stage: planned, at: "2026-10-02T09:00:00Z"}
- stage: picked-up
at: "2026-10-07T09:40:00Z"
cause: datum-cloud/compute#318 opened, closes datum-cloud/compute#311
work:
total: 5
done: 3
items:
- kind: issue
ref: datum-cloud/compute#311
title: BMC inventory API
state: open
url: https://github.com/datum-cloud/compute/issues/311
pullRequests:
- {ref: datum-cloud/compute#318, state: open}
partShipped:
- {changelog: datum-cloud.datum.303, at: "2026-10-07T13:23:39Z"}
lastSyncedAt: "2026-10-08T12:00:00Z"
13 changes: 13 additions & 0 deletions config/samples/postquery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: feedback.miloapis.com/v1alpha1
kind: PostQuery
metadata:
name: in-flight-deliver
spec:
text: wildcard hostnames
filter:
state: [planning, on-deck, in-progress]
categories: [deliver]
orgs: [datum-cloud, milo-os]
sort: top
limit: 20
facets: [state, categories]
19 changes: 19 additions & 0 deletions config/samples/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Releases are written by feedback-sync. Shown here for reference.
apiVersion: feedback.miloapis.com/v1alpha1
kind: Release
metadata:
name: hedy-2-0
status:
title: "Hedy: 2.0"
codename: Hedy
version: "2.0"
dueOn: "2026-10-31"
shipped: false
descriptionHTML: "<p>...</p>"
coverImage: hedy-2-0
posts:
- datum-cloud.enhancements.912
- datum-cloud.enhancements.913
github:
url: https://github.com/datum-cloud/enhancements/milestone/14
number: 14
10 changes: 10 additions & 0 deletions config/samples/securityacknowledgement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Read-only view served from SecurityReports. Shown here for reference.
apiVersion: feedback.miloapis.com/v1alpha1
kind: SecurityAcknowledgement
metadata:
name: sec-4m8q1
status:
name: Ada L.
url: https://example.com
month: "2026-11"
severity: high
25 changes: 25 additions & 0 deletions config/samples/securityreport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: feedback.miloapis.com/v1alpha1
kind: SecurityReport
metadata:
generateName: sec-
spec:
title: Project viewer can read connector credentials
description: |
A user with the viewer role on a project can read connector credentials.
affected: connectors
stepsToReproduce: |
1. ...
impact: Credential disclosure across users in one project
attachments:
- name: poc.sh
contentType: text/x-shellscript
uploadRef: att-c71e
credit:
public: true
name: Ada L.
url: https://example.com
context:
client: patch
filedByAgent: true
organization: acme-corp
clientVersion: patch@2026.10.2
20 changes: 20 additions & 0 deletions config/samples/submission.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: feedback.miloapis.com/v1alpha1
kind: Submission
metadata:
generateName: sub-
spec:
kind: idea
title: Let me pick the region for Galactic VPC attachments
body: |
When I attach a VPC I can't choose which region it lands in.
attachments:
- name: screenshot.png
contentType: image/png
uploadRef: att-91ac
context:
client: portal
pageURL: https://cloud.datum.net/org/acme/projects/web/vpc
organization: acme-corp
project: web
requestIDs: [req-01HZX]
clientVersion: cloud-portal@2026.10.1
11 changes: 11 additions & 0 deletions config/samples/submissionreview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Body of a create on submissions/{name}/review. Staff only.
apiVersion: feedback.miloapis.com/v1alpha1
kind: SubmissionReview
metadata:
name: sub-7f3k2
spec:
decision: Approved
publicTitle: Region selection for Galactic VPC attachments
publicBody: |
### Summary
Let users choose the region when attaching a VPC.
6 changes: 6 additions & 0 deletions config/samples/submissiontosecurityreport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Body of a create on submissions/{name}/to-security-report. Staff only.
apiVersion: feedback.miloapis.com/v1alpha1
kind: SubmissionToSecurityReport
metadata:
name: sub-7f3k2
affected: connectors
8 changes: 8 additions & 0 deletions config/samples/subscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: feedback.miloapis.com/v1alpha1
kind: Subscription
metadata:
name: datum-cloud.enhancements.912
spec:
postRef:
name: datum-cloud.enhancements.912
reason: manual
8 changes: 8 additions & 0 deletions config/samples/vote.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: feedback.miloapis.com/v1alpha1
kind: Vote
metadata:
name: datum-cloud.enhancements.912
spec:
postRef:
name: datum-cloud.enhancements.912
source: portal
4 changes: 1 addition & 3 deletions internal/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ func init() {
// There is no separate internal version: register the v1alpha1 types as
// internal too so the generic registry can convert and watch them.
Scheme.AddKnownTypes(schema.GroupVersion{Group: feedbackv1alpha1.GroupName, Version: runtime.APIVersionInternal},
&feedbackv1alpha1.FeedbackSource{},
&feedbackv1alpha1.FeedbackSourceList{},
)
feedbackv1alpha1.KnownTypes()...)

unversioned := schema.GroupVersion{Group: "", Version: "v1"}
Scheme.AddUnversionedTypes(unversioned,
Expand Down
4 changes: 2 additions & 2 deletions internal/registry/feedbacksource/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ func Validate(src *feedbackv1alpha1.FeedbackSource) field.ErrorList {
}
}
for k, v := range spec.StatusMapping {
if !slices.Contains(feedbackv1alpha1.ValidPostStatuses, v) {
if !slices.Contains(feedbackv1alpha1.ValidPostStates, v) {
errs = append(errs, field.NotSupported(field.NewPath("spec", "statusMapping").Key(k), v,
feedbackv1alpha1.ValidPostStatuses))
feedbackv1alpha1.ValidPostStates))
}
}
for k, v := range spec.CategoryMapping {
Expand Down
2 changes: 1 addition & 1 deletion internal/registry/feedbacksource/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func validSource() *feedbackv1alpha1.FeedbackSource {
Milestones: &feedbackv1alpha1.MilestoneSource{Repository: "enhancements"},
Changelog: &feedbackv1alpha1.ChangelogSource{Repository: "datum", DiscussionCategory: "changelog"},
},
StatusMapping: map[string]feedbackv1alpha1.PostStatus{"": "none", "In Progress": "in-progress", "Done": "shipped"},
StatusMapping: map[string]feedbackv1alpha1.PostState{"": "none", "In Progress": "in-progress", "Done": "shipped"},
CategoryMapping: map[string]string{"Build": "build"},
},
}
Expand Down
Loading
Loading