Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer the "secure" field in dspa based on scheme #196

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

amadhusu marked this conversation as resolved.
Show resolved Hide resolved
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
}
Loading