Skip to content

Commit

Permalink
Added server version command
Browse files Browse the repository at this point in the history
  • Loading branch information
sgonzalezoyuela committed Dec 20, 2022
1 parent 620d800 commit bd00610
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
24 changes: 14 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,7 @@ func preRunE(cmd *cobra.Command, args []string) error {
}
}

cfg := sdk.IdbusServer{
Config: &api.ServerConfiguration{
URL: viper.Get("endpoint").(string),
Description: "IAM.tf/JOSSO server",
},
Credentials: &sdk.ServerCredentials{
ClientId: viper.Get("client_id").(string),
Secret: viper.Get("secret").(string),
},
}
cfg := serverConfig()

id_or_name = viper.Get("appliance").(string)
quiet = viper.Get("quiet").(bool)
Expand Down Expand Up @@ -201,3 +192,16 @@ func initConfig() {
//fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
}

func serverConfig() sdk.IdbusServer {
return sdk.IdbusServer{
Config: &api.ServerConfiguration{
URL: viper.Get("endpoint").(string),
Description: "IAM.tf/JOSSO server",
},
Credentials: &sdk.ServerCredentials{
ClientId: viper.Get("client_id").(string),
Secret: viper.Get("secret").(string),
},
}
}
8 changes: 5 additions & 3 deletions cmd/server-version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"os"

"github.com/spf13/cobra"

sdk "github.com/atricore/josso-sdk-go"
)

// listCmd represents the list command
Expand All @@ -23,16 +25,16 @@ var serverVersionCmd = &cobra.Command{
client.Error(err)
os.Exit(1)
}
printOut(v + "\n")
printOut(v)

return nil

},
}

func serverVersion() (string, error) {

return client.Client().ServerVersion()
cfg := serverConfig()
return sdk.ServerVersion(&cfg)
}

func init() {
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/atricore/josso-cli-go
go 1.16

require (
github.com/atricore/josso-api-go v0.4.1
github.com/atricore/josso-sdk-go v0.4.1
github.com/atricore/josso-api-go v0.4.2
github.com/atricore/josso-sdk-go v0.4.4
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.10.1
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5

)

replace github.com/atricore/josso-api-go => ../josso-api-go
//replace github.com/atricore/josso-api-go => ../josso-api-go

replace github.com/atricore/josso-sdk-go => ../josso-sdk-go
//replace github.com/atricore/josso-sdk-go => ../josso-sdk-go
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/atricore/josso-api-go v0.4.2 h1:C/+ujvh+9q6zXEKJw/o/0CSlPReVqk3edsqgG5+9d34=
github.com/atricore/josso-api-go v0.4.2/go.mod h1:Oys9D0y1x+bvyIsnRFl6JOYiIV7KQkuToIQa+jxeuHs=
github.com/atricore/josso-sdk-go v0.4.4 h1:mOfJ+jdqdoneYVmzQ8M/3EW6Cz5KRrrOgSJV3bSpBaY=
github.com/atricore/josso-sdk-go v0.4.4/go.mod h1:9iWPXVArfd6h8gRUnrm9ahw0nQuMGZpeTvCLgtcak2U=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down

0 comments on commit bd00610

Please sign in to comment.