mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-10-08 16:48:37 -04:00
joinservice: use configmap for k8s components
This commit is contained in:
parent
e6c4bb3406
commit
0c71cc77f6
20 changed files with 662 additions and 98 deletions
|
@ -7,11 +7,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
package versions
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
"github.com/edgelesssys/constellation/v2/joinservice/joinproto"
|
||||
)
|
||||
|
||||
// ValidK8sVersion represents any of the three currently supported k8s versions.
|
||||
|
@ -261,8 +263,8 @@ type ComponentVersion struct {
|
|||
// ComponentVersions is a list of ComponentVersion.
|
||||
type ComponentVersions []ComponentVersion
|
||||
|
||||
// NewComponentVersionsFromProto converts a protobuf KubernetesVersion to ComponentVersions.
|
||||
func NewComponentVersionsFromProto(protoComponents []*initproto.KubernetesComponent) ComponentVersions {
|
||||
// NewComponentVersionsFromInitProto converts a protobuf KubernetesVersion to ComponentVersions.
|
||||
func NewComponentVersionsFromInitProto(protoComponents []*initproto.KubernetesComponent) ComponentVersions {
|
||||
components := ComponentVersions{}
|
||||
for _, protoComponent := range protoComponents {
|
||||
if protoComponent == nil {
|
||||
|
@ -273,8 +275,20 @@ func NewComponentVersionsFromProto(protoComponents []*initproto.KubernetesCompon
|
|||
return components
|
||||
}
|
||||
|
||||
// ToProto converts a ComponentVersions to a protobuf KubernetesVersion.
|
||||
func (c ComponentVersions) ToProto() []*initproto.KubernetesComponent {
|
||||
// NewComponentVersionsFromJoinProto converts a protobuf KubernetesVersion to ComponentVersions.
|
||||
func NewComponentVersionsFromJoinProto(protoComponents []*joinproto.KubernetesComponent) ComponentVersions {
|
||||
components := ComponentVersions{}
|
||||
for _, protoComponent := range protoComponents {
|
||||
if protoComponent == nil {
|
||||
continue
|
||||
}
|
||||
components = append(components, ComponentVersion{URL: protoComponent.Url, Hash: protoComponent.Hash, InstallPath: protoComponent.InstallPath, Extract: protoComponent.Extract})
|
||||
}
|
||||
return components
|
||||
}
|
||||
|
||||
// ToInitProto converts a ComponentVersions to a protobuf KubernetesVersion.
|
||||
func (c ComponentVersions) ToInitProto() []*initproto.KubernetesComponent {
|
||||
protoComponents := []*initproto.KubernetesComponent{}
|
||||
for _, component := range c {
|
||||
protoComponents = append(protoComponents, &initproto.KubernetesComponent{Url: component.URL, Hash: component.Hash, InstallPath: component.InstallPath, Extract: component.Extract})
|
||||
|
@ -282,6 +296,25 @@ func (c ComponentVersions) ToProto() []*initproto.KubernetesComponent {
|
|||
return protoComponents
|
||||
}
|
||||
|
||||
// ToJoinProto converts a ComponentVersions to a protobuf KubernetesVersion.
|
||||
func (c ComponentVersions) ToJoinProto() []*joinproto.KubernetesComponent {
|
||||
protoComponents := []*joinproto.KubernetesComponent{}
|
||||
for _, component := range c {
|
||||
protoComponents = append(protoComponents, &joinproto.KubernetesComponent{Url: component.URL, Hash: component.Hash, InstallPath: component.InstallPath, Extract: component.Extract})
|
||||
}
|
||||
return protoComponents
|
||||
}
|
||||
|
||||
// GetHash returns the hash over all component hashes.
|
||||
func (c ComponentVersions) GetHash() string {
|
||||
sha := sha256.New()
|
||||
for _, component := range c {
|
||||
sha.Write([]byte(component.Hash))
|
||||
}
|
||||
|
||||
return fmt.Sprintf("sha256:%x", sha.Sum(nil))
|
||||
}
|
||||
|
||||
// versionFromDockerImage returns the version tag from the image name, e.g. "v1.22.2" from "foocr.io/org/repo:v1.22.2@sha256:3009fj0...".
|
||||
func versionFromDockerImage(imageName string) string {
|
||||
beforeAt, _, _ := strings.Cut(imageName, "@")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue