Skip to content

Commit

Permalink
Infer secure based on the scheme provided.
Browse files Browse the repository at this point in the history
Signed-off-by: Achyut Madhusudan <amadhusu@redhat.com>
  • Loading branch information
Achyut Madhusudan committed Jul 13, 2023
1 parent 543be92 commit 6029935
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
3 changes: 1 addition & 2 deletions api/v1alpha1/dspipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ type ExternalStorage struct {
Bucket string `json:"bucket"`
Scheme string `json:"scheme"`
*S3CredentialSecret `json:"s3CredentialsSecret"`
// +kubebuilder:default:=true
// +kubebuilder:validation:Optional
Secure bool `json:"secure"`
Secure *bool `json:"secure"`
// +kubebuilder:validation:Optional
Port string `json:"port"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ spec:
scheme:
type: string
secure:
default: true
type: boolean
required:
- bucket
Expand Down
1 change: 1 addition & 0 deletions controllers/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
MinioHostPrefix = "minio"
MinioPort = "9000"
MinioScheme = "http"
MinioSecure = false
MinioDefaultBucket = "mlpipeline"
MinioPVCSize = "10Gi"

Expand Down
18 changes: 16 additions & 2 deletions controllers/dspipeline_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ type DBConnection struct {
type ObjectStorageConnection struct {
Bucket string
CredentialsSecret *dspa.S3CredentialSecret
Secure bool
Host string
Port string
Scheme string
Secure *bool
Endpoint string // scheme://host:port
AccessKeyID string
SecretAccessKey string
Expand Down Expand Up @@ -105,6 +105,10 @@ func passwordGen(n int) string {
return string(b)
}

func BoolPointer(b bool) *bool {
return &b
}

// SetupDBParams Populates the DB connection Parameters.
// If an external secret is specified, SetupDBParams will retrieve DB credentials from it.
// If DSPO is managing a dynamically created secret, then SetupDBParams generates the creds.
Expand Down Expand Up @@ -235,7 +239,15 @@ func (p *DSPAParams) SetupObjectParams(ctx context.Context, dsp *dspa.DataScienc
p.ObjectStorageConnection.Bucket = dsp.Spec.ObjectStorage.ExternalStorage.Bucket
p.ObjectStorageConnection.Host = dsp.Spec.ObjectStorage.ExternalStorage.Host
p.ObjectStorageConnection.Scheme = dsp.Spec.ObjectStorage.ExternalStorage.Scheme
p.ObjectStorageConnection.Secure = dsp.Spec.ObjectStorage.ExternalStorage.Secure

if dsp.Spec.ObjectStorage.ExternalStorage.Secure == nil {
if p.ObjectStorageConnection.Scheme == "https" {
p.ObjectStorageConnection.Secure = BoolPointer(true)
} else {
p.ObjectStorageConnection.Secure = BoolPointer(false)
}
}

// Port can be empty, which is fine.
p.ObjectStorageConnection.Port = dsp.Spec.ObjectStorage.ExternalStorage.Port
customCreds = dsp.Spec.ObjectStorage.ExternalStorage.S3CredentialSecret
Expand Down Expand Up @@ -265,6 +277,7 @@ func (p *DSPAParams) SetupObjectParams(ctx context.Context, dsp *dspa.DataScienc
)
p.ObjectStorageConnection.Port = config.MinioPort
p.ObjectStorageConnection.Scheme = config.MinioScheme

if p.Minio.S3CredentialSecret != nil {
customCreds = p.Minio.S3CredentialSecret
}
Expand Down Expand Up @@ -343,6 +356,7 @@ func (p *DSPAParams) SetupObjectParams(ctx context.Context, dsp *dspa.DataScienc
}

return nil

}

func (p *DSPAParams) SetupMLMD(ctx context.Context, dsp *dspa.DataSciencePipelinesApplication, client client.Client, log logr.Logger) error {
Expand Down

0 comments on commit 6029935

Please sign in to comment.