Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

### Enhancements:

- feat(service/logging): add support for the 'public-key` flag for GCS logging ([#1925](https://github.com/fastly/cli/pull/1925))
- feat(help): add -h short flag for --help. ([#1918](https://github.com/fastly/cli/pull/1918))

### Dependencies:
Expand Down
5 changes: 5 additions & 0 deletions pkg/commands/service/logging/gcs/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type CreateCommand struct {
Placement argparser.OptionalString
ProcessingRegion argparser.OptionalString
ProjectID argparser.OptionalString
PublicKey argparser.OptionalString
ResponseCondition argparser.OptionalString
SecretKey argparser.OptionalString
TimestampFormat argparser.OptionalString
Expand Down Expand Up @@ -81,6 +82,7 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman
logflags.Period(c.CmdClause, &c.Period)
logflags.Placement(c.CmdClause, &c.Placement)
logflags.ProcessingRegion(c.CmdClause, &c.ProcessingRegion, "GCS")
logflags.PublicKey(c.CmdClause, &c.PublicKey)
c.CmdClause.Flag("project-id", "The google project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value)
logflags.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)
Expand Down Expand Up @@ -153,6 +155,9 @@ func (c *CreateCommand) ConstructInput(serviceID string, serviceVersion int) (*f
if c.ProjectID.WasSet {
input.ProjectID = &c.ProjectID.Value
}
if c.PublicKey.WasSet {
input.PublicKey = &c.PublicKey.Value
}
if c.ResponseCondition.WasSet {
input.ResponseCondition = &c.ResponseCondition.Value
}
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/service/logging/gcs/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error {
"Processing region": fastly.ToValue(o.ProcessingRegion),
"Project ID": fastly.ToValue(o.ProjectID),
"Placement": fastly.ToValue(o.Placement),
"Public key": fastly.ToValue(o.PublicKey),
"Response condition": fastly.ToValue(o.ResponseCondition),
"Secret key": fastly.ToValue(o.SecretKey),
"Timestamp format": fastly.ToValue(o.TimestampFormat),
Expand Down
49 changes: 49 additions & 0 deletions pkg/commands/service/logging/gcs/gcs_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ func TestGCSCreate(t *testing.T) {
},
WantOutput: "Created GCS logging endpoint log (service 123 version 4)",
},
{
Args: "--service-id 123 --version 1 --name log --bucket log --user foo@example.com --secret-key foo --period 86400 --public-key foo --autoclone",
API: &mock.API{
GetVersionFn: testutil.GetVersion,
CloneVersionFn: testutil.CloneVersionResult(4),
CreateGCSFn: createGCSOK,
},
WantOutput: "Created GCS logging endpoint log (service 123 version 4)",
},
{
Args: "--service-id 123 --version 1 --name log --bucket log --user foo@example.com --secret-key foo --period 86400 --autoclone",
API: &mock.API{
Expand Down Expand Up @@ -210,6 +219,7 @@ func listGCSsOK(_ context.Context, i *fastly.ListGCSsInput) ([]*fastly.GCS, erro
ResponseCondition: new("Prevent default logging"),
TimestampFormat: new("%Y-%m-%dT%H:%M:%S.000"),
Placement: new("none"),
PublicKey: new(pgpPublicKey()),
CompressionCodec: new("zstd"),
ProcessingRegion: new("us"),
},
Expand All @@ -230,6 +240,7 @@ func listGCSsOK(_ context.Context, i *fastly.ListGCSsInput) ([]*fastly.GCS, erro
ResponseCondition: new("Prevent default logging"),
TimestampFormat: new("%Y-%m-%dT%H:%M:%S.000"),
Placement: new("none"),
PublicKey: new(pgpPublicKey()),
CompressionCodec: new("zstd"),
ProcessingRegion: new("us"),
},
Expand Down Expand Up @@ -270,6 +281,7 @@ Version: 1
Message type: classic
Timestamp format: %Y-%m-%dT%H:%M:%S.000
Placement: none
Public key: `+pgpPublicKey()+`
Compression codec: zstd
Processing region: us
GCS 2/2
Expand All @@ -289,6 +301,7 @@ Version: 1
Message type: classic
Timestamp format: %Y-%m-%dT%H:%M:%S.000
Placement: none
Public key: `+pgpPublicKey()+`
Compression codec: zstd
Processing region: us
`) + "\n\n"
Expand All @@ -311,6 +324,7 @@ func getGCSOK(_ context.Context, i *fastly.GetGCSInput) (*fastly.GCS, error) {
ResponseCondition: new("Prevent default logging"),
TimestampFormat: new("%Y-%m-%dT%H:%M:%S.000"),
Placement: new("none"),
PublicKey: new(pgpPublicKey()),
CompressionCodec: new("zstd"),
ProcessingRegion: new("us"),
}, nil
Expand All @@ -334,6 +348,7 @@ Period: 3600
Placement: none
Processing region: us
Project ID:
Public key: `+pgpPublicKey()+`
Response condition: Prevent default logging
Secret key: -----BEGIN RSA PRIVATE KEY-----foo
Service ID: 123
Expand Down Expand Up @@ -374,3 +389,37 @@ func deleteGCSOK(_ context.Context, _ *fastly.DeleteGCSInput) error {
func deleteGCSError(_ context.Context, _ *fastly.DeleteGCSInput) error {
return errTest
}

// pgpPublicKey returns a PEM encoded PGP public key suitable for testing.
func pgpPublicKey() string {
return strings.TrimSpace(`-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFyUD8sBCACyFnB39AuuTygseek+eA4fo0cgwva6/FSjnWq7riouQee8GgQ/
ibXTRyv4iVlwI12GswvMTIy7zNvs1R54i0qvsLr+IZ4GVGJqs6ZJnvQcqe3xPoR4
8AnBfw90o32r/LuHf6QCJXi+AEu35koNlNAvLJ2B+KACaNB7N0EeWmqpV/1V2k9p
lDYk+th7LcCuaFNGqKS/PrMnnMqR6VDLCjHhNx4KR79b0Twm/2qp6an3hyNRu8Gn
dwxpf1/BUu3JWf+LqkN4Y3mbOmSUL3MaJNvyQguUzTfS0P0uGuBDHrJCVkMZCzDB
89ag55jCPHyGeHBTd02gHMWzsg3WMBWvCsrzAB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NN+QY5WDbsGmsyk6+6ZMYejb4qYfweQeduOj27aavCJdLkCYMoRKfcFYI8c
FaNmEfKKy/r1PO20NXEG6t9t05K/frHy6ZG8bCNYdpagfFVot47r9JaQqWlTNtIR
5+zkkSq/eG9BEtRij3a6cTdQbktdBzx2KBeI0PYc1vlZR0LpuFKZqY9vlE6vTGLR
wMfrTEOvx0NxUM3rpaCgEmuWbB1G1Hu371oyr4srrr+N
=28dr
-----END PGP PUBLIC KEY BLOCK-----
`)
}
5 changes: 5 additions & 0 deletions pkg/commands/service/logging/gcs/gcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestCreateGCSInput(t *testing.T) {
Placement: new("none"),
CompressionCodec: new("zstd"),
ProcessingRegion: new("eu"),
PublicKey: new(pgpPublicKey()),
},
},
{
Expand Down Expand Up @@ -148,6 +149,7 @@ func TestUpdateGCSInput(t *testing.T) {
MessageType: new("new10"),
CompressionCodec: new("new11"),
ProcessingRegion: new("eu"),
PublicKey: new("new12"),
},
},
{
Expand Down Expand Up @@ -177,6 +179,7 @@ func TestUpdateGCSInput(t *testing.T) {
MessageType: new("new10"),
CompressionCodec: new("new11"),
ProcessingRegion: new("eu"),
PublicKey: new("new12"),
},
},
{
Expand Down Expand Up @@ -312,6 +315,7 @@ func createCommandAll() *gcs.CreateCommand {
Placement: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: "none"},
CompressionCodec: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: "zstd"},
ProcessingRegion: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: "eu"},
PublicKey: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: pgpPublicKey()},
}
}

Expand Down Expand Up @@ -400,6 +404,7 @@ func updateCommandAll() *gcs.UpdateCommand {
MessageType: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: "new10"},
CompressionCodec: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: "new11"},
ProcessingRegion: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: "eu"},
PublicKey: argparser.OptionalString{Optional: argparser.Optional{WasSet: true}, Value: "new12"},
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/commands/service/logging/gcs/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error {
fmt.Fprintf(out, "\t\tMessage type: %s\n", fastly.ToValue(gcs.MessageType))
fmt.Fprintf(out, "\t\tTimestamp format: %s\n", fastly.ToValue(gcs.TimestampFormat))
fmt.Fprintf(out, "\t\tPlacement: %s\n", fastly.ToValue(gcs.Placement))
fmt.Fprintf(out, "\t\tPublic key: %s\n", fastly.ToValue(gcs.PublicKey))
fmt.Fprintf(out, "\t\tCompression codec: %s\n", fastly.ToValue(gcs.CompressionCodec))
fmt.Fprintf(out, "\t\tProcessing region: %s\n", fastly.ToValue(gcs.ProcessingRegion))
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/commands/service/logging/gcs/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type UpdateCommand struct {
Placement argparser.OptionalString
ProcessingRegion argparser.OptionalString
ProjectID argparser.OptionalString
PublicKey argparser.OptionalString
ResponseCondition argparser.OptionalString
SecretKey argparser.OptionalString
TimestampFormat argparser.OptionalString
Expand Down Expand Up @@ -84,6 +85,7 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman
logflags.Placement(c.CmdClause, &c.Placement)
logflags.ProcessingRegion(c.CmdClause, &c.ProcessingRegion, "GCS")
c.CmdClause.Flag("project-id", "The google project ID").Action(c.ProjectID.Set).StringVar(&c.ProjectID.Value)
logflags.PublicKey(c.CmdClause, &c.PublicKey)
logflags.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 @@ -154,6 +156,9 @@ func (c *UpdateCommand) ConstructInput(serviceID string, serviceVersion int) (*f
if c.ProjectID.WasSet {
input.ProjectID = &c.ProjectID.Value
}
if c.PublicKey.WasSet {
input.PublicKey = &c.PublicKey.Value
}
if c.ResponseCondition.WasSet {
input.ResponseCondition = &c.ResponseCondition.Value
}
Expand Down
Loading