Skip to content

Commit 71962a1

Browse files
Merge pull request openshift#8562 from shiftstack/context
OSASINFRA-3510: Change 'Generate' to accept a context
2 parents 78ba1e8 + 41ac01a commit 71962a1

File tree

137 files changed

+402
-399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+402
-399
lines changed

pkg/asset/agent/agentconfig/agent_config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package agentconfig
22

33
import (
4+
"context"
45
"fmt"
56
"os"
67
"path/filepath"
@@ -40,7 +41,7 @@ func (*AgentConfig) Dependencies() []asset.Asset {
4041
}
4142

4243
// Generate generates the Agent Config manifest.
43-
func (a *AgentConfig) Generate(dependencies asset.Parents) error {
44+
func (a *AgentConfig) Generate(_ context.Context, dependencies asset.Parents) error {
4445
// TODO: We are temporarily generating a template of the agent-config.yaml
4546
// Change this when its interactive survey is implemented.
4647
agentConfigTemplate := `#

pkg/asset/agent/agentconfig/agenthosts.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package agentconfig
22

33
import (
4+
"context"
45
"fmt"
56
"path/filepath"
67
"strings"
@@ -59,7 +60,7 @@ func (a *AgentHosts) Dependencies() []asset.Asset {
5960
}
6061

6162
// Generate generates the Hosts data.
62-
func (a *AgentHosts) Generate(dependencies asset.Parents) error {
63+
func (a *AgentHosts) Generate(_ context.Context, dependencies asset.Parents) error {
6364
agentWorkflow := &workflow.AgentWorkflow{}
6465
addNodesConfig := &joiner.AddNodesConfig{}
6566
agentConfig := &AgentConfig{}

pkg/asset/agent/agentconfig/agenthosts_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package agentconfig
22

33
import (
4+
"context"
45
"net"
56
"testing"
67

@@ -296,7 +297,7 @@ func TestAgentHosts_Generate(t *testing.T) {
296297
parents.Add(tc.dependencies...)
297298

298299
asset := &AgentHosts{}
299-
err := asset.Generate(parents)
300+
err := asset.Generate(context.Background(), parents)
300301

301302
if tc.expectedError != "" {
302303
assert.Equal(t, tc.expectedError, err.Error())

pkg/asset/agent/common/infraenv.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package common
22

33
import (
4+
"context"
5+
46
"github.com/google/uuid"
57

68
"github.com/openshift/installer/pkg/asset"
@@ -19,7 +21,7 @@ func (a *InfraEnvID) Dependencies() []asset.Asset {
1921
}
2022

2123
// Generate generates the InfraEnvID for agent installer.
22-
func (a *InfraEnvID) Generate(dependencies asset.Parents) error {
24+
func (a *InfraEnvID) Generate(_ context.Context, dependencies asset.Parents) error {
2325
a.ID = uuid.New().String()
2426
return nil
2527
}

pkg/asset/agent/configimage/configiso.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package configimage
22

33
import (
4+
"context"
45
"os"
56
"path/filepath"
67
"strings"
@@ -35,7 +36,7 @@ func (a *ConfigImage) Dependencies() []asset.Asset {
3536
}
3637

3738
// Generate generates the configuration image file.
38-
func (a *ConfigImage) Generate(dependencies asset.Parents) error {
39+
func (a *ConfigImage) Generate(_ context.Context, dependencies asset.Parents) error {
3940
ignition := &image.Ignition{}
4041

4142
dependencies.Get(ignition)

pkg/asset/agent/gencrypto/authconfig.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gencrypto
22

33
import (
44
"bytes"
5+
"context"
56
"crypto/ecdsa"
67
"crypto/elliptic"
78
"crypto/rand"
@@ -37,7 +38,7 @@ func (a *AuthConfig) Dependencies() []asset.Asset {
3738
}
3839

3940
// Generate generates the auth config for agent installer APIs.
40-
func (a *AuthConfig) Generate(dependencies asset.Parents) error {
41+
func (a *AuthConfig) Generate(_ context.Context, dependencies asset.Parents) error {
4142
infraEnvID := &common.InfraEnvID{}
4243
dependencies.Get(infraEnvID)
4344
PublicKey, PrivateKey, err := keyPairPEM()

pkg/asset/agent/gencrypto/authconfig_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gencrypto
22

33
import (
4+
"context"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
@@ -23,7 +24,7 @@ func TestAuthConfig_Generate(t *testing.T) {
2324
parents.Add(&common.InfraEnvID{})
2425

2526
authConfigAsset := &AuthConfig{}
26-
err := authConfigAsset.Generate(parents)
27+
err := authConfigAsset.Generate(context.Background(), parents)
2728

2829
assert.NoError(t, err)
2930

pkg/asset/agent/image/agentartifacts.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package image
22

33
import (
4+
"context"
45
"encoding/json"
56
"fmt"
67
"os"
@@ -48,7 +49,7 @@ func (a *AgentArtifacts) Dependencies() []asset.Asset {
4849
}
4950

5051
// Generate generates the configurations for the agent ISO image and PXE assets.
51-
func (a *AgentArtifacts) Generate(dependencies asset.Parents) error {
52+
func (a *AgentArtifacts) Generate(_ context.Context, dependencies asset.Parents) error {
5253
ignition := &Ignition{}
5354
kargs := &Kargs{}
5455
baseIso := &BaseIso{}

pkg/asset/agent/image/agentimage.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package image
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"io"
@@ -52,7 +53,7 @@ func (a *AgentImage) Dependencies() []asset.Asset {
5253
}
5354

5455
// Generate generates the image file for to ISO asset.
55-
func (a *AgentImage) Generate(dependencies asset.Parents) error {
56+
func (a *AgentImage) Generate(ctx context.Context, dependencies asset.Parents) error {
5657
agentWorkflow := &workflow.AgentWorkflow{}
5758
clusterInfo := &joiner.ClusterInfo{}
5859
agentArtifacts := &AgentArtifacts{}
@@ -92,7 +93,7 @@ func (a *AgentImage) Generate(dependencies asset.Parents) error {
9293
logrus.Debugf("Using custom rootfs URL: %s", a.rootFSURL)
9394
} else {
9495
// Default to the URL from the RHCOS streams file
95-
defaultRootFSURL, err := baseIso.getRootFSURL(a.cpuArch)
96+
defaultRootFSURL, err := baseIso.getRootFSURL(ctx, a.cpuArch)
9697
if err != nil {
9798
return err
9899
}

pkg/asset/agent/image/agentpxefiles.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package image
22

33
import (
44
"compress/gzip"
5+
"context"
56
"encoding/json"
67
"errors"
78
"fmt"
@@ -41,7 +42,7 @@ func (a *AgentPXEFiles) Dependencies() []asset.Asset {
4142
}
4243

4344
// Generate generates the image files for PXE asset.
44-
func (a *AgentPXEFiles) Generate(dependencies asset.Parents) error {
45+
func (a *AgentPXEFiles) Generate(_ context.Context, dependencies asset.Parents) error {
4546
agentArtifacts := &AgentArtifacts{}
4647
dependencies.Get(agentArtifacts)
4748

0 commit comments

Comments
 (0)