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

Added ext dns aliases to application (#600) #601

Merged
merged 1 commit into from
Feb 28, 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
5 changes: 5 additions & 0 deletions api/applications/models/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ type Application struct {
// required: false
DNSAliases []DNSAlias `json:"dnsAliases,omitempty"`

// List of external DNS names and which component and environment incoming requests shall be routed to.
//
// required: false
DNSExternalAliases []DNSExternalAlias `json:"dnsExternalAliases,omitempty"`

// App alias showing nicer endpoint for application
//
// required: false
Expand Down
23 changes: 23 additions & 0 deletions api/applications/models/external_dns_alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package models

// DNSExternalAlias holds public external DNS alias information
// swagger:model DNSExternalAlias
type DNSExternalAlias struct {
// URL the public endpoint
//
// required: true
// example: https://my-app.equinor.com
URL string `json:"url"`

// ComponentName the component exposing the endpoint
//
// required: true
// example: frontend
ComponentName string `json:"componentName"`

// EnvironmentName the environment hosting the endpoint
//
// required: true
// example: prod
EnvironmentName string `json:"environmentName"`
}
13 changes: 7 additions & 6 deletions api/models/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
// BuildApplication builds an Application model.
func BuildApplication(rr *radixv1.RadixRegistration, ra *radixv1.RadixApplication, reList []radixv1.RadixEnvironment, rdList []radixv1.RadixDeployment, rjList []radixv1.RadixJob, ingressList []networkingv1.Ingress, userIsAdmin bool, dnsAliases []applicationModels.DNSAlias) *applicationModels.Application {
application := applicationModels.Application{
Name: rr.Name,
Registration: *BuildApplicationRegistration(rr),
Jobs: BuildJobSummaryList(rjList),
AppAlias: BuildApplicationAlias(ingressList, reList),
UserIsAdmin: userIsAdmin,
DNSAliases: dnsAliases,
Name: rr.Name,
Registration: *BuildApplicationRegistration(rr),
Jobs: BuildJobSummaryList(rjList),
AppAlias: BuildApplicationAlias(ingressList, reList),
UserIsAdmin: userIsAdmin,
DNSAliases: dnsAliases,
DNSExternalAliases: BuildDNSExternalAliases(ra),
}
if ra != nil {
application.Environments = BuildEnvironmentSummaryList(rr, ra, reList, rdList, rjList)
Expand Down
21 changes: 21 additions & 0 deletions api/models/external_dns_alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package models

import (
"github.com/equinor/radix-api/api/applications/models"
"github.com/equinor/radix-common/utils/slice"
radixv1 "github.com/equinor/radix-operator/pkg/apis/radix/v1"
)

// BuildDNSExternalAliases builds DNSExternalAliases model list
func BuildDNSExternalAliases(ra *radixv1.RadixApplication) []models.DNSExternalAlias {
if ra == nil {
return nil
}
return slice.Reduce(ra.Spec.DNSExternalAlias, make([]models.DNSExternalAlias, 0), func(acc []models.DNSExternalAlias, externalAlias radixv1.ExternalAlias) []models.DNSExternalAlias {
return append(acc, models.DNSExternalAlias{
URL: externalAlias.Alias,
ComponentName: externalAlias.Component,
EnvironmentName: externalAlias.Environment,
})
})
}
38 changes: 38 additions & 0 deletions swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5022,6 +5022,14 @@
},
"x-go-name": "DNSAliases"
},
"dnsExternalAliases": {
"description": "List of external DNS names and which component and environment incoming requests shall be routed to.",
"type": "array",
"items": {
"$ref": "#/definitions/DNSExternalAlias"
},
"x-go-name": "DNSExternalAliases"
},
"environments": {
"description": "Environments List of environments for this application",
"type": "array",
Expand Down Expand Up @@ -5726,6 +5734,36 @@
},
"x-go-package": "github.com/equinor/radix-api/api/applications/models"
},
"DNSExternalAlias": {
"description": "DNSExternalAlias holds public external DNS alias information",
"type": "object",
"required": [
"url",
"componentName",
"environmentName"
],
"properties": {
"componentName": {
"description": "ComponentName the component exposing the endpoint",
"type": "string",
"x-go-name": "ComponentName",
"example": "frontend"
},
"environmentName": {
"description": "EnvironmentName the environment hosting the endpoint",
"type": "string",
"x-go-name": "EnvironmentName",
"example": "prod"
},
"url": {
"description": "URL the public endpoint",
"type": "string",
"x-go-name": "URL",
"example": "https://my-app.equinor.com"
}
},
"x-go-package": "github.com/equinor/radix-api/api/applications/models"
},
"DeployKeyAndSecret": {
"description": "DeployKeyAndSecret Holds generated public deploy key and shared secret",
"type": "object",
Expand Down
Loading