Skip to content

Commit

Permalink
Merge pull request #196 from amadhusu/am/157
Browse files Browse the repository at this point in the history
Infer the "secure" field in dspa based on scheme
  • Loading branch information
openshift-merge-robot authored Jul 14, 2023
2 parents 7f5f983 + f1ca05c commit c414cf6
Show file tree
Hide file tree
Showing 4 changed files with 21 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
18 changes: 16 additions & 2 deletions controllers/dspipeline_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
mf "github.com/manifestival/manifestival"
dspa "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
"github.com/opendatahub-io/data-science-pipelines-operator/controllers/config"
"github.com/opendatahub-io/data-science-pipelines-operator/controllers/util"
v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -63,10 +64,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 @@ -235,7 +236,17 @@ 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 = util.BoolPointer(true)
} else {
p.ObjectStorageConnection.Secure = util.BoolPointer(false)
}
} else {
p.ObjectStorageConnection.Secure = dsp.Spec.ObjectStorage.ExternalStorage.Secure
}

// 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 +276,8 @@ func (p *DSPAParams) SetupObjectParams(ctx context.Context, dsp *dspa.DataScienc
)
p.ObjectStorageConnection.Port = config.MinioPort
p.ObjectStorageConnection.Scheme = config.MinioScheme
p.ObjectStorageConnection.Secure = util.BoolPointer(false)

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
4 changes: 4 additions & 0 deletions controllers/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ func GetDeploymentCondition(status appsv1.DeploymentStatus, condType appsv1.Depl
}
return nil
}

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

0 comments on commit c414cf6

Please sign in to comment.