Skip to content

Commit

Permalink
project describe: Include detailed project information for active pro…
Browse files Browse the repository at this point in the history
…jects

bopmatic project describe will now include additional information
regarding active projects including the website url, set of databases
created, set of datastores created, and their detail.
  • Loading branch information
mikeb26 committed Nov 11, 2024
1 parent c5d1719 commit f650214
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/aws/aws-sdk-go-v2 v1.32.4
github.com/aws/aws-sdk-go-v2/config v1.28.3
github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.46.5
github.com/bopmatic/sdk/golang v0.0.0-20241110180842-f87773a4d187
github.com/bopmatic/sdk/golang v0.0.0-20241111213848-4b9c0eb651ab
github.com/docker/docker v27.3.1+incompatible
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.32.4 h1:yDxvkz3/uOKfxnv8YhzOi9m+2OGI
github.com/aws/aws-sdk-go-v2/service/sts v1.32.4/go.mod h1:9XEUty5v5UAsMiFOBJrNibZgwCeOma73jgGwwhgffa8=
github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM=
github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/bopmatic/sdk/golang v0.0.0-20241110180842-f87773a4d187 h1:RwPsYrFvZBXWClSTNogcncZNFRE6QVMPR9Uwza4ywhA=
github.com/bopmatic/sdk/golang v0.0.0-20241110180842-f87773a4d187/go.mod h1:s/WFl21BUdqAYk7Kg4gmpVl30yEQ4OaAqVaSKp9+TJo=
github.com/bopmatic/sdk/golang v0.0.0-20241111213848-4b9c0eb651ab h1:+8bnjdxUw5/9fMJ6JAuyAVpvkd3urao/Snxx+efToV0=
github.com/bopmatic/sdk/golang v0.0.0-20241111213848-4b9c0eb651ab/go.mod h1:s/WFl21BUdqAYk7Kg4gmpVl30yEQ4OaAqVaSKp9+TJo=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
Expand Down
101 changes: 101 additions & 0 deletions project.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,107 @@ func projDescribeMain(args []string) {
fmt.Printf("\tState: %v\n", projDesc.State)
fmt.Printf("\tActive deployments: %v\n", projDesc.ActiveDeployIds)
fmt.Printf("\tPending deployments: %v\n", projDesc.PendingDeployIds)

if len(projDesc.ActiveDeployIds) == 0 {
return
}

descSiteReply, err := bopsdk.DescribeSite(opts.projectId, "", sdkOpts...)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to describe site: %v\n", err)
os.Exit(1)
}
fmt.Printf("\tWebsite: %v\n", descSiteReply.SiteEndpoint)
svcList, err := bopsdk.ListServices(opts.projectId, "", sdkOpts...)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to list services: %v\n", err)
os.Exit(1)
}
for _, svc := range svcList {
fmt.Printf("\tService %v:\n", svc)
svcDesc, err := bopsdk.DescribeService(opts.projectId, "", svc, sdkOpts...)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to describe service %v: %v\n", svc, err)
os.Exit(1)
}
fmt.Printf("\t\tApi Definition: %v\n", svcDesc.Desc.ApiDef)
fmt.Printf("\t\tPort: %v\n", svcDesc.Desc.Port)
if len(svcDesc.Desc.DatabaseNames) > 0 {
fmt.Printf("\t\tDatabases: ")
for _, dbName := range svcDesc.Desc.DatabaseNames {
fmt.Printf("%v, ", dbName)
}
fmt.Printf("\n")
}
if len(svcDesc.Desc.DatastoreNames) > 0 {
fmt.Printf("\t\tDatastores: ")
for _, dstoreName := range svcDesc.Desc.DatastoreNames {
fmt.Printf("%v, ", dstoreName)
}
fmt.Printf("\n")
}
if len(svcDesc.Desc.RpcEndpoints) > 0 {
fmt.Printf("\t\tRpc Endpoints:\n")
for _, rpcEnd := range svcDesc.Desc.RpcEndpoints {
fmt.Printf("\t\t\t%v\n", rpcEnd)
}
}
}

dbList, err := bopsdk.ListDatabases(opts.projectId, "", sdkOpts...)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to list databases: %v\n", err)
os.Exit(1)
}
for _, db := range dbList {
fmt.Printf("\tDatabase %v:\n", db)
dbDesc, err := bopsdk.DescribeDatabase(opts.projectId, "", db, sdkOpts...)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to describe database %v: %v\n", db,
err)
os.Exit(1)
}
if len(dbDesc.Desc.ServiceNames) > 0 {
fmt.Printf("\t\tServices: ")
for _, svcName := range dbDesc.Desc.ServiceNames {
fmt.Printf("%v, ", svcName)
}
fmt.Printf("\n")
}
if len(dbDesc.Desc.Tables) > 0 {
for _, tbl := range dbDesc.Desc.Tables {
fmt.Printf("\t\tTable %v:\n", tbl.Name)
fmt.Printf("\t\t\tNumRows: %v\n", tbl.NumRows)
fmt.Printf("\t\t\tSize: %v MiB\n", tbl.Size/1024/1024)
}
}
}

dstoreList, err := bopsdk.ListDatastores(opts.projectId, "", sdkOpts...)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to list datastores: %v\n", err)
os.Exit(1)
}
for _, dstore := range dstoreList {
fmt.Printf("\tDatastore %v:\n", dstore)
dstoreDesc, err := bopsdk.DescribeDatastore(opts.projectId, "", dstore,
sdkOpts...)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to describe datastore %v: %v\n",
dstore, err)
os.Exit(1)
}
fmt.Printf("\t\tNumObjects: %v\n", dstoreDesc.Desc.NumObjects)
fmt.Printf("\t\tSize: %v MiB\n",
dstoreDesc.Desc.CapacityConsumedInBytes/1024/1024)
if len(dstoreDesc.Desc.ServiceNames) > 0 {
fmt.Printf("\t\tServices: ")
for _, svcName := range dstoreDesc.Desc.ServiceNames {
fmt.Printf("%v, ", svcName)
}
fmt.Printf("\n")
}
}
}

func setProjIdFromOpts(opts *projOpts) error {
Expand Down

0 comments on commit f650214

Please sign in to comment.