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

feat(config-store): Add Config Store commands #829

Merged
merged 4 commits into from Mar 16, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -29,7 +29,7 @@ require (
)

require (
github.com/fastly/go-fastly/v7 v7.3.0
github.com/fastly/go-fastly/v7 v7.5.0
github.com/kennygrant/sanitize v1.2.4
github.com/mholt/archiver v3.1.1+incompatible
github.com/otiai10/copy v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -18,8 +18,8 @@ github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj6
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0 h1:90Ly+6UfUypEF6vvvW5rQIv9opIL8CbmW9FT20LDQoY=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0/go.mod h1:V+Qd57rJe8gd4eiGzZyg4h54VLHmYVVw54iMnlAMrF8=
github.com/fastly/go-fastly/v7 v7.3.0 h1:QG8rjm95DC2YLv8B64sHy2XhOfjfTRpx5dT/6uo/j8E=
github.com/fastly/go-fastly/v7 v7.3.0/go.mod h1:K32VeBzD+RJikDMUSKPpYfno8YBMXmNWjgGAn6I/OU8=
github.com/fastly/go-fastly/v7 v7.5.0 h1:5keaPPC8YA3seDKx5n0JVLhvgs4WmNtHl043Pey+Ho8=
github.com/fastly/go-fastly/v7 v7.5.0/go.mod h1:/Z2GD7NuxV3vVMAyrtckg1WvZVnCuM2Z8ok/z70XTEQ=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible h1:FhrXlfhgGCS+uc6YwyiFUt04alnjpoX7vgDKJxS6Qbk=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible/go.mod h1:U8UynVoU1SQaqD2I4ZqgYd5lx3A1ipQYn4aSt2Y5h6c=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
Expand Down
14 changes: 14 additions & 0 deletions pkg/api/interface.go
Expand Up @@ -329,6 +329,20 @@ type Interface interface {
UpdateServiceAuthorization(i *fastly.UpdateServiceAuthorizationInput) (*fastly.ServiceAuthorization, error)
DeleteServiceAuthorization(i *fastly.DeleteServiceAuthorizationInput) error

CreateConfigStore(i *fastly.CreateConfigStoreInput) (*fastly.ConfigStore, error)
DeleteConfigStore(i *fastly.DeleteConfigStoreInput) error
GetConfigStore(i *fastly.GetConfigStoreInput) (*fastly.ConfigStore, error)
GetConfigStoreMetadata(i *fastly.GetConfigStoreMetadataInput) (*fastly.ConfigStoreMetadata, error)
ListConfigStores() ([]*fastly.ConfigStore, error)
ListConfigStoreServices(i *fastly.ListConfigStoreServicesInput) ([]*fastly.Service, error)
UpdateConfigStore(i *fastly.UpdateConfigStoreInput) (*fastly.ConfigStore, error)

CreateConfigStoreItem(i *fastly.CreateConfigStoreItemInput) (*fastly.ConfigStoreItem, error)
DeleteConfigStoreItem(i *fastly.DeleteConfigStoreItemInput) error
GetConfigStoreItem(i *fastly.GetConfigStoreItemInput) (*fastly.ConfigStoreItem, error)
ListConfigStoreItems(i *fastly.ListConfigStoreItemsInput) ([]*fastly.ConfigStoreItem, error)
UpdateConfigStoreItem(i *fastly.UpdateConfigStoreItemInput) (*fastly.ConfigStoreItem, error)

CreateObjectStore(i *fastly.CreateObjectStoreInput) (*fastly.ObjectStore, error)
ListObjectStores(i *fastly.ListObjectStoresInput) (*fastly.ListObjectStoresResponse, error)
DeleteObjectStore(i *fastly.DeleteObjectStoreInput) error
Expand Down
28 changes: 28 additions & 0 deletions pkg/app/commands.go
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/fastly/cli/pkg/commands/backend"
"github.com/fastly/cli/pkg/commands/compute"
"github.com/fastly/cli/pkg/commands/config"
"github.com/fastly/cli/pkg/commands/configstore"
"github.com/fastly/cli/pkg/commands/configstoreentry"
"github.com/fastly/cli/pkg/commands/dictionary"
"github.com/fastly/cli/pkg/commands/dictionaryentry"
"github.com/fastly/cli/pkg/commands/domain"
Expand Down Expand Up @@ -115,6 +117,19 @@ func defineCommands(
computeUpdate := compute.NewUpdateCommand(computeCmdRoot.CmdClause, g, m)
computeValidate := compute.NewValidateCommand(computeCmdRoot.CmdClause, g, m)
configCmdRoot := config.NewRootCommand(app, g)
configstoreCmdRoot := configstore.NewRootCommand(app, g)
configstoreCreate := configstore.NewCreateCommand(configstoreCmdRoot.CmdClause, g, m)
configstoreDelete := configstore.NewDeleteCommand(configstoreCmdRoot.CmdClause, g, m)
configstoreDescribe := configstore.NewDescribeCommand(configstoreCmdRoot.CmdClause, g, m)
configstoreList := configstore.NewListCommand(configstoreCmdRoot.CmdClause, g, m)
configstoreListServices := configstore.NewListServicesCommand(configstoreCmdRoot.CmdClause, g, m)
configstoreUpdate := configstore.NewUpdateCommand(configstoreCmdRoot.CmdClause, g, m)
configstoreentryCmdRoot := configstoreentry.NewRootCommand(app, g)
configstoreentryCreate := configstoreentry.NewCreateCommand(configstoreentryCmdRoot.CmdClause, g, m)
configstoreentryDelete := configstoreentry.NewDeleteCommand(configstoreentryCmdRoot.CmdClause, g, m)
configstoreentryDescribe := configstoreentry.NewDescribeCommand(configstoreentryCmdRoot.CmdClause, g, m)
configstoreentryList := configstoreentry.NewListCommand(configstoreentryCmdRoot.CmdClause, g, m)
configstoreentryUpdate := configstoreentry.NewUpdateCommand(configstoreentryCmdRoot.CmdClause, g, m)
dictionaryCmdRoot := dictionary.NewRootCommand(app, g)
dictionaryCreate := dictionary.NewCreateCommand(dictionaryCmdRoot.CmdClause, g, m)
dictionaryDelete := dictionary.NewDeleteCommand(dictionaryCmdRoot.CmdClause, g, m)
Expand Down Expand Up @@ -447,6 +462,19 @@ func defineCommands(
computeUpdate,
computeValidate,
configCmdRoot,
configstoreCmdRoot,
configstoreCreate,
configstoreDelete,
configstoreDescribe,
configstoreList,
configstoreListServices,
configstoreUpdate,
configstoreentryCmdRoot,
configstoreentryCreate,
configstoreentryDelete,
configstoreentryDescribe,
configstoreentryList,
configstoreentryUpdate,
dictionaryCmdRoot,
dictionaryCreate,
dictionaryDelete,
Expand Down
2 changes: 2 additions & 0 deletions pkg/app/run_test.go
Expand Up @@ -63,6 +63,8 @@ auth-token
backend
compute
config
config-store
config-store-entry
dictionary
dictionary-entry
domain
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/backend/backend_test.go
Expand Up @@ -135,7 +135,7 @@ func TestBackendList(t *testing.T) {
ListVersionsFn: testutil.ListVersions,
ListBackendsFn: listBackendsOK,
},
WantOutput: `[{"Address":"www.test.com","AutoLoadbalance":false,"BetweenBytesTimeout":0,"Comment":"test","ConnectTimeout":0,"CreatedAt":null,"DeletedAt":null,"ErrorThreshold":0,"FirstByteTimeout":0,"HealthCheck":"","Hostname":"","MaxConn":0,"MaxTLSVersion":"","MinTLSVersion":"","Name":"test.com","OverrideHost":"","Port":80,"RequestCondition":"","SSLCACert":"","SSLCertHostname":"","SSLCheckCert":false,"SSLCiphers":"","SSLClientCert":"","SSLClientKey":"","SSLHostname":"","SSLSNIHostname":"","ServiceID":"123","ServiceVersion":1,"Shield":"","UpdatedAt":null,"UseSSL":false,"Weight":0},{"Address":"www.example.com","AutoLoadbalance":false,"BetweenBytesTimeout":0,"Comment":"example","ConnectTimeout":0,"CreatedAt":null,"DeletedAt":null,"ErrorThreshold":0,"FirstByteTimeout":0,"HealthCheck":"","Hostname":"","MaxConn":0,"MaxTLSVersion":"","MinTLSVersion":"","Name":"example.com","OverrideHost":"","Port":443,"RequestCondition":"","SSLCACert":"","SSLCertHostname":"","SSLCheckCert":false,"SSLCiphers":"","SSLClientCert":"","SSLClientKey":"","SSLHostname":"","SSLSNIHostname":"","ServiceID":"123","ServiceVersion":1,"Shield":"","UpdatedAt":null,"UseSSL":false,"Weight":0}]`,
WantOutput: `[{"Address":"www.test.com","AutoLoadbalance":false,"BetweenBytesTimeout":0,"Comment":"test","ConnectTimeout":0,"CreatedAt":null,"DeletedAt":null,"ErrorThreshold":0,"FirstByteTimeout":0,"HealthCheck":"","Hostname":"","KeepAliveTime":0,"MaxConn":0,"MaxTLSVersion":"","MinTLSVersion":"","Name":"test.com","OverrideHost":"","Port":80,"RequestCondition":"","SSLCACert":"","SSLCertHostname":"","SSLCheckCert":false,"SSLCiphers":"","SSLClientCert":"","SSLClientKey":"","SSLHostname":"","SSLSNIHostname":"","ServiceID":"123","ServiceVersion":1,"Shield":"","UpdatedAt":null,"UseSSL":false,"Weight":0},{"Address":"www.example.com","AutoLoadbalance":false,"BetweenBytesTimeout":0,"Comment":"example","ConnectTimeout":0,"CreatedAt":null,"DeletedAt":null,"ErrorThreshold":0,"FirstByteTimeout":0,"HealthCheck":"","Hostname":"","KeepAliveTime":0,"MaxConn":0,"MaxTLSVersion":"","MinTLSVersion":"","Name":"example.com","OverrideHost":"","Port":443,"RequestCondition":"","SSLCACert":"","SSLCertHostname":"","SSLCheckCert":false,"SSLCiphers":"","SSLClientCert":"","SSLClientKey":"","SSLHostname":"","SSLSNIHostname":"","ServiceID":"123","ServiceVersion":1,"Shield":"","UpdatedAt":null,"UseSSL":false,"Weight":0}]`,
},
{
Args: args("backend list --service-id 123 --version 1 --json --verbose"),
Expand Down