Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
parameter and literal map construction wrong
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
  • Loading branch information
wild-endeavor committed Aug 1, 2023
1 parent 59b147b commit 5a63652
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 58 deletions.
4 changes: 4 additions & 0 deletions flyteadmin_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ flyteadmin:
- "metadata"
- "admin"
useOffloadedWorkflowClosure: false
artifacts:
host: localhost
port: 50051
insecure: true
database:
postgres:
port: 30001
Expand Down
37 changes: 37 additions & 0 deletions pkg/artifacts/artifact_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package artifacts

import (
"context"
"crypto/tls"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/artifact"
"github.com/flyteorg/flytestdlib/logger"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)

func NewArtifactConnection(_ context.Context, cfg *Config, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
if opts == nil {
// Initialize opts list to the potential number of options we will add. Initialization optimizes memory
// allocation.
opts = make([]grpc.DialOption, 0, 5)
}

if cfg.Insecure {
opts = append(opts, grpc.WithInsecure())
} else {
tlsConfig := &tls.Config{} //nolint
creds := credentials.NewTLS(tlsConfig)
opts = append(opts, grpc.WithTransportCredentials(creds))
}

return grpc.Dial(cfg.Host, opts...)
}

func InitializeArtifactClient(ctx context.Context, cfg *Config, opts ...grpc.DialOption) artifact.ArtifactRegistryClient {
conn, err := NewArtifactConnection(ctx, cfg, opts...)
if err != nil {
logger.Panicf(ctx, "failed to initialize Artifact connection. Err: %s", err.Error())
panic(err)
}
return artifact.NewArtifactRegistryClient(conn)
}
7 changes: 7 additions & 0 deletions pkg/artifacts/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package artifacts

type Config struct {
Host string `json:"host"`
Port int `json:"port"`
Insecure bool `json:"insecure"`
}
Loading

0 comments on commit 5a63652

Please sign in to comment.