Skip to content

Commit

Permalink
Merge pull request #31 from schrodit/fix/minio-ssl
Browse files Browse the repository at this point in the history
Add ssl support for s3 instances
  • Loading branch information
Tim Schrodi authored Mar 14, 2019
2 parents f29bd33 + 1ccb0d3 commit 78702b6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ spec:
containers:
- name: testmachinery-controller
image: "{{ .Values.controller.image }}:{{ .Values.controller.tag }}"
imagePullPolicy: Always
{{ if .Values.local.enabled }}
command: ["/testmachinery-controller", "-insecure=true"]
{{end}}
Expand Down
3 changes: 3 additions & 0 deletions cmd/testrunner/cmd/runtemplate/run_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
outputFilePath string
elasticSearchConfigName string
s3Endpoint string
s3SSL bool
concourseOnErrorDir string

testrunChartPath string
Expand Down Expand Up @@ -98,6 +99,7 @@ var runCmd = &cobra.Command{
OutputFile: outputFilePath,
ESConfigName: elasticSearchConfigName,
S3Endpoint: s3Endpoint,
S3SSL: s3SSL,
ConcourseOnErrorDir: concourseOnErrorDir,
}

Expand Down Expand Up @@ -161,6 +163,7 @@ func init() {
runCmd.Flags().StringVar(&outputFilePath, "output-file-path", "./testout", "The filepath where the summary should be written to.")
runCmd.Flags().StringVar(&elasticSearchConfigName, "es-config-name", "sap_internal", "The elasticsearch secret-server config name.")
runCmd.Flags().StringVar(&s3Endpoint, "s3-endpoint", os.Getenv("S3_ENDPOINT"), "S3 endpoint of the testmachinery cluster.")
runCmd.Flags().BoolVar(&s3SSL, "s3-ssl", false, "S3 has SSL enabled.")
runCmd.Flags().StringVar(&concourseOnErrorDir, "concourse-onError-dir", os.Getenv("ON_ERROR_DIR"), "On error dir which is used by Concourse.")

// parameter flags
Expand Down
2 changes: 1 addition & 1 deletion pkg/testmachinery/garbagecollection/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewObjectStore() (*ObjectStore, error) {

cfg := testmachinery.GetConfig().ObjectStore

minioClient, err := minio.New(cfg.Endpoint, cfg.AccessKey, cfg.SecretKey, false)
minioClient, err := minio.New(cfg.Endpoint, cfg.AccessKey, cfg.SecretKey, cfg.SSL)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/testmachinery/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type TmConfiguration struct {
// ObjectStoreConfig is an object containing the ObjectStore specific configuration
type ObjectStoreConfig struct {
Endpoint string
SSL bool
AccessKey string
SecretKey string
BucketName string
Expand Down
8 changes: 4 additions & 4 deletions pkg/testrunner/result/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func Output(config *Config, tmKubeconfigPath, namespace string, tr *tmv1beta1.Te
if config.OutputFile == "" {
return nil
}
var s3Endpoint = config.S3Endpoint

metadata.TestrunID = tr.Name

Expand All @@ -59,7 +58,7 @@ func Output(config *Config, tmKubeconfigPath, namespace string, tr *tmv1beta1.Te
return err
}

osConfig, err := getOSConfig(tmKubeconfigPath, s3Endpoint, namespace)
osConfig, err := getOSConfig(tmKubeconfigPath, namespace, config.S3Endpoint, config.S3SSL)
if err != nil {
log.Warnf("Cannot get exported Test results of steps: %s", err.Error())
} else {
Expand Down Expand Up @@ -125,7 +124,7 @@ func getTestrunSummary(tr *tmv1beta1.Testrun, metadata *Metadata) (*elasticsearc

func getExportedDocuments(cfg *testmachinery.ObjectStoreConfig, status tmv1beta1.TestrunStatus, metadata *Metadata) []byte {

minioClient, err := minio.New(cfg.Endpoint, cfg.AccessKey, cfg.SecretKey, false)
minioClient, err := minio.New(cfg.Endpoint, cfg.AccessKey, cfg.SecretKey, cfg.SSL)
if err != nil {
log.Errorf("Error creating minio client %s: %s", cfg.Endpoint, err.Error())
return nil
Expand Down Expand Up @@ -226,7 +225,7 @@ func writeToFile(fielPath string, data []byte) error {
return nil
}

func getOSConfig(tmKubeconfigPath, minioEndpoint, namespace string) (*testmachinery.ObjectStoreConfig, error) {
func getOSConfig(tmKubeconfigPath, namespace, minioEndpoint string, ssl bool) (*testmachinery.ObjectStoreConfig, error) {
clusterClient, err := kubernetes.NewClientFromFile(tmKubeconfigPath, nil, client.Options{})
if err != nil {
return nil, fmt.Errorf("Cannot create client for %s: %s", tmKubeconfigPath, err.Error())
Expand All @@ -242,6 +241,7 @@ func getOSConfig(tmKubeconfigPath, minioEndpoint, namespace string) (*testmachin

return &testmachinery.ObjectStoreConfig{
Endpoint: minioEndpoint,
SSL: ssl,
AccessKey: string(minioSecrets.Data["accessKey"]),
SecretKey: string(minioSecrets.Data["secretKey"]),
BucketName: minioConfig.Data["objectstore.bucketName"],
Expand Down
9 changes: 6 additions & 3 deletions pkg/testrunner/result/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ import (

// Config represents the configuration for collecting and storing results from a testrun.
type Config struct {
// outputFilePath is the path where the testresult is written to.
// OutputFilePath is the path where the testresult is written to.
OutputFile string

// config name of the elastic search to store the test results.
// Config name of the elasticsearch instance to store the test results.
ESConfigName string

// Endpint of the s3 storage of the testmachinery.
// Endpoint of the s3 storage of the testmachinery.
S3Endpoint string

// S3SSL indicates whether the S3 instance is SSL secured or not.
S3SSL bool

// Path to the error directory of concourse to put the notify.cfg in.
ConcourseOnErrorDir string
}
Expand Down

0 comments on commit 78702b6

Please sign in to comment.