Skip to content

Commit c414cf6

Browse files
Merge pull request opendatahub-io#196 from amadhusu/am/157
Infer the "secure" field in dspa based on scheme
2 parents 7f5f983 + f1ca05c commit c414cf6

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

api/v1alpha1/dspipeline_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,8 @@ type ExternalStorage struct {
215215
Bucket string `json:"bucket"`
216216
Scheme string `json:"scheme"`
217217
*S3CredentialSecret `json:"s3CredentialsSecret"`
218-
// +kubebuilder:default:=true
219218
// +kubebuilder:validation:Optional
220-
Secure bool `json:"secure"`
219+
Secure *bool `json:"secure"`
221220
// +kubebuilder:validation:Optional
222221
Port string `json:"port"`
223222
}

config/crd/bases/datasciencepipelinesapplications.opendatahub.io_datasciencepipelinesapplications.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ spec:
457457
scheme:
458458
type: string
459459
secure:
460-
default: true
461460
type: boolean
462461
required:
463462
- bucket

controllers/dspipeline_params.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
mf "github.com/manifestival/manifestival"
2828
dspa "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
2929
"github.com/opendatahub-io/data-science-pipelines-operator/controllers/config"
30+
"github.com/opendatahub-io/data-science-pipelines-operator/controllers/util"
3031
v1 "k8s.io/api/core/v1"
3132
apierrs "k8s.io/apimachinery/pkg/api/errors"
3233
"k8s.io/apimachinery/pkg/api/resource"
@@ -63,10 +64,10 @@ type DBConnection struct {
6364
type ObjectStorageConnection struct {
6465
Bucket string
6566
CredentialsSecret *dspa.S3CredentialSecret
66-
Secure bool
6767
Host string
6868
Port string
6969
Scheme string
70+
Secure *bool
7071
Endpoint string // scheme://host:port
7172
AccessKeyID string
7273
SecretAccessKey string
@@ -235,7 +236,17 @@ func (p *DSPAParams) SetupObjectParams(ctx context.Context, dsp *dspa.DataScienc
235236
p.ObjectStorageConnection.Bucket = dsp.Spec.ObjectStorage.ExternalStorage.Bucket
236237
p.ObjectStorageConnection.Host = dsp.Spec.ObjectStorage.ExternalStorage.Host
237238
p.ObjectStorageConnection.Scheme = dsp.Spec.ObjectStorage.ExternalStorage.Scheme
238-
p.ObjectStorageConnection.Secure = dsp.Spec.ObjectStorage.ExternalStorage.Secure
239+
240+
if dsp.Spec.ObjectStorage.ExternalStorage.Secure == nil {
241+
if p.ObjectStorageConnection.Scheme == "https" {
242+
p.ObjectStorageConnection.Secure = util.BoolPointer(true)
243+
} else {
244+
p.ObjectStorageConnection.Secure = util.BoolPointer(false)
245+
}
246+
} else {
247+
p.ObjectStorageConnection.Secure = dsp.Spec.ObjectStorage.ExternalStorage.Secure
248+
}
249+
239250
// Port can be empty, which is fine.
240251
p.ObjectStorageConnection.Port = dsp.Spec.ObjectStorage.ExternalStorage.Port
241252
customCreds = dsp.Spec.ObjectStorage.ExternalStorage.S3CredentialSecret
@@ -265,6 +276,8 @@ func (p *DSPAParams) SetupObjectParams(ctx context.Context, dsp *dspa.DataScienc
265276
)
266277
p.ObjectStorageConnection.Port = config.MinioPort
267278
p.ObjectStorageConnection.Scheme = config.MinioScheme
279+
p.ObjectStorageConnection.Secure = util.BoolPointer(false)
280+
268281
if p.Minio.S3CredentialSecret != nil {
269282
customCreds = p.Minio.S3CredentialSecret
270283
}
@@ -343,6 +356,7 @@ func (p *DSPAParams) SetupObjectParams(ctx context.Context, dsp *dspa.DataScienc
343356
}
344357

345358
return nil
359+
346360
}
347361

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

controllers/util/util.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ func GetDeploymentCondition(status appsv1.DeploymentStatus, condType appsv1.Depl
4040
}
4141
return nil
4242
}
43+
44+
func BoolPointer(b bool) *bool {
45+
return &b
46+
}

0 commit comments

Comments
 (0)