Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add project-id to gcs logging setting #1202

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/commands/logging/gcs/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type CreateCommand struct {
Path argparser.OptionalString
Period argparser.OptionalInt
Placement argparser.OptionalString
ProjectID argparser.OptionalString
ResponseCondition argparser.OptionalString
SecretKey argparser.OptionalString
TimestampFormat argparser.OptionalString
Expand Down Expand Up @@ -75,6 +76,7 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman
common.Path(c.CmdClause, &c.Path)
common.Period(c.CmdClause, &c.Period)
common.Placement(c.CmdClause, &c.Placement)
c.CmdClause.Flag("project-id", "The google project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value)
common.ResponseCondition(c.CmdClause, &c.ResponseCondition)
c.CmdClause.Flag("secret-key", "Your GCS account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value)
c.RegisterFlag(argparser.StringFlagOpts{
Expand Down Expand Up @@ -140,6 +142,9 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f
if c.Placement.WasSet {
input.Placement = &c.Placement.Value
}
if c.ProjectID.WasSet {
input.ProjectID = &c.ProjectID.Value
}
if c.ResponseCondition.WasSet {
input.ResponseCondition = &c.ResponseCondition.Value
}
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/logging/gcs/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error {
"Name": fastly.ToValue(o.Name),
"Path": fastly.ToValue(o.Path),
"Period": fastly.ToValue(o.Period),
"Project ID": fastly.ToValue(o.ProjectID),
"Placement": fastly.ToValue(o.Placement),
"Response condition": fastly.ToValue(o.ResponseCondition),
"Secret key": fastly.ToValue(o.SecretKey),
Expand Down
9 changes: 9 additions & 0 deletions pkg/commands/logging/gcs/gcs_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ func TestGCSCreate(t *testing.T) {
},
wantOutput: "Created GCS logging endpoint log (service 123 version 4)",
},
{
args: args("logging gcs create --service-id 123 --version 1 --name log --bucket log --account-name service-account-id --project-id gcp-prj-id --period 86400 --autoclone"),
api: mock.API{
ListVersionsFn: testutil.ListVersions,
CloneVersionFn: testutil.CloneVersionResult(4),
CreateGCSFn: createGCSOK,
},
wantOutput: "Created GCS logging endpoint log (service 123 version 4)",
},
{
args: args("logging gcs create --service-id 123 --version 1 --name log --bucket log --user foo@example.com --secret-key foo --period 86400 --autoclone"),
api: mock.API{
Expand Down
5 changes: 5 additions & 0 deletions pkg/commands/logging/gcs/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type UpdateCommand struct {
Path argparser.OptionalString
Period argparser.OptionalInt
Placement argparser.OptionalString
ProjectID argparser.OptionalString
ResponseCondition argparser.OptionalString
SecretKey argparser.OptionalString
TimestampFormat argparser.OptionalString
Expand Down Expand Up @@ -76,6 +77,7 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman
c.CmdClause.Flag("path", "The path to upload logs to (default '/')").Action(c.Path.Set).StringVar(&c.Path.Value)
common.Period(c.CmdClause, &c.Period)
common.Placement(c.CmdClause, &c.Placement)
c.CmdClause.Flag("project-id", "The google project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value)
common.ResponseCondition(c.CmdClause, &c.ResponseCondition)
c.CmdClause.Flag("secret-key", "Your GCS account secret key. The private_key field in your service account authentication JSON").Action(c.SecretKey.Set).StringVar(&c.SecretKey.Value)
c.RegisterFlag(argparser.StringFlagOpts{
Expand Down Expand Up @@ -136,6 +138,9 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f
if c.Placement.WasSet {
input.Placement = &c.Placement.Value
}
if c.ProjectID.WasSet {
input.ProjectID = &c.ProjectID.Value
}
if c.ResponseCondition.WasSet {
input.ResponseCondition = &c.ResponseCondition.Value
}
Expand Down
Loading