tasks/go.py
def generate_protobuf(ctx):
    """
    Generates protobuf defintions in pkg/proto
    """
    base = os.path.dirname(os.path.abspath(__file__))
    repo_root = os.path.abspath(os.path.join(base, ".."))
    proto_root = os.path.join(repo_root, "pkg", "proto")

    print(f"nuking old definitions at: {proto_root}")
    file_list = glob.glob(os.path.join(proto_root, "pbgo", "*.go"))
    for file_path in file_list:
        try:
            os.remove(file_path)
        except OSError:
            print("Error while deleting file : ", file_path)

    with ctx.cd(repo_root):
        # protobuf defs
        print(f"generating protobuf code from: {proto_root}")

        files = []
        for path in Path(os.path.join(proto_root, "datadog")).rglob('*.proto'):
            files.append(path.as_posix())

        ctx.run(f"protoc -I{proto_root} --go_out=plugins=grpc:{repo_root} {' '.join(files)}")
        # grpc-gateway logic
        ctx.run(f"protoc -I{proto_root} --grpc-gateway_out=logtostderr=true:{repo_root} {' '.join(files)}")
        # mockgen
        pbgo_dir = os.path.join(proto_root, "pbgo")
        mockgen_out = os.path.join(proto_root, "pbgo", "mocks")
        try:
            os.mkdir(mockgen_out)
        except FileExistsError:
            print(f"{mockgen_out} folder already exists")

        ctx.run(f"mockgen -source={pbgo_dir}/api.pb.go -destination={mockgen_out}/api_mockgen.pb.go")

    # generate messagepack marshallers
    ctx.run("msgp -file pkg/proto/pbgo/config.pb.go -o=pkg/proto/pbgo/config_gen.go")

    Generates protobuf defintions in pkg/proto
    
Generates protobuf defintions in pkg/proto
Generates protobuf defintions in pkg / proto
def generate_protobuf(ctx):
    base = os.path.dirname(os.path.abspath(__file__))
    repo_root = os.path.abspath(os.path.join(base, ".."))
    proto_root = os.path.join(repo_root, "pkg", "proto")
    print(f"nuking old definitions at: {proto_root}")
    file_list = glob.glob(os.path.join(proto_root, "pbgo", "*.go"))
    for file_path in file_list:
        try:
            os.remove(file_path)
        except OSError:
            print("Error while deleting file : ", file_path)
    with ctx.cd(repo_root):
        print(f"generating protobuf code from: {proto_root}")
        files = []
        for path in Path(os.path.join(proto_root, "datadog")).rglob('*.proto'):
            files.append(path.as_posix())
        ctx.run(f"protoc -I{proto_root} --go_out=plugins=grpc:{repo_root} {' '.join(files)}")
        ctx.run(f"protoc -I{proto_root} --grpc-gateway_out=logtostderr=true:{repo_root} {' '.join(files)}")
        pbgo_dir = os.path.join(proto_root, "pbgo")
        mockgen_out = os.path.join(proto_root, "pbgo", "mocks")
        try:
            os.mkdir(mockgen_out)
        except FileExistsError:
            print(f"{mockgen_out} folder already exists")
        ctx.run(f"mockgen -source={pbgo_dir}/api.pb.go -destination={mockgen_out}/api_mockgen.pb.go")
    ctx.run("msgp -file pkg/proto/pbgo/config.pb.go -o=pkg/proto/pbgo/config_gen.go")
def generate_protobuf ( ctx ) : base = os . path . dirname ( os . path . abspath ( __file__ ) ) repo_root = os . path . abspath ( os . path . join ( base , ".." ) ) proto_root = os . path . join ( repo_root , "pkg" , "proto" ) print ( f"nuking old definitions at: {proto_root}" ) file_list = glob . glob ( os . path . join ( proto_root , "pbgo" , "*.go" ) ) for file_path in file_list : try : os . remove ( file_path ) except OSError : print ( "Error while deleting file : " , file_path ) with ctx . cd ( repo_root ) : print ( f"generating protobuf code from: {proto_root}" ) files = [ ] for path in Path ( os . path . join ( proto_root , "datadog" ) ) . rglob ( '*.proto' ) : files . append ( path . as_posix ( ) ) ctx . run ( f"protoc -I{proto_root} --go_out=plugins=grpc:{repo_root} {' '.join(files)}" ) ctx . run ( f"protoc -I{proto_root} --grpc-gateway_out=logtostderr=true:{repo_root} {' '.join(files)}" ) pbgo_dir = os . path . join ( proto_root , "pbgo" ) mockgen_out = os . path . join ( proto_root , "pbgo" , "mocks" ) try : os . mkdir ( mockgen_out ) except FileExistsError : print ( f"{mockgen_out} folder already exists" ) ctx . run ( f"mockgen -source={pbgo_dir}/api.pb.go -destination={mockgen_out}/api_mockgen.pb.go" ) ctx . run ( "msgp -file pkg/proto/pbgo/config.pb.go -o=pkg/proto/pbgo/config_gen.go" )
Generates protobuf defintions in pkg/proto
Generates protobuf defintions in pkg / proto
"""
    Generates protobuf defintions in pkg/proto
    """ # protobuf defs # grpc-gateway logic # mockgen # generate messagepack marshallers
ctx