1
1
package openshift
2
2
3
3
import (
4
+ "bytes"
4
5
"fmt"
5
6
"io"
6
7
"io/ioutil"
@@ -22,13 +23,14 @@ import (
22
23
"github.com/openshift/origin/pkg/bootstrap/docker/errors"
23
24
dockerexec "github.com/openshift/origin/pkg/bootstrap/docker/exec"
24
25
"github.com/openshift/origin/pkg/bootstrap/docker/host"
25
- "github.com/openshift/origin/pkg/bootstrap/docker/localcmd"
26
26
"github.com/openshift/origin/pkg/bootstrap/docker/run"
27
27
defaultsapi "github.com/openshift/origin/pkg/build/admission/defaults/api"
28
28
cliconfig "github.com/openshift/origin/pkg/cmd/cli/config"
29
+ "github.com/openshift/origin/pkg/cmd/server/admin"
29
30
configapi "github.com/openshift/origin/pkg/cmd/server/api"
30
31
_ "github.com/openshift/origin/pkg/cmd/server/api/install"
31
32
configapilatest "github.com/openshift/origin/pkg/cmd/server/api/latest"
33
+ "github.com/openshift/origin/pkg/cmd/server/crypto"
32
34
cmdutil "github.com/openshift/origin/pkg/cmd/util"
33
35
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
34
36
)
@@ -805,32 +807,34 @@ window.OPENSHIFT_CONSTANTS.ENABLE_TECH_PREVIEW_FEATURE = {
805
807
certPath := filepath .Join (configDir , aggregatorCert )
806
808
keyPath := filepath .Join (configDir , aggregatorKey )
807
809
808
- // TODO: reconcile this oadm logic with https://github.com/openshift/origin/blob/master/pkg/bootstrap/docker/openshift/admin.go#L121-L149
809
- out , err := localcmd .New ("oc" ).Args (
810
- "adm" ,
811
- "ca" ,
812
- "create-signer-cert" ,
813
- "--cert" , cacertPath ,
814
- "--key" , cakeyPath ,
815
- "--serial" , caserialPath ,
816
- ).CombinedOutput ()
810
+ cmdOutput := & bytes.Buffer {}
811
+ createSignerCertOptions := & admin.CreateSignerCertOptions {
812
+ CertFile : cacertPath ,
813
+ KeyFile : cakeyPath ,
814
+ SerialFile : caserialPath ,
815
+ Output : cmdOutput ,
816
+ }
817
+ _ , err = createSignerCertOptions .CreateSignerCert ()
817
818
if err != nil {
818
- return errors .NewError (fmt .Sprintf ("failed generating signer certificate, command output: %s\n error: %v" , out , err ))
819
- }
820
-
821
- // TODO: reconcile this oadm logic with https://github.com/openshift/origin/blob/master/pkg/bootstrap/docker/openshift/admin.go#L121-L149
822
- out , err = localcmd .New ("oc" ).Args (
823
- "adm" ,
824
- "create-api-client-config" ,
825
- "--certificate-authority" , cacertPath ,
826
- "--signer-cert" , cacertPath ,
827
- "--signer-key" , cakeyPath ,
828
- "--signer-serial" , caserialPath ,
829
- "--user" , "aggregator-front-proxy" ,
830
- "--client-dir" , configDir ,
831
- ).CombinedOutput ()
819
+ return errors .NewError ("cannot create signer cert" ).WithCause (err ).WithDetails (cmdOutput .String ())
820
+ }
821
+
822
+ cmdOutput = & bytes.Buffer {}
823
+ signerCertOptions := admin .NewDefaultSignerCertOptions ()
824
+ signerCertOptions .CertFile = cacertPath
825
+ signerCertOptions .KeyFile = cakeyPath
826
+ signerCertOptions .SerialFile = caserialPath
827
+
828
+ createClientOptions := & admin.CreateClientOptions {
829
+ SignerCertOptions : signerCertOptions ,
830
+ ClientDir : configDir ,
831
+ ExpireDays : crypto .DefaultCertificateLifetimeInDays ,
832
+ User : "aggregator-front-proxy" ,
833
+ Output : cmdOutput ,
834
+ }
835
+ err = createClientOptions .CreateClientFolder ()
832
836
if err != nil {
833
- return errors .NewError (fmt . Sprintf ( "failed generating client certificate, command output: %s \n error: %v" , out , err ))
837
+ return errors .NewError ("cannot create client config" ). WithCause ( err ). WithDetails ( cmdOutput . String ( ))
834
838
}
835
839
836
840
err = h .hostHelper .UploadFileToContainer (cacertPath , aggregatorCACertPath )
0 commit comments