forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Devflow, boilerplate, improved code, formatting and bug fixes (flyteo…
- Loading branch information
1 parent
2c56ff7
commit e659074
Showing
40 changed files
with
2,048 additions
and
204 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ vendor | |
bin | ||
.DS_Store | ||
_test | ||
./config.yaml |
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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
export REPOSITORY=flytectl | ||
include boilerplate/lyft/golang_test_targets/Makefile | ||
|
||
generate: | ||
go test github.com/lyft/flytectl/cmd --update | ||
go test github.com/lyft/flytectl/cmd --update | ||
|
||
compile: | ||
go build -o bin/flytectl main.go | ||
|
||
.PHONY: update_boilerplate | ||
update_boilerplate: | ||
@boilerplate/update.sh |
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,22 @@ | ||
package adminutils | ||
|
||
import "github.com/lyft/flytestdlib/config" | ||
|
||
//go:generate pflags Config | ||
|
||
var ( | ||
defaultConfig = &Config{ | ||
MaxRecords: 500, | ||
BatchSize: 100, | ||
} | ||
section = config.MustRegisterSection("adminutils", defaultConfig) | ||
) | ||
|
||
type Config struct { | ||
MaxRecords int `json:"maxRecords" pflag:",Maximum number of records to retrieve."` | ||
BatchSize int `json:"batchSize" pflag:",Maximum number of records to retrieve per call."` | ||
} | ||
|
||
func GetConfig() *Config { | ||
return section.GetConfig().(*Config) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,62 @@ | ||
package adminutils | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/admin" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
type NamedEntityIDLister func(ctx context.Context, in *admin.NamedEntityIdentifierListRequest, opts ...grpc.CallOption) (*admin.NamedEntityIdentifierList, error) | ||
|
||
type NamedEntityVisitor func(entities []*admin.NamedEntityIdentifier) error | ||
|
||
type ListRequest struct { | ||
Project string | ||
Domain string | ||
Filters string | ||
} | ||
|
||
func IterateThroughAllNamedEntities(ctx context.Context, lister NamedEntityIDLister, visitor NamedEntityVisitor, req ListRequest, opts ...grpc.CallOption) error { | ||
adminReq := &admin.NamedEntityIdentifierListRequest{ | ||
Project: req.Project, | ||
Domain: req.Domain, | ||
Filters: req.Filters, | ||
SortBy: &admin.Sort{ | ||
Key: "name", | ||
Direction: admin.Sort_ASCENDING, | ||
}, | ||
Limit: uint32(GetConfig().BatchSize), | ||
} | ||
|
||
i := 0 | ||
for i < GetConfig().MaxRecords { | ||
res, err := lister(ctx, adminReq, opts...) | ||
if err != nil { | ||
return err | ||
} | ||
if len(res.Entities) != 0 { | ||
if err := visitor(res.Entities); err != nil { | ||
return err | ||
} | ||
} | ||
i = i + len(res.Entities) | ||
if len(res.Entities) == 0 || res.Token == "" { | ||
break | ||
} | ||
adminReq.Token = res.Token | ||
} | ||
return nil | ||
} | ||
|
||
func GetAllNamedEntities(ctx context.Context, lister NamedEntityIDLister, req ListRequest, opts ...grpc.CallOption) ([]*admin.NamedEntityIdentifier, error) { | ||
var allEntities []*admin.NamedEntityIdentifier | ||
err := IterateThroughAllNamedEntities(ctx, lister, func(entities []*admin.NamedEntityIdentifier) error { | ||
allEntities = append(allEntities, entities...) | ||
return nil | ||
}, req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return allEntities, nil | ||
} |
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,12 @@ | ||
module github.com/lyft/boilerplate | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/alvaroloes/enumer v1.1.2 | ||
github.com/golangci/golangci-lint v1.22.2 | ||
github.com/lyft/flytestdlib v0.2.31 | ||
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5 | ||
) | ||
|
||
replace github.com/vektra/mockery => github.com/enghabu/mockery v0.0.0-20191009061720-9d0c8670c2f0 |
Oops, something went wrong.