Skip to content

Commit 80f2a52

Browse files
Merge pull request #15471 from bparees/backport_oc_binary
Automatic merge from submit-queue remove oc cluster up dependency on oc binary
2 parents 34e361b + 3b7e102 commit 80f2a52

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

pkg/bootstrap/docker/openshift/helper.go

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package openshift
22

33
import (
4+
"bytes"
45
"fmt"
56
"io"
67
"io/ioutil"
@@ -22,13 +23,14 @@ import (
2223
"github.com/openshift/origin/pkg/bootstrap/docker/errors"
2324
dockerexec "github.com/openshift/origin/pkg/bootstrap/docker/exec"
2425
"github.com/openshift/origin/pkg/bootstrap/docker/host"
25-
"github.com/openshift/origin/pkg/bootstrap/docker/localcmd"
2626
"github.com/openshift/origin/pkg/bootstrap/docker/run"
2727
defaultsapi "github.com/openshift/origin/pkg/build/admission/defaults/api"
2828
cliconfig "github.com/openshift/origin/pkg/cmd/cli/config"
29+
"github.com/openshift/origin/pkg/cmd/server/admin"
2930
configapi "github.com/openshift/origin/pkg/cmd/server/api"
3031
_ "github.com/openshift/origin/pkg/cmd/server/api/install"
3132
configapilatest "github.com/openshift/origin/pkg/cmd/server/api/latest"
33+
"github.com/openshift/origin/pkg/cmd/server/crypto"
3234
cmdutil "github.com/openshift/origin/pkg/cmd/util"
3335
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
3436
)
@@ -805,32 +807,34 @@ window.OPENSHIFT_CONSTANTS.ENABLE_TECH_PREVIEW_FEATURE = {
805807
certPath := filepath.Join(configDir, aggregatorCert)
806808
keyPath := filepath.Join(configDir, aggregatorKey)
807809

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()
817818
if err != nil {
818-
return errors.NewError(fmt.Sprintf("failed generating signer certificate, command output: %s\nerror: %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()
832836
if err != nil {
833-
return errors.NewError(fmt.Sprintf("failed generating client certificate, command output: %s\nerror: %v", out, err))
837+
return errors.NewError("cannot create client config").WithCause(err).WithDetails(cmdOutput.String())
834838
}
835839

836840
err = h.hostHelper.UploadFileToContainer(cacertPath, aggregatorCACertPath)

0 commit comments

Comments
 (0)