Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Data-configuration: introduce ingress/egress data slices #235

Merged
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
1 change: 1 addition & 0 deletions api/v1alpha1/edgedevice_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
"fmt"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/edgeworkload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ type NameRef struct {
}

type DataConfiguration struct {
Paths []DataPath `json:"paths,omitempty"`
Ingress []DataPath `json:"ingress,omitempty"`
Egress []DataPath `json:"egress,omitempty"`
}

type DataPath struct {
Expand Down
11 changes: 8 additions & 3 deletions api/v1alpha1/zz_generated.deepcopy.go

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

36 changes: 19 additions & 17 deletions cmd/httpapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,12 @@ import (
"crypto/x509"
"errors"
"fmt"
"net/http"
"os"

"github.com/kelseyhightower/envconfig"
obv1 "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
routev1 "github.com/openshift/api/route/v1"
managementv1alpha1 "github.com/project-flotta/flotta-operator/api/v1alpha1"
"github.com/project-flotta/flotta-operator/internal/common/metrics"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgedevice"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgedeviceset"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgedevicesignedrequest"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgeworkload"
"github.com/project-flotta/flotta-operator/internal/common/storage"
"github.com/project-flotta/flotta-operator/internal/edgeapi/configmaps"
"github.com/project-flotta/flotta-operator/internal/edgeapi/devicemetrics"
"github.com/project-flotta/flotta-operator/internal/edgeapi/images"
"github.com/project-flotta/flotta-operator/internal/edgeapi/k8sclient"
"github.com/project-flotta/flotta-operator/internal/edgeapi/yggdrasil"
"github.com/project-flotta/flotta-operator/pkg/mtls"
"github.com/project-flotta/flotta-operator/restapi"
"github.com/project-flotta/flotta-operator/restapi/operations"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -35,11 +23,25 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/record"
"net/http"
"os"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"

managementv1alpha1 "github.com/project-flotta/flotta-operator/api/v1alpha1"
"github.com/project-flotta/flotta-operator/internal/common/metrics"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgedevice"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgedeviceset"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgedevicesignedrequest"
"github.com/project-flotta/flotta-operator/internal/common/repository/edgeworkload"
"github.com/project-flotta/flotta-operator/internal/common/storage"
"github.com/project-flotta/flotta-operator/internal/edgeapi/configmaps"
"github.com/project-flotta/flotta-operator/internal/edgeapi/devicemetrics"
"github.com/project-flotta/flotta-operator/internal/edgeapi/images"
"github.com/project-flotta/flotta-operator/internal/edgeapi/k8sclient"
"github.com/project-flotta/flotta-operator/internal/edgeapi/yggdrasil"
"github.com/project-flotta/flotta-operator/pkg/mtls"
"github.com/project-flotta/flotta-operator/restapi"
"github.com/project-flotta/flotta-operator/restapi/operations"
)

const (
Expand Down
14 changes: 13 additions & 1 deletion config/crd/bases/management.project-flotta.io_edgeworkloads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ spec:
properties:
data:
properties:
paths:
egress:
items:
properties:
source:
type: string
target:
type: string
required:
- source
- target
type: object
type: array
ingress:
items:
properties:
source:
Expand Down
16 changes: 10 additions & 6 deletions internal/edgeapi/yggdrasil/configuration-assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,8 @@ func (a *configurationAssembler) toWorkloadList(ctx context.Context, logger *zap
continue
}
var data *models.DataConfiguration
if spec.Data != nil && len(spec.Data.Paths) > 0 {
var paths []*models.DataPath
for _, path := range spec.Data.Paths {
paths = append(paths, &models.DataPath{Source: path.Source, Target: path.Target})
}
data = &models.DataConfiguration{Paths: paths}
if spec.Data != nil {
data = &models.DataConfiguration{Egress: toDataPath(spec.Data.Egress), Ingress: toDataPath(spec.Data.Ingress)}
}

workload := models.Workload{
Expand Down Expand Up @@ -534,3 +530,11 @@ func (a *configurationAssembler) getMetricsReceiverConfiguration(ctx context.Con

return result, nil
}

func toDataPath(input []v1alpha1.DataPath) []*models.DataPath {
var ret []*models.DataPath
for _, path := range input {
ret = append(ret, &models.DataPath{Source: path.Source, Target: path.Target})
}
return ret
}
52 changes: 42 additions & 10 deletions models/data_configuration.go

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

2 changes: 1 addition & 1 deletion pkg/mtls/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"go.uber.org/zap"
"net/http"
"strings"
"time"

"github.com/hashicorp/go-multierror"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilrand "k8s.io/apimachinery/pkg/util/rand"
Expand Down
2 changes: 1 addition & 1 deletion pkg/mtls/ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"go.uber.org/zap"
"math/big"
"net"
"net/http"
Expand All @@ -21,6 +20,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down
16 changes: 14 additions & 2 deletions restapi/embedded_spec.go

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

6 changes: 5 additions & 1 deletion swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,11 @@ definitions:
description: Configuration for data transfer
type: object
properties:
paths:
ingress:
type: array
items:
$ref: '#/definitions/data-path'
egress:
type: array
items:
$ref: '#/definitions/data-path'
Expand Down