mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 23:32:02 +00:00
initial stab at making a quicker quickstart
This commit is contained in:
+3
-2
@@ -17,6 +17,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/internal/log"
|
||||
"io"
|
||||
@@ -27,12 +28,12 @@ import (
|
||||
const ()
|
||||
|
||||
type ArtOptions struct {
|
||||
CommonOptions
|
||||
common.CommonOptions
|
||||
}
|
||||
|
||||
func NewCmdArt(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &ArtOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: common.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
|
||||
+5
-3
@@ -21,11 +21,13 @@ import (
|
||||
"fmt"
|
||||
"github.com/openziti/ziti/ziti/cmd/agentcli"
|
||||
"github.com/openziti/ziti/ziti/cmd/common"
|
||||
"github.com/openziti/ziti/ziti/cmd/create"
|
||||
"github.com/openziti/ziti/ziti/cmd/database"
|
||||
"github.com/openziti/ziti/ziti/cmd/demo"
|
||||
"github.com/openziti/ziti/ziti/cmd/edge"
|
||||
"github.com/openziti/ziti/ziti/cmd/fabric"
|
||||
"github.com/openziti/ziti/ziti/cmd/install"
|
||||
"github.com/openziti/ziti/ziti/cmd/pki"
|
||||
"github.com/openziti/ziti/ziti/cmd/templates"
|
||||
c "github.com/openziti/ziti/ziti/constants"
|
||||
"github.com/openziti/ziti/ziti/controller"
|
||||
@@ -45,7 +47,7 @@ import (
|
||||
|
||||
// InitOptions the flags for running init
|
||||
type MainOptions struct {
|
||||
CommonOptions
|
||||
common.CommonOptions
|
||||
}
|
||||
|
||||
type RootCmd struct {
|
||||
@@ -121,12 +123,12 @@ func NewCmdRoot(in io.Reader, out, err io.Writer, cmd *cobra.Command) *cobra.Com
|
||||
|
||||
p := common.NewOptionsProvider(out, err)
|
||||
|
||||
createCommands := NewCmdCreate(out, err)
|
||||
createCommands := create.NewCmdCreate(out, err)
|
||||
controllerCmd := controller.NewControllerCmd()
|
||||
tunnelCmd := tunnel.NewTunnelCmd(false)
|
||||
routerCmd := router.NewRouterCmd()
|
||||
agentCommands := agentcli.NewAgentCmd(p)
|
||||
pkiCommands := NewCmdPKI(out, err)
|
||||
pkiCommands := pki.NewCmdPKI(out, err)
|
||||
fabricCommand := fabric.NewFabricCmd(p)
|
||||
edgeCommand := edge.NewCmdEdge(out, err)
|
||||
demoCmd := demo.NewDemoCmd(p)
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
Copyright NetFoundry Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"io"
|
||||
)
|
||||
|
||||
// CommonOptions contains common options and helper methods
|
||||
type CommonOptions struct {
|
||||
Out io.Writer
|
||||
Err io.Writer
|
||||
Cmd *cobra.Command
|
||||
Args []string
|
||||
BatchMode bool
|
||||
Verbose bool
|
||||
Staging bool
|
||||
ConfigIdentity string
|
||||
Timeout int
|
||||
}
|
||||
|
||||
func (options *CommonOptions) AddCommonFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().BoolVarP(&options.BatchMode, "batch-mode", "b", false, "In batch mode the command never prompts for user input")
|
||||
cmd.Flags().BoolVarP(&options.Verbose, "verbose", "", false, "Enable verbose logging")
|
||||
cmd.Flags().BoolVarP(&options.Staging, "staging", "", false, "Install/Upgrade components from the ziti-staging repo")
|
||||
cmd.Flags().StringVarP(&options.ConfigIdentity, "configIdentity", "i", "", "Which configIdentity to use")
|
||||
cmd.Flags().IntVarP(&options.Timeout, "timeout", "t", 5, "Timeout for REST operations (specified in seconds)")
|
||||
options.Cmd = cmd
|
||||
}
|
||||
|
||||
func (options *CommonOptions) panicOnErr(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,11 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/cmd/pki"
|
||||
"github.com/openziti/ziti/ziti/cmd/templates"
|
||||
"github.com/spf13/cobra"
|
||||
"io"
|
||||
@@ -43,11 +44,11 @@ func NewCmdCreate(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
|
||||
cmd.AddCommand(NewCmdCreateConfig())
|
||||
|
||||
cmd.AddCommand(NewCmdPKICreateCA(out, errOut))
|
||||
cmd.AddCommand(NewCmdPKICreateIntermediate(out, errOut))
|
||||
cmd.AddCommand(NewCmdPKICreateServer(out, errOut))
|
||||
cmd.AddCommand(NewCmdPKICreateClient(out, errOut))
|
||||
cmd.AddCommand(NewCmdPKICreateCSR(out, errOut))
|
||||
cmd.AddCommand(pki.NewCmdPKICreateCA(out, errOut))
|
||||
cmd.AddCommand(pki.NewCmdPKICreateIntermediate(out, errOut))
|
||||
cmd.AddCommand(pki.NewCmdPKICreateServer(out, errOut))
|
||||
cmd.AddCommand(pki.NewCmdPKICreateClient(out, errOut))
|
||||
cmd.AddCommand(pki.NewCmdPKICreateCSR(out, errOut))
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/ziti/cmd/common"
|
||||
@@ -196,12 +196,6 @@ type RouterListenerTemplateValues struct {
|
||||
OutQueueSize int
|
||||
}
|
||||
|
||||
var workingDir string
|
||||
|
||||
func init() {
|
||||
workingDir, _ = cmdHelper.GetZitiHome()
|
||||
}
|
||||
|
||||
// NewCmdCreateConfig creates a command object for the "config" command
|
||||
func NewCmdCreateConfig() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
@@ -227,14 +221,13 @@ func (options *CreateConfigOptions) addCreateFlags(cmd *cobra.Command) {
|
||||
cmd.PersistentFlags().StringVarP(&options.Output, optionOutput, "o", defaultOutput, outputDescription)
|
||||
}
|
||||
|
||||
func (data *ConfigTemplateValues) populateConfigValues() {
|
||||
func (data *ConfigTemplateValues) PopulateConfigValues() {
|
||||
|
||||
// Get and add hostname to the params
|
||||
data.Hostname = cmdHelper.HostnameOrNetworkName()
|
||||
|
||||
// Get and add ziti home to the params
|
||||
zitiHome, err := cmdHelper.GetZitiHome()
|
||||
handleVariableError(err, constants.ZitiHomeVarName)
|
||||
zitiHome := cmdHelper.GetZitiHome()
|
||||
|
||||
data.ZitiHome = zitiHome
|
||||
// ************* Controller Values ************
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
@@ -107,7 +107,7 @@ func NewCmdCreateConfigController() *CreateControllerConfigCmd {
|
||||
logrus.SetOutput(logOut)
|
||||
}
|
||||
|
||||
data.populateConfigValues()
|
||||
data.PopulateConfigValues()
|
||||
|
||||
// Update controller specific values with configOptions passed in if the argument was provided or the value is currently blank
|
||||
if data.Controller.Ctrl.AdvertisedPort == "" || controllerOptions.CtrlPort != constants.DefaultCtrlAdvertisedPort {
|
||||
@@ -196,28 +196,28 @@ func SetControllerIdentity(data *ControllerTemplateValues) {
|
||||
func SetControllerIdentityCert(c *ControllerTemplateValues) {
|
||||
val := os.Getenv(constants.PkiCtrlCertVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".cert" // default
|
||||
val = helpers2.GetZitiHome() + "/" + helpers2.HostnameOrNetworkName() + ".cert" // default
|
||||
}
|
||||
c.Identity.Cert = helpers2.NormalizePath(val)
|
||||
}
|
||||
func SetControllerIdentityServerCert(c *ControllerTemplateValues) {
|
||||
val := os.Getenv(constants.PkiCtrlServerCertVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".server.chain.cert" // default
|
||||
val = helpers2.GetZitiHome() + "/" + helpers2.HostnameOrNetworkName() + ".server.chain.cert" // default
|
||||
}
|
||||
c.Identity.ServerCert = helpers2.NormalizePath(val)
|
||||
}
|
||||
func SetControllerIdentityKey(c *ControllerTemplateValues) {
|
||||
val := os.Getenv(constants.PkiCtrlKeyVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".key" // default
|
||||
val = helpers2.GetZitiHome() + "/" + helpers2.HostnameOrNetworkName() + ".key" // default
|
||||
}
|
||||
c.Identity.Key = helpers2.NormalizePath(val)
|
||||
}
|
||||
func SetControllerIdentityCA(c *ControllerTemplateValues) {
|
||||
val := os.Getenv(constants.PkiCtrlCAVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".ca" // default
|
||||
val = helpers2.GetZitiHome() + "/" + helpers2.HostnameOrNetworkName() + ".ca" // default
|
||||
}
|
||||
c.Identity.Ca = helpers2.NormalizePath(val)
|
||||
}
|
||||
@@ -229,7 +229,7 @@ func SetEdgeConfig(data *ControllerTemplateValues) {
|
||||
func SetEdgeSigningCert(c *ControllerTemplateValues) {
|
||||
val := os.Getenv(constants.PkiSignerCertVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".signing.cert" // default
|
||||
val = helpers2.GetZitiHome() + "/" + helpers2.HostnameOrNetworkName() + ".signing.cert" // default
|
||||
}
|
||||
c.EdgeEnrollment.SigningCert = helpers2.NormalizePath(val)
|
||||
|
||||
@@ -237,7 +237,7 @@ func SetEdgeSigningCert(c *ControllerTemplateValues) {
|
||||
func SetEdgeSigningKey(c *ControllerTemplateValues) {
|
||||
val := os.Getenv(constants.PkiSignerKeyVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".signing.key" // default
|
||||
val = helpers2.GetZitiHome() + "/" + helpers2.HostnameOrNetworkName() + ".signing.key" // default
|
||||
}
|
||||
c.EdgeEnrollment.SigningCertKey = helpers2.NormalizePath(val)
|
||||
}
|
||||
+30
-13
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -250,25 +250,25 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) {
|
||||
|
||||
// identity:
|
||||
t.Run("TestPKICert", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".cert"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".cert"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.Cert)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.Cert)
|
||||
})
|
||||
t.Run("TestPKIServerCert", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".server.chain.cert"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".server.chain.cert"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.ServerCert)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.ServerCert)
|
||||
})
|
||||
t.Run("TestPKIKey", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".key"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".key"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.Key)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.Key)
|
||||
})
|
||||
t.Run("TestPKICA", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".ca"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".ca"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.Ca)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.Ca)
|
||||
@@ -325,14 +325,14 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) {
|
||||
})
|
||||
t.Run("TestEdgeEnrollmentSigningCert", func(t *testing.T) {
|
||||
// Should default to the value of Ctrl Edge Advertised Port
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.cert"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.cert"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCert)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Cert)
|
||||
})
|
||||
t.Run("TestEdgeEnrollmentSigningKey", func(t *testing.T) {
|
||||
// Should default to the value of Ctrl Edge Advertised Port
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.key"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.key"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCertKey)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Key)
|
||||
@@ -450,25 +450,25 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) {
|
||||
|
||||
// identity:
|
||||
t.Run("TestPKICert", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".cert"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".cert"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.Cert)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.Cert)
|
||||
})
|
||||
t.Run("TestPKIServerCert", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".server.chain.cert"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".server.chain.cert"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.ServerCert)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.ServerCert)
|
||||
})
|
||||
t.Run("TestPKIKey", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".key"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".key"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.Key)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.Key)
|
||||
})
|
||||
t.Run("TestPKICA", func(t *testing.T) {
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".ca"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".ca"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.Identity.Ca)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Identity.Ca)
|
||||
@@ -525,14 +525,14 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) {
|
||||
})
|
||||
t.Run("TestEdgeEnrollmentSigningCert", func(t *testing.T) {
|
||||
// Should default to the value of Ctrl Edge Advertised Port
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.cert"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.cert"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCert)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Cert)
|
||||
})
|
||||
t.Run("TestEdgeEnrollmentSigningKey", func(t *testing.T) {
|
||||
// Should default to the value of Ctrl Edge Advertised Port
|
||||
expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.key"
|
||||
expectedValue := cmdhelper.GetZitiHome() + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.key"
|
||||
|
||||
assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCertKey)
|
||||
assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Key)
|
||||
@@ -663,6 +663,23 @@ func TestZitiCtrlIdentitySection(t *testing.T) {
|
||||
assert.Equal(t, caPath, ctrlConfig.Identity.Ca)
|
||||
}
|
||||
|
||||
func TestDefaultPkiPath(t *testing.T) {
|
||||
expectedPkiRoot := "/tmp/expectedPkiRoot"
|
||||
keys := map[string]string{
|
||||
"ZITI_HOME": expectedPkiRoot,
|
||||
}
|
||||
|
||||
ctrlConfig, data := execCreateConfigControllerCommand(nil, keys)
|
||||
|
||||
assert.Contains(t, data.Controller.Identity.Cert, expectedPkiRoot)
|
||||
assert.Contains(t, data.Controller.Identity.ServerCert, expectedPkiRoot)
|
||||
assert.Contains(t, ctrlConfig.Identity.ServerCert, expectedPkiRoot)
|
||||
assert.Contains(t, data.Controller.Identity.Key, expectedPkiRoot)
|
||||
assert.Contains(t, ctrlConfig.Identity.Key, expectedPkiRoot)
|
||||
assert.Contains(t, data.Controller.Identity.Ca, expectedPkiRoot)
|
||||
assert.Contains(t, ctrlConfig.Identity.Ca, expectedPkiRoot)
|
||||
}
|
||||
|
||||
func TestCtrlBindAddress(t *testing.T) {
|
||||
customValue := "123.456.7.8"
|
||||
keys := map[string]string{
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
@@ -83,7 +83,7 @@ func NewCmdCreateConfigEnvironment() *cobra.Command {
|
||||
Long: createConfigEnvironmentLong,
|
||||
Example: createConfigEnvironmentExample,
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
data.populateConfigValues()
|
||||
data.PopulateConfigValues()
|
||||
// Set router identities
|
||||
SetZitiRouterIdentity(&data.Router, validateRouterName(""))
|
||||
// Set up other identity info
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
@@ -70,7 +70,7 @@ func NewCmdCreateConfigRouter(routerOptions *CreateConfigRouterOptions) *NewCrea
|
||||
logrus.SetOutput(logOut)
|
||||
}
|
||||
|
||||
data.populateConfigValues()
|
||||
data.PopulateConfigValues()
|
||||
|
||||
// Update router data with options passed in
|
||||
data.Router.Name = validateRouterName(routerOptions.RouterName)
|
||||
+7
-7
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
@@ -58,28 +58,28 @@ func SetZitiRouterIdentity(r *RouterTemplateValues, routerName string) {
|
||||
func SetZitiRouterIdentityCert(r *RouterTemplateValues, routerName string) {
|
||||
val := os.Getenv(constants.ZitiRouterIdentityCertVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + routerName + ".cert" // default
|
||||
val = helpers2.GetZitiHome() + "/" + routerName + ".cert" // default
|
||||
}
|
||||
r.IdentityCert = cmdhelper.NormalizePath(val)
|
||||
}
|
||||
func SetZitiRouterIdentityServerCert(r *RouterTemplateValues, routerName string) {
|
||||
val := os.Getenv(constants.ZitiRouterIdentityServerCertVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + routerName + ".server.chain.cert" // default
|
||||
val = helpers2.GetZitiHome() + "/" + routerName + ".server.chain.cert" // default
|
||||
}
|
||||
r.IdentityServerCert = cmdhelper.NormalizePath(val)
|
||||
}
|
||||
func SetZitiRouterIdentityKey(r *RouterTemplateValues, routerName string) {
|
||||
val := os.Getenv(constants.ZitiRouterIdentityKeyVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + routerName + ".key" // default
|
||||
val = helpers2.GetZitiHome() + "/" + routerName + ".key" // default
|
||||
}
|
||||
r.IdentityKey = cmdhelper.NormalizePath(val)
|
||||
}
|
||||
func SetZitiRouterIdentityCA(r *RouterTemplateValues, routerName string) {
|
||||
val := os.Getenv(constants.ZitiRouterIdentityCAVarName)
|
||||
if val == "" {
|
||||
val = workingDir + "/" + routerName + ".cas" // default
|
||||
val = cmdhelper.GetZitiHome() + "/" + routerName + ".cas" // default
|
||||
}
|
||||
r.IdentityCA = cmdhelper.NormalizePath(val)
|
||||
}
|
||||
@@ -104,6 +104,6 @@ func SetRouterAltServerCerts(c *RouterTemplateValues) {
|
||||
return //exit unless both vars are set
|
||||
}
|
||||
c.AltCertsEnabled = true
|
||||
c.AltServerCert = helpers2.NormalizePath(altServerCert)
|
||||
c.AltServerKey = helpers2.NormalizePath(altServerKey)
|
||||
c.AltServerCert = cmdhelper.NormalizePath(altServerCert)
|
||||
c.AltServerKey = cmdhelper.NormalizePath(altServerKey)
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/ziti/constants"
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/ziti/constants"
|
||||
+6
-5
@@ -1,7 +1,8 @@
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/constants"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
@@ -137,7 +138,7 @@ func TestSetZitiRouterIdentityCertDefault(t *testing.T) {
|
||||
_ = os.Setenv(constants.ZitiRouterIdentityCertVarName, "")
|
||||
|
||||
routerName := "RouterTest"
|
||||
expectedDefault := workingDir + "/" + routerName + ".cert"
|
||||
expectedDefault := cmdhelper.GetZitiHome() + "/" + routerName + ".cert"
|
||||
rtv := &RouterTemplateValues{}
|
||||
SetZitiRouterIdentityCert(rtv, routerName)
|
||||
|
||||
@@ -162,7 +163,7 @@ func TestSetZitiRouterIdentityServerCertDefault(t *testing.T) {
|
||||
_ = os.Setenv(constants.ZitiRouterIdentityServerCertVarName, "")
|
||||
|
||||
routerName := "RouterTest"
|
||||
expectedDefault := workingDir + "/" + routerName + ".server.chain.cert"
|
||||
expectedDefault := cmdhelper.GetZitiHome() + "/" + routerName + ".server.chain.cert"
|
||||
rtv := &RouterTemplateValues{}
|
||||
SetZitiRouterIdentityServerCert(rtv, routerName)
|
||||
|
||||
@@ -187,7 +188,7 @@ func TestSetZitiRouterIdentityKeyCertDefault(t *testing.T) {
|
||||
_ = os.Setenv(constants.ZitiRouterIdentityKeyVarDescription, "")
|
||||
|
||||
routerName := "RouterTest"
|
||||
expectedDefault := workingDir + "/" + routerName + ".key"
|
||||
expectedDefault := cmdhelper.GetZitiHome() + "/" + routerName + ".key"
|
||||
rtv := &RouterTemplateValues{}
|
||||
SetZitiRouterIdentityKey(rtv, routerName)
|
||||
|
||||
@@ -212,7 +213,7 @@ func TestSetZitiRouterIdentityKeyCADefault(t *testing.T) {
|
||||
_ = os.Setenv(constants.ZitiRouterIdentityCAVarName, "")
|
||||
|
||||
routerName := "RouterTest"
|
||||
expectedDefault := workingDir + "/" + routerName + ".cas"
|
||||
expectedDefault := cmdhelper.GetZitiHome() + "/" + routerName + ".cas"
|
||||
rtv := &RouterTemplateValues{}
|
||||
SetZitiRouterIdentityCA(rtv, routerName)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package create
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -45,7 +45,7 @@ func newCreateCmd(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
cmd.AddCommand(newCreateCaCmd(out, errOut))
|
||||
cmd.AddCommand(newCreateConfigCmd(out, errOut))
|
||||
cmd.AddCommand(newCreateConfigTypeCmd(out, errOut))
|
||||
cmd.AddCommand(newCreateEdgeRouterCmd(out, errOut))
|
||||
cmd.AddCommand(NewCreateEdgeRouterCmd(out, errOut))
|
||||
cmd.AddCommand(newCreateEdgeRouterPolicyCmd(out, errOut))
|
||||
cmd.AddCommand(newCreateEnrollmentCmd(out, errOut))
|
||||
cmd.AddCommand(newCreateIdentityCmd(out, errOut))
|
||||
|
||||
@@ -37,7 +37,7 @@ type createEdgeRouterOptions struct {
|
||||
disabled bool
|
||||
}
|
||||
|
||||
func newCreateEdgeRouterCmd(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
func NewCreateEdgeRouterCmd(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &createEdgeRouterOptions{
|
||||
EntityOptions: api.NewEntityOptions(out, errOut),
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ type LoginOptions struct {
|
||||
ExtJwt string
|
||||
}
|
||||
|
||||
// newLoginCmd creates the command
|
||||
func newLoginCmd(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
// NewLoginCmd creates the command
|
||||
func NewLoginCmd(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &LoginOptions{
|
||||
Options: api.Options{
|
||||
CommonOptions: common.CommonOptions{Out: out, Err: errOut},
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
Copyright NetFoundry Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package edge
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
edgeSubCmd "github.com/openziti/edge/controller/subcmd"
|
||||
"github.com/openziti/ziti/common/version"
|
||||
"github.com/openziti/ziti/ziti/cmd/create"
|
||||
"github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/cmd/pki"
|
||||
controller2 "github.com/openziti/ziti/ziti/controller"
|
||||
"github.com/openziti/ziti/ziti/router"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// newCreateCmd creates a command object for the "create" command
|
||||
func newQuickStartCmd(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "quickstart",
|
||||
Short: "runs a Controller and Router in quickstart mode",
|
||||
Long: "runs a Controller and Router in quickstart mode. A totally ephemeral network only valid while running.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
run(out, errOut)
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func removeTempDir(tmpDir string) {
|
||||
fmt.Println("Removing temp directory at: " + tmpDir)
|
||||
_ = os.RemoveAll(tmpDir)
|
||||
}
|
||||
|
||||
func run(out io.Writer, errOut io.Writer) {
|
||||
tmpDir, _ := os.MkdirTemp("", "quickstart")
|
||||
|
||||
defer removeTempDir(tmpDir)
|
||||
|
||||
ctrlYaml := tmpDir + "/ctrl.yaml"
|
||||
|
||||
//ZITI_HOME=/tmp ziti create config controller | grep -v "#" | sed -E 's/^ *$//g' | sed '/^$/d'
|
||||
_ = os.Setenv("ZITI_HOME", tmpDir)
|
||||
_ = os.Setenv("ZITI_PKI_CTRL_CA", tmpDir+"/pki/root-ca/certs/root-ca.cert")
|
||||
_ = os.Setenv("ZITI_PKI_CTRL_KEY", tmpDir+"/pki/intermediate-ca/keys/server.key")
|
||||
_ = os.Setenv("ZITI_PKI_CTRL_CERT", tmpDir+"/pki/intermediate-ca/certs/client.cert")
|
||||
_ = os.Setenv("ZITI_PKI_SIGNER_CERT", tmpDir+"/pki/intermediate-ca/certs/intermediate-ca.cert")
|
||||
_ = os.Setenv("ZITI_PKI_SIGNER_KEY", tmpDir+"/pki/intermediate-ca/keys/intermediate-ca.key")
|
||||
_ = os.Setenv("ZITI_PKI_CTRL_SERVER_CERT", tmpDir+"/pki/intermediate-ca/certs/server.chain.pem")
|
||||
|
||||
dbDir := tmpDir + "/db"
|
||||
_, _ = fmt.Fprintf(os.Stdout, "creating the tmp dir [%v] for the database.\n\n", dbDir)
|
||||
_ = os.MkdirAll(dbDir, 0o777)
|
||||
|
||||
createMinimalPki(out, errOut)
|
||||
|
||||
ctrl := create.NewCmdCreateConfigController()
|
||||
ctrl.SetArgs([]string{
|
||||
fmt.Sprintf("--output=%s", ctrlYaml),
|
||||
})
|
||||
_ = ctrl.Execute()
|
||||
|
||||
initCmd := edgeSubCmd.NewEdgeInitializeCmd(version.GetCmdBuildInfo())
|
||||
initCmd.SetArgs([]string{
|
||||
fmt.Sprintf("--username=%s", "admin"),
|
||||
fmt.Sprintf("--password=%s", "admin"),
|
||||
fmt.Sprintf(ctrlYaml),
|
||||
})
|
||||
initErr := initCmd.Execute()
|
||||
if initErr != nil {
|
||||
logrus.Fatal(initErr)
|
||||
}
|
||||
|
||||
go func() {
|
||||
runCtrl := controller2.NewRunCmd()
|
||||
runCtrl.SetArgs([]string{
|
||||
fmt.Sprintf(ctrlYaml),
|
||||
})
|
||||
runCtrlErr := runCtrl.Execute()
|
||||
if runCtrlErr != nil {
|
||||
logrus.Fatal(runCtrlErr)
|
||||
}
|
||||
}()
|
||||
|
||||
fmt.Println("Controller running... Configuring and starting Router...")
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
//ziti edge login https://localhost:1280 -u admin -p admin -y
|
||||
loginCmd := NewLoginCmd(out, errOut)
|
||||
loginCmd.SetArgs([]string{
|
||||
fmt.Sprintf("localhost:1280"),
|
||||
fmt.Sprintf("--username=%s", "admin"),
|
||||
fmt.Sprintf("--password=%s", "admin"),
|
||||
fmt.Sprintf("-y"),
|
||||
})
|
||||
loginErr := loginCmd.Execute()
|
||||
if loginErr != nil {
|
||||
logrus.Fatal(loginErr)
|
||||
}
|
||||
|
||||
//./ziti edge create edge-router ${ZITI_HOSTNAME}-edge-router -o ${ZITI_HOME}/${ZITI_HOSTNAME}-edge-router.jwt -t -a public
|
||||
createErCmd := NewCreateEdgeRouterCmd(out, errOut)
|
||||
erJwt := tmpDir + "/quickstart.er.jwt"
|
||||
createErCmd.SetArgs([]string{
|
||||
fmt.Sprintf("quickstart-router"),
|
||||
fmt.Sprintf("--jwt-output-file=%s", erJwt),
|
||||
fmt.Sprintf("--tunneler-enabled"),
|
||||
fmt.Sprintf("--role-attributes=%s", "public"),
|
||||
})
|
||||
createErErr := createErCmd.Execute()
|
||||
if createErErr != nil {
|
||||
logrus.Fatal(createErErr)
|
||||
}
|
||||
|
||||
//./ziti create config router edge --routerName ${ZITI_HOSTNAME}-edge-router >${ZITI_HOME}/${ZITI_HOSTNAME}-edge-router.yaml
|
||||
opts := &create.CreateConfigRouterOptions{}
|
||||
|
||||
data := &create.ConfigTemplateValues{}
|
||||
data.PopulateConfigValues()
|
||||
create.SetZitiRouterIdentity(&data.Router, "quickstart-router")
|
||||
erCfg := create.NewCmdCreateConfigRouterEdge(opts, data)
|
||||
erYaml := tmpDir + "/quickstart.er.yaml"
|
||||
erCfg.SetArgs([]string{
|
||||
fmt.Sprintf("--routerName=%s", "quickstart-router"),
|
||||
fmt.Sprintf("--output=%s", erYaml),
|
||||
})
|
||||
_ = ctrl.Execute()
|
||||
erCfgErr := erCfg.Execute()
|
||||
if erCfgErr != nil {
|
||||
logrus.Fatal(erCfgErr)
|
||||
}
|
||||
|
||||
//./ziti router enroll ${ZITI_HOME}/${ZITI_HOSTNAME}-edge-router.yaml --jwt ${ZITI_HOME}/${ZITI_HOSTNAME}-edge-router.jwt
|
||||
erEnroll := router.NewEnrollGwCmd()
|
||||
erEnroll.SetArgs([]string{
|
||||
fmt.Sprintf(erYaml),
|
||||
fmt.Sprintf("--jwt=%s", erJwt),
|
||||
})
|
||||
erEnrollErr := erEnroll.Execute()
|
||||
if erEnrollErr != nil {
|
||||
logrus.Fatal(erEnrollErr)
|
||||
}
|
||||
|
||||
//./ziti router run ${ZITI_HOME}/${ZITI_HOSTNAME}-edge-router.yaml &> ${ZITI_HOME}/${ZITI_HOSTNAME}-edge-router.log &
|
||||
erRunCmd := router.NewRunCmd()
|
||||
erRunCmd.SetArgs([]string{
|
||||
fmt.Sprintf(erYaml),
|
||||
})
|
||||
erRunCmdErr := erRunCmd.Execute()
|
||||
if erRunCmdErr != nil {
|
||||
logrus.Fatal(erRunCmdErr)
|
||||
}
|
||||
}
|
||||
|
||||
func createMinimalPki(out io.Writer, errOut io.Writer) {
|
||||
tmpDir := os.Getenv("ZITI_HOME")
|
||||
pkiDir := tmpDir + "/pki"
|
||||
fmt.Println("emitting a minimal PKI:")
|
||||
|
||||
//ziti pki create ca --pki-root="$pkiDir" --ca-file="root-ca" --ca-name="root-ca"
|
||||
ca := pki.NewCmdPKICreateCA(out, errOut)
|
||||
ca.SetArgs([]string{
|
||||
fmt.Sprintf("--pki-root=%s", pkiDir),
|
||||
fmt.Sprintf("--ca-file=%s", "root-ca"),
|
||||
fmt.Sprintf("--ca-name=%s", "root-ca"),
|
||||
})
|
||||
pkiErr := ca.Execute()
|
||||
if pkiErr != nil {
|
||||
logrus.Fatal(pkiErr)
|
||||
}
|
||||
|
||||
//ziti pki create intermediate --pki-root "$pkiDir" --ca-name "root-ca" --intermediate-name "intermediate-ca" --intermediate-file "intermediate-ca" --max-path-len "1"
|
||||
intermediate := pki.NewCmdPKICreateIntermediate(out, errOut)
|
||||
intermediate.SetArgs([]string{
|
||||
fmt.Sprintf("--pki-root=%s", pkiDir),
|
||||
fmt.Sprintf("--ca-name=%s", "root-ca"),
|
||||
fmt.Sprintf("--intermediate-name=%s", "intermediate-ca"),
|
||||
fmt.Sprintf("--intermediate-file=%s", "intermediate-ca"),
|
||||
fmt.Sprintf("--max-path-len=1"),
|
||||
})
|
||||
intErr := intermediate.Execute()
|
||||
if intErr != nil {
|
||||
logrus.Fatal(intErr)
|
||||
}
|
||||
|
||||
//ziti pki create server --pki-root="${ZITI_HOME}/pki" --ca-name "intermediate-ca" --server-name "server" --server-file "server" --dns "localhost,${ZITI_HOSTNAME}"
|
||||
svr := pki.NewCmdPKICreateServer(out, errOut)
|
||||
svr.SetArgs([]string{
|
||||
fmt.Sprintf("--pki-root=%s", pkiDir),
|
||||
fmt.Sprintf("--ca-name=%s", "intermediate-ca"),
|
||||
fmt.Sprintf("--server-name=%s", "server"),
|
||||
fmt.Sprintf("--server-file=%s", "server"),
|
||||
fmt.Sprintf("--dns=%s,%s", "localhost", helpers.GetCtrlAdvertisedAddress()),
|
||||
})
|
||||
svrErr := svr.Execute()
|
||||
if svrErr != nil {
|
||||
logrus.Fatal(svrErr)
|
||||
}
|
||||
|
||||
//ziti pki create client --pki-root="${ZITI_HOME}/pki" --ca-name "intermediate-ca" --client-name "client" --client-file "client" --key-file "server"
|
||||
client := pki.NewCmdPKICreateClient(out, errOut)
|
||||
client.SetArgs([]string{
|
||||
fmt.Sprintf("--pki-root=%s", pkiDir),
|
||||
fmt.Sprintf("--ca-name=%s", "intermediate-ca"),
|
||||
fmt.Sprintf("--client-name=%s", "client"),
|
||||
fmt.Sprintf("--client-file=%s", "client"),
|
||||
fmt.Sprintf("--key-file=%s", "server"),
|
||||
})
|
||||
clientErr := client.Execute()
|
||||
if clientErr != nil {
|
||||
logrus.Fatal(clientErr)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//func waitForShutdown(fabricController *controller.Controller, edgeController *server.Controller) {
|
||||
// ch := make(chan os.Signal, 1)
|
||||
// signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
|
||||
//
|
||||
// <-ch
|
||||
//
|
||||
// pfxlog.Logger().Info("shutting down ziti-controller")
|
||||
// edgeController.Shutdown()
|
||||
// fabricController.Shutdown()
|
||||
//}
|
||||
@@ -37,7 +37,7 @@ func NewCmdEdge(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
func populateEdgeCommands(out io.Writer, errOut io.Writer, cmd *cobra.Command) *cobra.Command {
|
||||
cmd.AddCommand(newCreateCmd(out, errOut))
|
||||
cmd.AddCommand(newDeleteCmd(out, errOut))
|
||||
cmd.AddCommand(newLoginCmd(out, errOut))
|
||||
cmd.AddCommand(NewLoginCmd(out, errOut))
|
||||
cmd.AddCommand(newLogoutCmd(out, errOut))
|
||||
cmd.AddCommand(newUseCmd(out, errOut))
|
||||
cmd.AddCommand(newListCmd(out, errOut))
|
||||
@@ -50,6 +50,7 @@ func populateEdgeCommands(out io.Writer, errOut io.Writer, cmd *cobra.Command) *
|
||||
cmd.AddCommand(newTraceRouteCmd(out, errOut))
|
||||
cmd.AddCommand(newShowCmd(out, errOut))
|
||||
cmd.AddCommand(newReEnrollCmd(out, errOut))
|
||||
cmd.AddCommand(newQuickStartCmd(out, errOut))
|
||||
|
||||
p := common.NewOptionsProvider(out, errOut)
|
||||
cmd.AddCommand(enrollment.NewEnrollCommand(p))
|
||||
|
||||
@@ -46,7 +46,7 @@ func WorkingDir() (string, error) {
|
||||
return NormalizePath(wd), nil
|
||||
}
|
||||
|
||||
func GetZitiHome() (string, error) {
|
||||
func GetZitiHome() string {
|
||||
// Get path from env variable
|
||||
retVal := os.Getenv(constants.ZitiHomeVarName)
|
||||
|
||||
@@ -59,14 +59,10 @@ func GetZitiHome() (string, error) {
|
||||
}
|
||||
|
||||
err = os.Setenv(constants.ZitiHomeVarName, workingDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
retVal = os.Getenv(constants.ZitiHomeVarName)
|
||||
}
|
||||
|
||||
return NormalizePath(retVal), nil
|
||||
return NormalizePath(retVal)
|
||||
}
|
||||
|
||||
func HostnameOrNetworkName() string {
|
||||
|
||||
@@ -18,6 +18,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/spf13/cobra"
|
||||
"io"
|
||||
@@ -26,7 +27,7 @@ import (
|
||||
|
||||
// LogFormatOptions contains the command line options
|
||||
type LogFormatOptions struct {
|
||||
CommonOptions
|
||||
common.CommonOptions
|
||||
|
||||
absoluteTime bool
|
||||
trimPrefix string
|
||||
@@ -35,7 +36,7 @@ type LogFormatOptions struct {
|
||||
// NewCmdLogFormat a command object for the "log-format" command
|
||||
func NewCmdLogFormat(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &LogFormatOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: common.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/cmd/lets_encrypt"
|
||||
"github.com/openziti/ziti/ziti/cmd/templates"
|
||||
@@ -27,7 +28,7 @@ import (
|
||||
|
||||
// PKIOptions contains the command line options
|
||||
type PKIOptions struct {
|
||||
CommonOptions
|
||||
common.CommonOptions
|
||||
|
||||
Flags PKIFlags
|
||||
}
|
||||
@@ -73,7 +74,7 @@ Provide the components needed to manage a Ziti PKI.
|
||||
// NewCmdPKI PKIs a command object for the "PKI" command
|
||||
func NewCmdPKI(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: common.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"encoding/asn1"
|
||||
"errors"
|
||||
"fmt"
|
||||
cmd2 "github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/pki/pki"
|
||||
"github.com/openziti/ziti/ziti/util"
|
||||
@@ -49,7 +50,7 @@ type PKICreateOptions struct {
|
||||
func NewCmdPKICreate(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &PKICreateOptions{
|
||||
PKIOptions: PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: cmd2.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
@@ -459,3 +460,9 @@ func (o *PKICreateOptions) obtainRsaOptions() (pki.PrivateKeyOptions, error) {
|
||||
Size: o.Flags.CAPrivateKeySize,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (options *PKICreateOptions) panicOnErr(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,12 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
cmd2 "github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/internal/log"
|
||||
"github.com/openziti/ziti/ziti/pki/certificate"
|
||||
@@ -41,7 +42,7 @@ func NewCmdPKICreateCA(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &PKICreateCAOptions{
|
||||
PKICreateOptions: PKICreateOptions{
|
||||
PKIOptions: PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: cmd2.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
@@ -97,7 +98,7 @@ func (o *PKICreateCAOptions) Run() error {
|
||||
//default name, ensure uniqueness by adding a random id
|
||||
o.Flags.CAName = o.Flags.CAName + " " + idgen.New()
|
||||
}
|
||||
|
||||
|
||||
commonName := o.Flags.CAName
|
||||
|
||||
filename := o.ObtainFileName(caFile, commonName)
|
||||
@@ -14,11 +14,12 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
cmd2 "github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/internal/log"
|
||||
"github.com/openziti/ziti/ziti/pki/certificate"
|
||||
@@ -40,7 +41,7 @@ func NewCmdPKICreateClient(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &PKICreateClientOptions{
|
||||
PKICreateOptions: PKICreateOptions{
|
||||
PKIOptions: PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: cmd2.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
@@ -14,10 +14,11 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
cmd2 "github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/internal/log"
|
||||
"github.com/openziti/ziti/ziti/pki/pki"
|
||||
@@ -36,7 +37,7 @@ func NewCmdPKICreateCSR(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &PKICreateCSROptions{
|
||||
PKICreateOptions: PKICreateOptions{
|
||||
PKIOptions: PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: cmd2.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
@@ -14,11 +14,12 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
cmd2 "github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/internal/log"
|
||||
"github.com/openziti/ziti/ziti/pki/certificate"
|
||||
@@ -39,7 +40,7 @@ func NewCmdPKICreateIntermediate(out io.Writer, errOut io.Writer) *cobra.Command
|
||||
options := &PKICreateIntermediateOptions{
|
||||
PKICreateOptions: PKICreateOptions{
|
||||
PKIOptions: PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: cmd2.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
@@ -14,10 +14,11 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
cmd2 "github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/internal/log"
|
||||
"github.com/openziti/ziti/ziti/pki/certificate"
|
||||
@@ -37,7 +38,7 @@ func NewCmdPKICreateKey(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &PKICreateKeyOptions{
|
||||
PKICreateOptions: PKICreateOptions{
|
||||
PKIOptions: PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: cmd2.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
@@ -14,11 +14,12 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package pki
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti/fabric/controller/idgen"
|
||||
cmd2 "github.com/openziti/ziti/ziti/cmd/common"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/internal/log"
|
||||
"github.com/openziti/ziti/ziti/pki/certificate"
|
||||
@@ -40,7 +41,7 @@ func NewCmdPKICreateServer(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
options := &PKICreateServerOptions{
|
||||
PKICreateOptions: PKICreateOptions{
|
||||
PKIOptions: PKIOptions{
|
||||
CommonOptions: CommonOptions{
|
||||
CommonOptions: cmd2.CommonOptions{
|
||||
Out: out,
|
||||
Err: errOut,
|
||||
},
|
||||
Reference in New Issue
Block a user