From 2702622740079dfdbc57045fee03d613731dde90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Gustav=20Str=C3=A5b=C3=B8?= Date: Wed, 25 Sep 2024 12:35:35 +0200 Subject: [PATCH] add network to component model --- api/deployments/models/component_builder.go | 2 + .../models/component_deployment.go | 32 +++++++++++++++ go.mod | 2 +- go.sum | 4 +- swaggerui/html/swagger.json | 41 +++++++++++++++++++ 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/api/deployments/models/component_builder.go b/api/deployments/models/component_builder.go index deb1a02a..632b0caa 100644 --- a/api/deployments/models/component_builder.go +++ b/api/deployments/models/component_builder.go @@ -55,6 +55,7 @@ type componentBuilder struct { resources *radixv1.ResourceRequirements runtime *radixv1.Runtime replicasOverride *int + network *Network } func (b *componentBuilder) WithStatus(status ComponentStatus) ComponentBuilder { @@ -265,6 +266,7 @@ func (b *componentBuilder) BuildComponent() (*Component, error) { CommitID: variables[defaults.RadixCommitHashEnvironmentVariable], GitTags: variables[defaults.RadixGitTagsEnvironmentVariable], Runtime: b.buildRuntimeModel(), + Network: b.network, } if b.resources != nil && (len(b.resources.Limits) > 0 || len(b.resources.Requests) > 0) { component.Resources = pointers.Ptr(ConvertRadixResourceRequirements(*b.resources)) diff --git a/api/deployments/models/component_deployment.go b/api/deployments/models/component_deployment.go index ae95f58b..4ba69e8b 100644 --- a/api/deployments/models/component_deployment.go +++ b/api/deployments/models/component_deployment.go @@ -138,6 +138,38 @@ type Component struct { // Runtime requirements for the component or job Runtime *Runtime `json:"runtime,omitempty"` + + // Network configuration for the component + // + // required: false + Network *Network `json:"network,omitempty"` +} + +// Network describes network configuration for a component +// swagger:model Network +type Network struct { + // Ingress configuration + // + // required: false + Ingress *Ingress `json:"ingress,omitempty"` +} + +// Ingress describes ingress configuration for a component +// swagger:model Ingress +type Ingress struct { + // Public ingress configuration + // + // required: false + Public *IngressPublic `json:"public,omitempty"` +} + +// IngressPublic describes public ingress configuration for a component +// swagger:model IngressPublic +type IngressPublic struct { + // List of allowed IP addresses or CIDRs. All traffic is allowed if list is empty. + // + // required: true + Allow []string `json:"allow"` } // ExternalDNS describes an external DNS entry for a component diff --git a/go.mod b/go.mod index 2f2b8898..8c8a0366 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/cert-manager/cert-manager v1.15.0 github.com/equinor/radix-common v1.9.5 github.com/equinor/radix-job-scheduler v1.11.0 - github.com/equinor/radix-operator v1.59.1 + github.com/equinor/radix-operator v1.61.0 github.com/evanphx/json-patch/v5 v5.9.0 github.com/felixge/httpsnoop v1.0.4 github.com/golang-jwt/jwt/v5 v5.2.1 diff --git a/go.sum b/go.sum index a34ae571..008033ba 100644 --- a/go.sum +++ b/go.sum @@ -87,8 +87,8 @@ github.com/equinor/radix-common v1.9.5 h1:p1xldkYUoavwIMguoxxOyVkOXLPA6K8qMsgzez github.com/equinor/radix-common v1.9.5/go.mod h1:+g0Wj0D40zz29DjNkYKVmCVeYy4OsFWKI7Qi9rA6kpY= github.com/equinor/radix-job-scheduler v1.11.0 h1:8wCmXOVl/1cto8q2WJQEE06Cw68/QmfoifYVR49vzkY= github.com/equinor/radix-job-scheduler v1.11.0/go.mod h1:yPXn3kDcMY0Z3kBkosjuefsdY1x2g0NlBeybMmHz5hc= -github.com/equinor/radix-operator v1.59.1 h1:wzb2tF4MWtGDWmyYuIv3oh17G5Bx8ztW9O+WgnI3QFc= -github.com/equinor/radix-operator v1.59.1/go.mod h1:uRW9SgVZ94hkpq87npVv2YVviRuXNJ1zgCleya1uvr8= +github.com/equinor/radix-operator v1.61.0 h1:kHWHn5p9S+wKqOTSKtju2URW5FKgAFng1p6RLRnaTmE= +github.com/equinor/radix-operator v1.61.0/go.mod h1:uRW9SgVZ94hkpq87npVv2YVviRuXNJ1zgCleya1uvr8= github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= diff --git a/swaggerui/html/swagger.json b/swaggerui/html/swagger.json index 156c8ccf..897ae2e7 100644 --- a/swaggerui/html/swagger.json +++ b/swaggerui/html/swagger.json @@ -5747,6 +5747,9 @@ "x-go-name": "Name", "example": "server" }, + "network": { + "$ref": "#/definitions/Network" + }, "notifications": { "$ref": "#/definitions/Notifications" }, @@ -6629,6 +6632,34 @@ }, "x-go-package": "github.com/equinor/radix-api/api/privateimagehubs/models" }, + "Ingress": { + "description": "Ingress describes ingress configuration for a component", + "type": "object", + "properties": { + "public": { + "$ref": "#/definitions/IngressPublic" + } + }, + "x-go-package": "github.com/equinor/radix-api/api/deployments/models" + }, + "IngressPublic": { + "description": "IngressPublic describes public ingress configuration for a component", + "type": "object", + "required": [ + "allow" + ], + "properties": { + "allow": { + "description": "List of allowed IP addresses or CIDRs. All traffic is allowed if list is empty.", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Allow" + } + }, + "x-go-package": "github.com/equinor/radix-api/api/deployments/models" + }, "Job": { "description": "Job holds general information about job", "type": "object", @@ -6887,6 +6918,16 @@ }, "x-go-package": "github.com/equinor/radix-api/api/jobs/models" }, + "Network": { + "description": "Network describes network configuration for a component", + "type": "object", + "properties": { + "ingress": { + "$ref": "#/definitions/Ingress" + } + }, + "x-go-package": "github.com/equinor/radix-api/api/deployments/models" + }, "Node": { "description": "Node Defines node attributes, where pod should be scheduled", "type": "object",