Skip to content

Commit

Permalink
Merge pull request #3634 from dgageot/fix-get-latest
Browse files Browse the repository at this point in the history
Version can be in the process of being released
  • Loading branch information
tejal29 authored Feb 4, 2020
2 parents 7117450 + d15a3df commit 5bd0f1e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 79 deletions.
4 changes: 2 additions & 2 deletions hack/versions/cmd/latest/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (

"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/version"
"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"
)

// Print the latest version released.
func main() {
logrus.SetLevel(logrus.ErrorLevel)

current, _ := version.GetLatestVersion()
current, _ := schema.GetLatestVersion()
fmt.Println(current)
}
4 changes: 2 additions & 2 deletions hack/versions/cmd/latest_released/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (

"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/version"
hackschema "github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
)

// Print the latest version released.
func main() {
logrus.SetLevel(logrus.ErrorLevel)

current, latestIsReleased := version.GetLatestVersion()
current, latestIsReleased := hackschema.GetLatestVersion()

if latestIsReleased {
fmt.Println(current)
Expand Down
3 changes: 1 addition & 2 deletions hack/versions/cmd/new/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/sirupsen/logrus"

hackschema "github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"
"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/version"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
)
Expand All @@ -39,7 +38,7 @@ func main() {
prev := strings.TrimPrefix(schema.SchemaVersions[len(schema.SchemaVersions)-2].APIVersion, "skaffold/")
logrus.Infof("Previous Skaffold version: %s", prev)

current, latestIsReleased := version.GetLatestVersion()
current, latestIsReleased := hackschema.GetLatestVersion()

if !latestIsReleased {
logrus.Fatalf("There is no need to create a new version, %s is still not released", current)
Expand Down
7 changes: 3 additions & 4 deletions hack/versions/cmd/update_comments/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ import (

"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"
"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/version"
hackschema "github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"
)

func main() {
schemaDir := path.Join("pkg", "skaffold", "schema")
_, isReleased := version.GetLatestVersion()
_, isReleased := hackschema.GetLatestVersion()
if err := filepath.Walk(schemaDir, func(path string, info os.FileInfo, err error) error {
if info.Name() == "config.go" {
released := !strings.Contains(path, "latest") || isReleased
return schema.UpdateVersionComment(path, released)
return hackschema.UpdateVersionComment(path, released)
}
return nil
}); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions hack/versions/pkg/schema/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/diff"
"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/version"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
)

Expand Down Expand Up @@ -92,7 +91,7 @@ func RunSchemaCheckOnChangedFiles() error {
}

logrus.Infof("structural changes in latest config, checking on Github if latest is released...")
latestVersion, isReleased := version.GetLatestVersion()
latestVersion, isReleased := GetLatestVersion()
if !isReleased {
color.Green.Fprintf(os.Stdout, "%s is unreleased, it is safe to change it.\n", latestVersion)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package version
package schema

import (
"fmt"
Expand All @@ -32,9 +32,20 @@ import (
func GetLatestVersion() (string, bool) {
current := strings.TrimPrefix(latest.Version, "skaffold/")
logrus.Infof("Current Skaffold version: %s", current)
logrus.Infof("checking for released status of %s...", current)

config, err := ioutil.ReadFile("pkg/skaffold/schema/latest/config.go")
if err != nil {
logrus.Fatalf("failed to read latest config: %s", err)
}

if strings.Contains(string(config), "This config version is already released") {
return current, true
}

logrus.Infof("Checking for released status of %s...", current)
lastReleased := getLastReleasedConfigVersion()
logrus.Infof("last released version: %s", lastReleased)
logrus.Infof("Last released version: %s", lastReleased)

latestIsReleased := lastReleased == current
return current, latestIsReleased
}
Expand Down
64 changes: 0 additions & 64 deletions hack/versions/pkg/version.go

This file was deleted.

0 comments on commit 5bd0f1e

Please sign in to comment.