Skip to content

Commit

Permalink
Updating docker image checks to make sure JMX image available and use…
Browse files Browse the repository at this point in the history
…d for pipelines
  • Loading branch information
carlosroman committed Nov 27, 2024
1 parent 047dd64 commit 4cb277f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
11 changes: 7 additions & 4 deletions components/datadog/agent/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ func dockerAgentComposeManifest(agentImagePath string, apiKey pulumi.StringInput
}

func defaultAgentParams(params *dockeragentparams.Params) {
// After setting params.FullImagePath check if you need to use JMX Docker image
defer func(p *dockeragentparams.Params) {
if p.JMX {
p.FullImagePath = fmt.Sprintf("%s-jmx", p.FullImagePath)
}
}(params)

if params.FullImagePath != "" {
return
}
Expand All @@ -128,8 +135,4 @@ func defaultAgentParams(params *dockeragentparams.Params) {
params.ImageTag = defaultAgentImageTag
}
params.FullImagePath = utils.BuildDockerImagePath(params.Repository, params.ImageTag)

if params.JMX {
params.FullImagePath = fmt.Sprintf("%s-jmx", params.FullImagePath)
}
}
17 changes: 10 additions & 7 deletions components/datadog/dockeragentparams/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ func NewParams(e config.Env, options ...Option) (*Params, error) {
}

if e.PipelineID() != "" && e.CommitSHA() != "" {
exists, err := e.InternalRegistryImageTagExists(fmt.Sprintf("%s/agent", e.InternalRegistry()), fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA()))
if err != nil {
return nil, err
}
if !exists {
return nil, fmt.Errorf("image %s/agent:%s not found in the internal registry", e.InternalRegistry(), fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA()))
baseTag := fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA())
for _, tag := range []string{baseTag, fmt.Sprintf("%s-jmx", baseTag)} {
exists, err := e.InternalRegistryImageTagExists(fmt.Sprintf("%s/agent", e.InternalRegistry()), tag)
if err != nil {
return nil, err
}
if !exists {
return nil, fmt.Errorf("image %s/agent:%s not found in the internal registry", e.InternalRegistry(), tag)
}
}
options = append(options, WithFullImagePath(utils.BuildDockerImagePath("669783387624.dkr.ecr.us-east-1.amazonaws.com/agent", fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA()))))
options = append(options, WithFullImagePath(utils.BuildDockerImagePath("669783387624.dkr.ecr.us-east-1.amazonaws.com/agent", baseTag)))
}

return common.ApplyOption(version, options)
Expand Down

0 comments on commit 4cb277f

Please sign in to comment.