Skip to content

Commit

Permalink
Merge branch 'main' into length-check
Browse files Browse the repository at this point in the history
  • Loading branch information
kajes committed Aug 15, 2023
2 parents 85ddd63 + 17e8d0a commit b5a5c95
Show file tree
Hide file tree
Showing 24 changed files with 170 additions and 59 deletions.
6 changes: 3 additions & 3 deletions cmd/appliance/backup/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestBackupCmd(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("http://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("http://appgate.test:%d", registry.Port),
},
IOOutWriter: buf,
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestBackupCmdFailedOnServer(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("http://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("http://appgate.test:%d", registry.Port),
},
IOOutWriter: buf,
}
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestBackupCmdDisabledAPI(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("http://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("http://appgate.test:%d", registry.Port),
},
IOOutWriter: buf,
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/appliance/force_disable_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import (
"github.com/appgate/sdp-api-client-go/api/v19/openapi"
"github.com/appgate/sdpctl/pkg/appliance"
"github.com/appgate/sdpctl/pkg/configuration"
"github.com/appgate/sdpctl/pkg/dns"
"github.com/appgate/sdpctl/pkg/factory"
"github.com/appgate/sdpctl/pkg/httpmock"
"github.com/appgate/sdpctl/pkg/prompt"
"github.com/foxcpp/go-mockdns"
"github.com/google/shlex"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -254,6 +256,8 @@ func TestForceDisableControllerCMD(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, teardown := dns.RunMockDNSServer(map[string]mockdns.Zone{})
defer teardown()
registry := httpmock.NewRegistry(t)
for _, v := range tt.httpStubs {
registry.Register(v.URL, v.Responder)
Expand All @@ -267,7 +271,7 @@ func TestForceDisableControllerCMD(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("https://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("https://appgate.test:%d", registry.Port),
},
IOOutWriter: stdout,
Stdin: in,
Expand Down
12 changes: 6 additions & 6 deletions cmd/appliance/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestApplianceListCommandTable(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("http://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("http://appgate.test:%d", registry.Port),
},
IOOutWriter: stdout,
Stdin: in,
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestApplianceListCommandTable(t *testing.T) {
gotStr := string(got)
want := `Name ID Hostname Site Activated
---- -- -------- ---- ---------
controller-da0375f6-0b28-4248-bd54-a933c4c39008-site1 4c07bc67-57ea-42dd-b702-c2d6c45419fc appgate.com Default Site true
controller-da0375f6-0b28-4248-bd54-a933c4c39008-site1 4c07bc67-57ea-42dd-b702-c2d6c45419fc appgate.test Default Site true
gateway-da0375f6-0b28-4248-bd54-a933c4c39008-site1 ee639d70-e075-4f01-596b-930d5f24f569 gateway.devops Default Site true
`
if !cmp.Equal(want, gotStr) {
Expand All @@ -140,7 +140,7 @@ func TestApplianceFiltering(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("http://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("http://appgate.test:%d", registry.Port),
},
IOOutWriter: stdout,
Stdin: in,
Expand Down Expand Up @@ -176,9 +176,9 @@ func TestApplianceFiltering(t *testing.T) {
t.Fatalf("unable to read stdout %s", err)
}
gotStr := string(got)
want := `Name ID Hostname Site Activated
---- -- -------- ---- ---------
controller-da0375f6-0b28-4248-bd54-a933c4c39008-site1 4c07bc67-57ea-42dd-b702-c2d6c45419fc appgate.com Default Site true
want := `Name ID Hostname Site Activated
---- -- -------- ---- ---------
controller-da0375f6-0b28-4248-bd54-a933c4c39008-site1 4c07bc67-57ea-42dd-b702-c2d6c45419fc appgate.test Default Site true
`
if !cmp.Equal(want, gotStr) {
t.Fatalf("\nGot: \n %q \n\n Want: \n %q \n", gotStr, want)
Expand Down
2 changes: 1 addition & 1 deletion cmd/appliance/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewLogsCmd(f *factory.Factory) *cobra.Command {
Short: docs.ApplianceLogsDoc.Short,
Long: docs.ApplianceLogsDoc.Short,
Example: docs.ApplianceLogsDoc.ExampleString(),
Args: func(cmd *cobra.Command, args []string) error {
PreRunE: func(cmd *cobra.Command, args []string) error {
return cmdappliance.ArgsSelectAppliance(cmd, args, &opts.AppliancCmdOpts)
},
RunE: func(c *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/appliance/maintenance/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewDisableCmd(f *factory.Factory) *cobra.Command {
Short: docs.MaintenanceDisable.Short,
Long: docs.MaintenanceDisable.Long,
Example: docs.MaintenanceDisable.ExampleString(),
Args: func(cmd *cobra.Command, args []string) error {
PreRunE: func(cmd *cobra.Command, args []string) error {
return toggleArgs(cmd, &opts, args)
},
RunE: func(c *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/appliance/maintenance/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewEnableCmd(f *factory.Factory) *cobra.Command {
Short: docs.MaintenanceEnable.Short,
Long: docs.MaintenanceEnable.Long,
Example: docs.MaintenanceEnable.ExampleString(),
Args: func(cmd *cobra.Command, args []string) error {
PreRunE: func(cmd *cobra.Command, args []string) error {
return toggleArgs(cmd, &opts, args)
},
RunE: func(c *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/appliance/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewMetricCmd(f *factory.Factory) *cobra.Command {
Long: docs.ApplianceMetricsDoc.Long,
Example: docs.ApplianceMetricsDoc.ExampleString(),
Aliases: []string{"metrics"},
Args: func(cmd *cobra.Command, args []string) error {
PreRunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
a, err := opts.Appliance(opts.Config)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/appliance/resolve_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewResolveNameCmd(f *factory.Factory) *cobra.Command {
Short: docs.ApplianceResolveNameDoc.Short,
Long: docs.ApplianceResolveNameDoc.Long,
Example: docs.ApplianceResolveNameDoc.ExampleString(),
Args: func(cmd *cobra.Command, args []string) error {
PreRunE: func(cmd *cobra.Command, args []string) error {
a, err := opts.Appliance(opts.Config)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/appliance/resolve_name_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewResolveNameStatusCmd(f *factory.Factory) *cobra.Command {
Short: docs.ApplianceResolveNameStatusDoc.Short,
Long: docs.ApplianceResolveNameStatusDoc.Long,
Example: docs.ApplianceResolveNameStatusDoc.ExampleString(),
Args: func(cmd *cobra.Command, args []string) error {
PreRunE: func(cmd *cobra.Command, args []string) error {
a, err := opts.Appliance(opts.Config)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/appliance/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewSeedCmd(f *factory.Factory) *cobra.Command {
Short: docs.ApplianceSeedDocs.Short,
Long: docs.ApplianceSeedDocs.Long,
Example: docs.ApplianceSeedDocs.ExampleString(),
Args: func(cmd *cobra.Command, args []string) error {
PreRunE: func(cmd *cobra.Command, args []string) error {
noInteractive, err := cmd.Flags().GetBool("no-interactive")
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion cmd/appliance/upgrade/complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
"github.com/appgate/sdp-api-client-go/api/v19/openapi"
appliancepkg "github.com/appgate/sdpctl/pkg/appliance"
"github.com/appgate/sdpctl/pkg/configuration"
"github.com/appgate/sdpctl/pkg/dns"
"github.com/appgate/sdpctl/pkg/factory"
"github.com/appgate/sdpctl/pkg/httpmock"
"github.com/appgate/sdpctl/pkg/prompt"
"github.com/appgate/sdpctl/pkg/tui"
"github.com/foxcpp/go-mockdns"
"github.com/google/shlex"
"github.com/hashicorp/go-version"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -417,6 +419,8 @@ func TestUpgradeCompleteCommand(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, teardown := dns.RunMockDNSServer(map[string]mockdns.Zone{})
defer teardown()
registry := httpmock.NewRegistry(t)
for _, v := range tt.httpStubs {
registry.Register(v.URL, v.Responder)
Expand All @@ -431,7 +435,7 @@ func TestUpgradeCompleteCommand(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("http://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("http://appgate.test:%d", registry.Port),
},
IOOutWriter: stdout,
Stdin: in,
Expand Down
7 changes: 5 additions & 2 deletions cmd/appliance/upgrade/prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import (
"github.com/appgate/sdp-api-client-go/api/v19/openapi"
appliancepkg "github.com/appgate/sdpctl/pkg/appliance"
"github.com/appgate/sdpctl/pkg/configuration"
"github.com/appgate/sdpctl/pkg/dns"
"github.com/appgate/sdpctl/pkg/factory"
"github.com/appgate/sdpctl/pkg/httpmock"
"github.com/appgate/sdpctl/pkg/prompt"
"github.com/appgate/sdpctl/pkg/tui"
"github.com/foxcpp/go-mockdns"
"github.com/google/shlex"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -490,7 +492,8 @@ func TestUpgradePrepareCommand(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

_, teardown := dns.RunMockDNSServer(map[string]mockdns.Zone{})
defer teardown()
registry := httpmock.NewRegistry(t)
for _, v := range tt.httpStubs {
registry.Register(v.URL, v.Responder)
Expand All @@ -505,7 +508,7 @@ func TestUpgradePrepareCommand(t *testing.T) {
f := &factory.Factory{
Config: &configuration.Config{
Debug: false,
URL: fmt.Sprintf("http://appgate.com:%d", registry.Port),
URL: fmt.Sprintf("http://appgate.test:%d", registry.Port),
Version: 16,
},
IOOutWriter: stdout,
Expand Down
35 changes: 21 additions & 14 deletions docs/assets/guide.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* common */
:root {
--color-ag-rust: #d64527;
--color-ag-dark: #0f0f0f;
--color-ag-light: #f0f0f0;
--color-bg-page: #f0f0f0;
--color-bg-box: #ffffff;
--color-gh-link: #0969da;
--color-gh-editor: #f6f8fa;
--color-gh-comment: #6e7781;
--color-gh-command: #0550ae;
--color-bg-editor: #f6f8fa;
--color-link: #074D9C;
--color-comment: #005C00;
--color-command: #0550ae;
--spacing-default: 1.25rem;
--spacing-page-hor: calc(var(--spacing-default) * 8);
--spacing-page-ver: calc(var(--spacing-default) * 2);
Expand Down Expand Up @@ -110,7 +109,7 @@ li p {

a {
cursor: pointer;
color: var(--color-gh-link);
color: var(--color-link);
font-weight: normal;
font-family: var(--font-body);
text-decoration: none;
Expand All @@ -120,9 +119,9 @@ a {
}

a:hover {
color: var(--color-gh-link);
color: var(--color-link);
text-decoration: none;
border-bottom: 1px solid var(--color-gh-link);
border-bottom: 1px solid var(--color-link);
transition: color 0.4s, border-color 0.4s !important;
}

Expand Down Expand Up @@ -230,18 +229,18 @@ code {
text-align: left;
padding: var(--spacing-default);
overflow-x: scroll;
background-color: var(--color-gh-editor);
background-color: var(--color-bg-editor);
border: 1px solid var(--color-bg-page);
border-radius: var(--border-radius);
}

.code-command {
font-weight: bold;
color: var(--color-gh-command);
color: var(--color-command);
}

.code-comment {
font-style: italic;
color: var(--color-comment);
}

.tag {
Expand Down Expand Up @@ -310,19 +309,27 @@ code {

.example-summary {
padding: 1rem 0.5rem;
margin-bottom: 1px;
cursor: pointer;
background-color: var(--color-gh-editor);
background-color: var(--color-bg-editor);
border: 1px solid var(--color-bg-page);
border-radius: var(--border-radius);
user-select: none;
}

details .code-editor {
border-top: 0;
border-top-right-radius: 0;
border-top-left-radius: 0;
}

@media (prefers-color-scheme: dark) {
:root {
--color-bg-page: #000000;
--color-bg-box: #181818;
--color-gh-editor: var(--color-ag-dark);
--color-bg-editor: #0f0f0f;
--color-link: #5EA6F8;
--color-comment: #00B800;
--color-command: #58A0F9;
--drop-shadow: 0 0 0.5rem #232323;
--button-shadow: 0 0 0.5rem #232323;
}
Expand Down
13 changes: 10 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,20 @@ <h2 class="margin-bottom">Usage Examples</h2>
<pre class="code-editor"><code>
# Step 1: Extract the executable

# Step 2: Provide the Admin UI url. If you use self-signed cert on Admin UI, use the flag : --pem &lt;path-to-pem&gt;
# Step 2: Required if you are using self-signed cert on Admin UI, otherwise skip
Download the CA cert from the Admin UI, System, Certificate Authority
Place the downloaded cert file in the same folder as the sdpctl binary


# Step 3: Provide the Admin UI url
&gt; <span data-varid="command">sdpctl.exe</span> configure
# or
&gt; <span data-varid="command">sdpctl.exe</span> configure --pem &lt;ca-cert-file-name&gt;
? Enter the url for the Controller API (example https://controller.company.com:8443) https://ag-ctrl.company.com:8443
Configuration updated successfully


# Step 3: Signin to your Collective
# Step 4: Sign in to your Collective
&gt; <span data-varid="command">sdpctl.exe</span> configure signin
? Choose a provider: [Use arrows to move, type to filter]
❯ Azure AD SAML Admin
Expand All @@ -218,7 +225,7 @@ <h2 class="margin-bottom">Usage Examples</h2>
Successfully signed in


# Step 4: Verify the configuration
# Step 5: Verify the configuration
&gt; <span data-varid="command">sdpctl.exe</span> appliance status
Name Status Function CPU Memory Network out/in Disk Version
---- ------ -------- --- ------ -------------- ---- -------
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/foxcpp/go-mockdns v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand All @@ -54,6 +55,7 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/miekg/dns v1.1.55 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -63,9 +65,12 @@ require (
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/oauth2 v0.9.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/tools v0.11.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
Expand Down
Loading

0 comments on commit b5a5c95

Please sign in to comment.