Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Resource Tags #96

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
4 changes: 2 additions & 2 deletions charts/core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for deploying Unikorn Core

type: application

version: v0.1.83
appVersion: v0.1.83
version: v0.1.84
appVersion: v0.1.84

icon: https://assets.unikorn-cloud.org/images/logos/dark-on-light/icon.svg

Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/unikorn/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ func (IPv4Prefix) OpenAPISchemaFormat() string {
return ""
}

// Tag is an arbirary key/value.
type Tag struct {
// Name of the tag.
Name string `json:"name"`
// Value of the tag.
Value string `json:"value"`
}

// TagList is an ordered list of tags.
type TagList []Tag

// MachineGeneric contains common things across all machine pool types.
type MachineGeneric struct {
// Image is the region service image to deploy with.
Expand Down
36 changes: 36 additions & 0 deletions pkg/apis/unikorn/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/openapi/common.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ components:
description: A semantic version.
type: string
pattern: '^v\d+\.\d+\.\d+$'
tag:
description: An arbitrary tag name and value.
type: object
required:
- name
- value
properties:
name:
description: A unique tag name.
type: string
value:
description: The value of the tag.
type: string
tagList:
description: A list of tags.
type: array
items:
$ref: '#/components/schemas/tag'
resourceMetadata:
description: Resource metadata valid for all API resource reads and writes.
required:
Expand All @@ -57,6 +75,8 @@ components:
description: |-
The resource description, this optionally augments the name with more context.
type: string
tags:
$ref: '#/components/schemas/tagList'
staticResourceMetadata:
description: |
This metadata is for resources that just exist, and don't require
Expand Down
58 changes: 30 additions & 28 deletions pkg/openapi/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions pkg/openapi/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions pkg/server/conversion/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,49 @@ func UpdateObjectMetadata(required, current metav1.Object, requiredAnnotations,

return nil
}

func ConvertTag(in unikornv1.Tag) openapi.Tag {
out := openapi.Tag{
Name: in.Name,
Value: in.Value,
}

return out
}

func ConvertTags(in unikornv1.TagList) openapi.TagList {
if in == nil {
return nil
}

out := make(openapi.TagList, len(in))

for i := range in {
out[i] = ConvertTag(in[i])
}

return out
}

func GenerateTag(in openapi.Tag) unikornv1.Tag {
out := unikornv1.Tag{
Name: in.Name,
Value: in.Value,
}

return out
}

func GenerateTagList(in *openapi.TagList) unikornv1.TagList {
if in == nil {
return nil
}

out := make(unikornv1.TagList, len(*in))

for i := range *in {
out[i] = GenerateTag((*in)[i])
}

return out
}