cli: split image into oss and enterprise (#1788)

This commit is contained in:
3u13r 2023-05-23 10:49:47 +02:00 committed by GitHub
parent cfef384f36
commit 6062b10035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 21 deletions

View File

@ -42,10 +42,6 @@ runs:
username: ${{ github.actor }}
password: ${{ inputs.githubToken }}
- name: Upload referenced container images
shell: bash
run: bazelisk run //bazel/release:push
- name: MiniConstellation E2E
shell: bash
env:
@ -53,4 +49,4 @@ runs:
ARM_SUBSCRIPTION_ID: ${{ inputs.azureSubscriptionID }}
ARM_TENANT_ID: ${{ inputs.azureTenantID }}
run: |
bazelisk run //e2e/miniconstellation:remote_test
bazelisk run //e2e/miniconstellation:push_remote_test

View File

@ -80,11 +80,11 @@ jobs:
defaultVersionReg='defaultImage = \"[^\"]*\"'
# Ensure regexp matches (otherwise the file was changed or the workflow is broken).
grep -E "${defaultVersionReg}" internal/config/image.go
grep -E "${defaultVersionReg}" internal/config/image_enterprise.go
# Update version.
newVersion="ref\/${{ steps.version.outputs.branchName }}\/stream\/nightly\/${{ steps.version.outputs.version }}"
sed -i "s/${defaultVersionReg}/defaultImage = \"${newVersion}\"/" internal/config/image.go
sed -i "s/${defaultVersionReg}/defaultImage = \"${newVersion}\"/" internal/config/image_enterprise.go
- name: Build generateMeasurements tool
working-directory: internal/attestation/measurements/measurement-generator

View File

@ -147,12 +147,11 @@ jobs:
defaultVersionReg='defaultImage = \"[^\"]*\"'
# Ensure regexp matches (otherwise the file was changed or the workflow is broken).
grep -E "${defaultVersionReg}" internal/config/image.go
grep -E "${defaultVersionReg}" internal/config/image_enterprise.go
# Update version.
sed -i "s/${defaultVersionReg}/defaultImage = \"${VERSION}\"/" internal/config/image.go
git add internal/config/image.go
sed -i "s/${defaultVersionReg}/defaultImage = \"${VERSION}\"/" internal/config/image_enterprise.go
git add internal/config/image_enterprise.go
- name: Commit
run: |
git config --global user.name "edgelessci"

View File

@ -428,7 +428,7 @@ func (c *Creator) createQEMU(ctx context.Context, cl terraformClient, lv libvirt
// if no libvirt URI is specified, start a libvirt container
case libvirtURI == "":
if err := lv.Start(ctx, opts.Config.Name, opts.Config.Provider.QEMU.LibvirtContainerImage); err != nil {
return clusterid.File{}, err
return clusterid.File{}, fmt.Errorf("start libvirt container: %w", err)
}
libvirtURI = libvirt.LibvirtTCPConnectURI
@ -485,7 +485,7 @@ func (c *Creator) createQEMU(ctx context.Context, cl terraformClient, lv libvirt
}
if err := cl.PrepareWorkspace(path.Join("terraform", strings.ToLower(cloudprovider.QEMU.String())), &vars); err != nil {
return clusterid.File{}, err
return clusterid.File{}, fmt.Errorf("prepare workspace: %w", err)
}
// Allow rollback of QEMU Terraform workspace from this point on
@ -493,7 +493,7 @@ func (c *Creator) createQEMU(ctx context.Context, cl terraformClient, lv libvirt
tfOutput, err := cl.CreateCluster(ctx, opts.TFLogLevel)
if err != nil {
return clusterid.File{}, err
return clusterid.File{}, fmt.Errorf("create cluster: %w", err)
}
return clusterid.File{

View File

@ -10,6 +10,7 @@ package libvirt
import (
"context"
"errors"
"fmt"
"io"
"github.com/docker/docker/api/types"
@ -43,7 +44,7 @@ func New() *Runner {
func (r *Runner) Start(ctx context.Context, name, imageName string) error {
docker, err := docker.NewClientWithOpts(docker.FromEnv, docker.WithAPIVersionNegotiation())
if err != nil {
return err
return fmt.Errorf("failed to create docker client: %w", err)
}
defer docker.Close()
@ -65,7 +66,7 @@ func (r *Runner) Start(ctx context.Context, name, imageName string) error {
if len(images) == 0 {
reader, err := docker.ImagePull(ctx, imageName, types.ImagePullOptions{})
if err != nil {
return err
return fmt.Errorf("failed to pull image %q: %w", imageName, err)
}
defer reader.Close()
if _, err := io.Copy(io.Discard, reader); err != nil {
@ -88,11 +89,11 @@ func (r *Runner) Start(ctx context.Context, name, imageName string) error {
nil,
containerName,
); err != nil {
return err
return fmt.Errorf("failed to create container: %w", err)
}
if err := docker.ContainerStart(ctx, containerName, types.ContainerStartOptions{}); err != nil {
_ = docker.ContainerRemove(ctx, containerName, types.ContainerRemoveOptions{Force: true})
return err
return fmt.Errorf("failed to start container: %w", err)
}
// write the name of the container to a file so we can remove it later

View File

@ -411,13 +411,13 @@ func (c *Client) writeVars(vars Variables) error {
// If a variables file already exists, check if it's the same as we're expecting, so we can continue using it.
varsContent, err := c.file.Read(pathToVarsFile)
if err != nil {
return err
return fmt.Errorf("read variables file: %w", err)
}
if vars.String() != string(varsContent) {
return ErrTerraformWorkspaceExistsWithDifferentVariables
}
} else if err != nil {
return err
return fmt.Errorf("write variables file: %w", err)
}
return nil

View File

@ -1,3 +1,4 @@
load("@com_github_ash2k_bazel_tools//multirun:def.bzl", "multirun")
load("//bazel/sh:def.bzl", "sh_template")
filegroup(
@ -31,3 +32,13 @@ sh_template(
":dependencies_lib",
],
)
multirun(
name = "push_remote_test",
commands = [
"//bazel/release:push",
":remote_test",
],
jobs = 1, # execute sequentially
visibility = ["//visibility:public"],
)

View File

@ -8,7 +8,10 @@ go_library(
"azure.go",
"config.go",
"config_doc.go",
"image.go",
# keep
"image_enterprise.go",
# keep
"image_oss.go",
"qemu.go",
"validation.go",
],

View File

@ -1,3 +1,5 @@
//go:build enterprise
/*
Copyright (c) Edgeless Systems GmbH

View File

@ -0,0 +1,14 @@
//go:build !enterprise
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package config
const (
// defaultImage is the default image to use.
defaultImage = ""
)