Files
kde-linux/minioauth/minioauth.go
Thomas Duckworth cfc528f6d0 Reintroduce OpenQA testing
Integrates OpenQA image testing into CI.

Builds images once in the imaging job, then passes the resulting image and
update channel to the OpenQA pipeline in kde-linux/os-autoinst-distri-kdelinux.

For regular test builds, upload the built ISO and a temporary sysupdate tree
to ci-artifacts on storage.kde.org. The resulting IMAGE_URL, STAGING_CHANNEL_URL
and ephemeral update signing key are exported through the imaging job dotenv
artifact so OpenQA can boot the image and run upgrade tests against the build
under test.

For protected default-branch builds, stage the release artifacts under a
per-job staging prefix in the kde-linux bucket. OpenQA tests the staged ISO
and sysupdate channel before the publish job is allowed to run.

Publishing downloads the staged artifacts, uploads the public ISO/torrent and
sysupdate assets to files.kde.org, chunks and uploads the root to the desync
chunk store, then merges the staged S3 tree into the live tree on the bucket
and regenerates the published SHA256SUMS.
2026-07-03 04:57:34 +00:00

72 lines
1.9 KiB
Go

// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-FileCopyrightText: 2025 Harald Sitter <sitter@kde.org>
// SPDX-FileCopyrightText: 2026 Thomas Duckworth <tduck@filotimoproject.org>
package minioauth
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"gopkg.in/ini.v1"
)
type AWSSection struct {
AccessKeyID string `ini:"aws_access_key_id"`
SecretKey string `ini:"aws_secret_access_key"`
SessionToken string `ini:"aws_session_token"`
}
func readConfigAWS(section string) (AWSSection, error) {
awsSection := AWSSection{}
awsConfigPath := filepath.Join(os.Getenv("HOME"), ".aws", "credentials")
cfg, err := ini.Load(awsConfigPath)
if err != nil {
return awsSection, fmt.Errorf("failed to load AWS credentials file: %w", err)
}
err = cfg.Section(section).MapTo(&awsSection)
if err != nil {
return awsSection, fmt.Errorf("failed to map AWS credentials section: %w", err)
}
return awsSection, nil
}
func Connect(endpoint string) (*minio.Client, error) {
awsSection, err := readConfigAWS("default")
if err != nil {
return nil, err
}
if awsSection.AccessKeyID == "" {
return nil, errors.New("AWS access key ID is empty")
}
if awsSection.SecretKey == "" {
return nil, errors.New("AWS secret access key is empty")
}
if awsSection.SessionToken == "" {
return nil, errors.New("AWS session token is empty")
}
minioClient, err := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(awsSection.AccessKeyID, awsSection.SecretKey, awsSection.SessionToken),
Secure: true,
TrailingHeaders: true,
})
if err != nil {
return nil, fmt.Errorf("failed to create MinIO client: %w", err)
}
return minioClient, nil
}
func ListBuckets(client *minio.Client) ([]minio.BucketInfo, error) {
return client.ListBuckets(context.Background())
}