Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure configure command under cmd, remove public APIs #197

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build: go ocb
generate: generate-sources generate-goreleaser

generate-goreleaser: go
@${GO} run -tags releaser goreleaser/configure.go -d "${DISTRIBUTIONS}" > .goreleaser.yaml
@${GO} run cmd/goreleaser/main.go -d "${DISTRIBUTIONS}" > .goreleaser.yaml

generate-sources: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}
Expand Down
37 changes: 14 additions & 23 deletions goreleaser/configure.go → cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
//go:build releaser
// Copyright The OpenTelemetry Authors
//
// 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
//
// http://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 main
package internal

// This file is a script which generates the .goreleaser.yaml file for all
// supported OpenTelemetry Collector distributions.
//
// Run it with `make generate-goreleaser`.

import (
"flag"
"fmt"
"log"
"os"
"path"
"strings"

"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/nfpm/v2/files"
"gopkg.in/yaml.v2"
)

var (
ImagePrefixes = []string{"otel", "ghcr.io/open-telemetry/opentelemetry-collector-releases"}
Architectures = []string{"386", "amd64", "arm64", "ppc64le"}

distsFlag = flag.String("d", "", "Collector distributions(s) to build, comma-separated")
)

func main() {
flag.Parse()

if len(*distsFlag) == 0 {
log.Fatal("no distributions to build")
}
dists := strings.Split(*distsFlag, ",")

project := Generate(ImagePrefixes, dists)

if err := yaml.NewEncoder(os.Stdout).Encode(&project); err != nil {
log.Fatal(err)
}
}

func Generate(imagePrefixes []string, dists []string) config.Project {
return config.Project{
ProjectName: "opentelemetry-collector-releases",
Expand Down
43 changes: 43 additions & 0 deletions cmd/goreleaser/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright The OpenTelemetry Authors
//
// 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
//
// http://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 main

import (
"flag"
"log"
"os"
"strings"

"gopkg.in/yaml.v2"

"github.com/open-telemetry/opentelemetry-collector-releases/cmd/goreleaser/internal"
)

var distsFlag = flag.String("d", "", "Collector distributions(s) to build, comma-separated")

func main() {
flag.Parse()

if len(*distsFlag) == 0 {
log.Fatal("no distributions to build")
}
dists := strings.Split(*distsFlag, ",")

project := internal.Generate(internal.ImagePrefixes, dists)

if err := yaml.NewEncoder(os.Stdout).Encode(&project); err != nil {
log.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-telemetry/opentelemetry-collector-releases

go 1.17
go 1.18

require (
github.com/goreleaser/goreleaser v1.11.4
Expand Down
Loading