-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add initial server implementation (source, defs, get and l…
…ist)
- Loading branch information
Showing
7 changed files
with
306 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Println(banner) | ||
} | ||
|
||
const banner = ` | ||
) ) | ||
( ( | ||
|======| | ||
| | | ||
| cup | | ||
'------'` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package core | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/xeipuuv/gojsonschema" | ||
) | ||
|
||
// ResourceDefinition represents a definition of a particular resource Kind and its versions | ||
type ResourceDefinition struct { | ||
APIVersion string `json:"apiVersion"` | ||
Kind string `json:"kind"` | ||
Metadata Metadata `json:"metadata"` | ||
Names Names `json:"names"` | ||
Spec ResourceDefinitionSpec `json:"spec"` | ||
} | ||
|
||
type Names struct { | ||
Kind string `json:"kind"` | ||
Singular string `json:"singular"` | ||
Plural string `json:"plural"` | ||
} | ||
|
||
type ResourceDefinitionSpec struct { | ||
Group string `json:"group"` | ||
Controller ResourceDefinitionController `json:"controller"` | ||
Versions map[string]*gojsonschema.Schema `json:"schema"` | ||
} | ||
|
||
type ResourceDefinitionController struct { | ||
Path string `json:"path"` | ||
} | ||
|
||
// Metadata contains Resource metadata include name, labels and annotations | ||
type Metadata struct { | ||
Name string `json:"name"` | ||
Labels map[string]string `json:"labels"` | ||
Annotations map[string]string `json:"annotations"` | ||
} | ||
|
||
// Resource is the core API resource definition used to communicate | ||
// the various available resources on the wire | ||
type Resource struct { | ||
APIVersion string `json:"apiVersion"` | ||
Kind string `json:"kind"` | ||
Metadata NamespacedMetadata `json:"metadata"` | ||
Spec json.RawMessage `json:"spec"` | ||
} | ||
|
||
// NamespacedMetadata contains Resource metadata include namespace, name, labels and annotations | ||
type NamespacedMetadata struct { | ||
Namespace string `json:"namespace"` | ||
Name string `json:"name"` | ||
Labels map[string]string `json:"labels"` | ||
Annotations map[string]string `json:"annotations"` | ||
} |
Oops, something went wrong.