Skip to content

Commit

Permalink
add Network info to Component
Browse files Browse the repository at this point in the history
add IsPublic to Port
  • Loading branch information
nilsgstrabo committed Sep 25, 2024
1 parent 2702622 commit 3a7ab2a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
23 changes: 21 additions & 2 deletions api/deployments/models/component_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/equinor/radix-api/api/secrets/suffix"
"github.com/equinor/radix-api/api/utils/secret"
"github.com/equinor/radix-common/utils/pointers"
"github.com/equinor/radix-common/utils/slice"
"github.com/equinor/radix-operator/pkg/apis/defaults"
"github.com/equinor/radix-operator/pkg/apis/deployment"
"github.com/equinor/radix-operator/pkg/apis/ingress"
Expand Down Expand Up @@ -107,8 +108,9 @@ func (b *componentBuilder) WithComponent(component radixv1.RadixCommonDeployComp
if component.GetPorts() != nil {
for _, port := range component.GetPorts() {
ports = append(ports, Port{
Name: port.Name,
Port: port.Port,
Name: port.Name,
Port: port.Port,
IsPublic: port.Name == component.GetPublicPort(),
})
}
}
Expand Down Expand Up @@ -177,6 +179,23 @@ func (b *componentBuilder) WithComponent(component radixv1.RadixCommonDeployComp
}

b.environmentVariables = component.GetEnvironmentVariables()

if network := component.GetNetwork(); network != nil {
b.network = &Network{}

if ingress := network.Ingress; ingress != nil {
b.network.Ingress = &Ingress{}

if publicIngress := ingress.Public; publicIngress != nil {
b.network.Ingress.Public = &IngressPublic{}

if allow := publicIngress.Allow; allow != nil {
b.network.Ingress.Public.Allow = slice.Map(*allow, func(v radixv1.IPOrCIDR) string { return string(v) })
}
}
}
}

return b
}

Expand Down
8 changes: 7 additions & 1 deletion api/deployments/models/component_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,15 @@ type Port struct {

// Component port number. From radixconfig.yaml
//
// required: false
// required: true
// example: 8080
Port int32 `json:"port"`

// IsPublic indicates that the port is accessible from the Internet by proxying traffic from 443
//
// required: true
// example: true
IsPublic bool `json:"isPublic"`
}

// ComponentSummary describe a component part of a deployment
Expand Down
10 changes: 9 additions & 1 deletion swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7374,9 +7374,17 @@
"description": "Port describe a port of a component",
"type": "object",
"required": [
"name"
"name",
"port",
"isPublic"
],
"properties": {
"isPublic": {
"description": "IsPublic indicates that the port is accessible from the Internet by proxying traffic from 443",
"type": "boolean",
"x-go-name": "IsPublic",
"example": true
},
"name": {
"description": "Component port name. From radixconfig.yaml",
"type": "string",
Expand Down

0 comments on commit 3a7ab2a

Please sign in to comment.