This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parameter and literal map construction wrong
Signed-off-by: Yee Hing Tong <wild-endeavor@users.noreply.github.com>
- Loading branch information
1 parent
59b147b
commit 5a63652
Showing
8 changed files
with
217 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"` | ||
} |
Oops, something went wrong.